Skip to content

Commit

Permalink
Merge pull request #361 from its-a-feature/docker_updates
Browse files Browse the repository at this point in the history
Docker updates
  • Loading branch information
its-a-feature authored Jan 28, 2024
2 parents e80fe95 + 3f574ee commit 30856d7
Show file tree
Hide file tree
Showing 66 changed files with 4,350 additions and 2,800 deletions.
569 changes: 569 additions & 0 deletions .github/workflows/docker.yml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ linux:
cd Mythic_CLI && make && mv mythic-cli ../

macos:
cd Mythic_CLI && make build_all_macos && mv mythic-cli ../
cd Mythic_CLI && make build_macos && mv mythic-cli ../

macos_local:
cd Mythic_CLI && make build_binary_macos_local
20 changes: 20 additions & 0 deletions Mythic_CLI/.docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#FROM itsafeaturemythic/mythic_go_base:latest
FROM golang:1.21-alpine
WORKDIR /usr/src/app

ARG GOPROXY=proxy.golang.org
ARG GO111MODULE

RUN go env -w GOPROXY=${GOPROXY}
RUN go env -w GO111MODULE=${GO111MODULE}

COPY ["src/", "."]

RUN apk add --no-cache make

RUN make build_all

FROM alpine

COPY --from=0 /usr/src/app/mythic-cli_linux /mythic-cli_linux
COPY --from=0 /usr/src/app/mythic-cli_macos /mythic-cli_macos
6 changes: 6 additions & 0 deletions Mythic_CLI/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## 0.2.3 - 2023-12-27

### Changed

- Updated the 3rd party service additions to respect existing volume mounts

## 0.2.2 - 2023-09-07

### Changed
Expand Down
17 changes: 1 addition & 16 deletions Mythic_CLI/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1 @@
FROM itsafeaturemythic/mythic_go_base:latest

WORKDIR /usr/src/app

ARG GOPROXY=proxy.golang.org
ARG GO111MODULE

RUN go env -w GOPROXY=${GOPROXY}
RUN go env -w GO111MODULE=${GO111MODULE}

COPY ["src/", "."]

RUN go mod download
RUN go mod tidy

CMD ["/bin/bash", "-c", "make", "build"]
FROM ghcr.io/its-a-feature/mythic_cli:v0.0.3
24 changes: 10 additions & 14 deletions Mythic_CLI/Makefile
Original file line number Diff line number Diff line change
@@ -1,29 +1,25 @@
BINARY_NAME=mythic-cli
LOCAL_PATH=$(shell pwd)/src
LOCAL_PATH=$(shell pwd)
BUILDER_IMAGE=ghcr.io/its-a-feature/mythic_cli:v0.0.3
.PHONY: default
default: build_all_linux ;
default: build_linux ;

# pull in build and env options from global settings
-include ../build.env
-include ../.env

export

build_container:
docker build -t mythic-cli --build-arg GOPROXY --build-arg GO111MODULE .

build_binary:
docker run --env GOPROXY --env GO111MODULE --name mythic-cli-builder --rm -v ${LOCAL_PATH}:/usr/src/app mythic-cli make build_linux
mv src/${BINARY_NAME} .
chmod +x ${BINARY_NAME}
build_binary_linux:
docker run -v ${LOCAL_PATH}/copy_file/:/copy_file/ --rm -ti ${BUILDER_IMAGE} sh -c "cp /mythic-cli_linux /copy_file/mythic-cli"
mv ./copy_file/${BINARY_NAME} . && rm -rf ./copy_file && chmod +x ${BINARY_NAME}

build_binary_macos:
docker run --env GOPROXY --env GO111MODULE --name mythic-cli-builder --rm -v ${LOCAL_PATH}:/usr/src/app mythic-cli make build_macos
mv src/${BINARY_NAME} .
chmod +x ${BINARY_NAME}
docker run -v ${LOCAL_PATH}/copy_file/:/copy_file/ --rm -ti ${BUILDER_IMAGE} sh -c "cp /mythic-cli_macos /copy_file/mythic-cli"
mv ./copy_file/${BINARY_NAME} . && rm -rf ./copy_file && chmod +x ${BINARY_NAME}

build_binary_macos_local:
cd src && go build -o ../../mythic-cli .

build_all_linux: build_container build_binary
build_all_macos: build_container build_binary_macos
build_linux: build_binary_linux
build_macos: build_binary_macos
10 changes: 8 additions & 2 deletions Mythic_CLI/src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@ BINARY_NAME=mythic-cli
export

build:
go mod download
go mod tidy
go build -o ${BINARY_NAME} .

build_linux:
GOOS=linux go build -o ${BINARY_NAME} .
go mod tidy
GOOS=linux go build -o ${BINARY_NAME}_linux .

build_macos:
GOOS=darwin go build -o ${BINARY_NAME} .
go mod tidy
GOOS=darwin go build -o ${BINARY_NAME}_macos .

build_all: build_linux build_macos

run:
./${BINARY_NAME}
Expand Down
12 changes: 10 additions & 2 deletions Mythic_CLI/src/cmd/addDockerCompose.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package cmd

import (
"github.com/MythicMeta/Mythic_CLI/cmd/config"
"github.com/MythicMeta/Mythic_CLI/cmd/internal"
"github.com/MythicMeta/Mythic_CLI/cmd/utils"
"github.com/spf13/cobra"
"log"
)

// configCmd represents the config command
Expand All @@ -19,7 +22,12 @@ func init() {
}

func addDockerCompose(cmd *cobra.Command, args []string) {
if err := internal.AddDockerComposeEntry(args[0], make(map[string]interface{})); err != nil {

if utils.StringInSlice(args[0], config.MythicPossibleServices) {
internal.AddMythicService(args[0])
return
}
err := internal.Add3rdPartyService(args[0], make(map[string]interface{}))
if err != nil {
log.Printf("[-] Failed to add service")
}
}
2 changes: 1 addition & 1 deletion Mythic_CLI/src/cmd/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func init() {
}

func buildContainer(cmd *cobra.Command, args []string) {
if err := internal.DockerBuild(args); err != nil {
if err := internal.ServiceBuild(args); err != nil {

}
}
4 changes: 2 additions & 2 deletions Mythic_CLI/src/cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package cmd

import (
"fmt"
"github.com/MythicMeta/Mythic_CLI/cmd/internal"
"github.com/MythicMeta/Mythic_CLI/cmd/config"
"github.com/spf13/cobra"
"os"
"sort"
Expand Down Expand Up @@ -35,7 +35,7 @@ func configDisplay(cmd *cobra.Command, args []string) {
fmt.Fprintf(writer, "\n %s\t%s", "Setting", "Value")
fmt.Fprintf(writer, "\n %s\t%s", "–––––––", "–––––––")

configuration := internal.GetConfigAllStrings()
configuration := config.GetConfigAllStrings()
keys := make([]string, 0, len(configuration))
for k := range configuration {
keys = append(keys, k)
Expand Down
4 changes: 4 additions & 0 deletions Mythic_CLI/src/cmd/config/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package config

// MythicDockerLatest is the most recent tagged version pushed to GitHub packages
const MythicDockerLatest = "v0.0.3"
Loading

0 comments on commit 30856d7

Please sign in to comment.