diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..c5a1fa7 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,42 @@ +{ + "name": "GitHub Codespaces (Default)", + "build": { + "dockerfile": "Dockerfile" + }, + "settings": { + "go.toolsManagement.checkForUpdates": "local", + "go.useLanguageServer": true, + "go.gopath": "/go", + "go.goroot": "/usr/local/go", + "go.linting.enabled": true, + "lldb.executable": "/usr/bin/lldb", + "files.watcherExclude": { + "**/target/**": true + } + }, + "remoteUser": "codespace", + "overrideCommand": false, + "mounts": ["source=codespaces-linux-var-lib-docker,target=/var/lib/docker,type=volume"], + "runArgs": [ + "--cap-add=SYS_PTRACE", + "--security-opt", + "seccomp=unconfined", + "--privileged", + "--init" + ], + + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "GitHub.vscode-pull-request-github", + "golang.go", + "hashicorp.terraform", + "wholroyd.hcl", + "github.copilot" + ], + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // "oryx build" will automatically install your dependencies and attempt to build your project + // "postCreateCommand": "oryx build -p virtualenv_name=.venv --log-file /tmp/oryx-build.log --manifest-dir /tmp || echo 'Could not auto-build. Skipping.'" +} diff --git a/.drone.yml b/.drone.yml index 940f8cf..f6d0e7f 100644 --- a/.drone.yml +++ b/.drone.yml @@ -50,10 +50,10 @@ steps: - trivy fs --exit-code 0 --severity UNKNOWN,LOW,MEDIUM . # Perform code security check of higher level vulnerabilities. This can break the build. - # - trivy fs --skip-update --exit-code 1 --severity CRITICAL,HIGH . + - trivy fs --skip-update --exit-code 1 --severity CRITICAL,HIGH . # Build new container image. - # - docker buildx build --push --platform linux/amd64 --progress plain -t ${DRONE_REPO}:${DRONE_COMMIT} -f docker/Dockerfile . + # - docker buildx build --push --platform linux/amd64 --progress plain --build-arg SEMVER="${DRONE_SEMVER:0.0.3}" -t ${DRONE_REPO}:${DRONE_COMMIT} -f docker/Dockerfile . # Perform image security check of lower level vulnerabilities. This will not break the build, we just want this information, just in case. # - trivy image --skip-update --exit-code 0 --severity UNKNOWN,LOW,MEDIUM,HIGH ${DRONE_REPO}:${DRONE_COMMIT} diff --git a/docker/Dockerfile b/docker/Dockerfile index 3c613e8..bc1d0ce 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,4 +1,6 @@ -FROM golang:1.17-alpine3.14 as builder +# FROM golang:1.17-alpine3.14 as builder +FROM dragonheim/golang:1.17.0 as builder +ARG SEMVER WORKDIR /gagent COPY . . @@ -8,13 +10,15 @@ ARG GOOS=${GOOS:-linux} ARG CGO_ENABLED=1 RUN apk add --no-cache zeromq-dev build-base git -RUN go build -o /gagent/bin/gagent gagent/main.go +RUN go build -o /gagent/bin/gagent -ldflags "-X main.semVER=${SEMVER}" gagent/main.go RUN strip /gagent/bin/gagent FROM alpine:3.14 +ARG vernum LABEL Name="G'Agent" LABEL Maintainer="jwells@dragonheim.net" LABEL License="MIT License" +LABEL version="${SEMVER}" RUN apk add --no-cache zeromq && mkdir -p -m 0700 /etc/gagent COPY --from=builder /gagent/examples/gagent.hcl /etc/gagent/gagent.hcl @@ -25,3 +29,5 @@ EXPOSE 35570/tcp 35571/tcp 35572/tcp VOLUME /etc/gagent CMD ["/usr/bin/gagent"] + +HEALTHCHECK NONE diff --git a/gagent/main.go b/gagent/main.go index 5d061e1..b73c686 100644 --- a/gagent/main.go +++ b/gagent/main.go @@ -20,7 +20,9 @@ import ( cty "github.com/zclconf/go-cty/cty" ) -const versionNum = "0.0.1" +var ( + semVER = "0.0.2" +) var exitCodes = struct { m map[string]int @@ -106,15 +108,15 @@ func main() { usage += "\n" usage += "Arguments: \n" - usage += " client -- Start as a G'Agent client \n" - usage += " router -- Start as a G'Agent router \n" - usage += " worker -- Start as a G'Agent worker \n" - usage += " setup -- Write initial configuration file \n" + usage += " client -- Start as a G'Agent client \n" + usage += " router -- Start as a G'Agent router \n" + usage += " worker -- Start as a G'Agent worker \n" + usage += " setup -- Write initial configuration file \n" usage += "\n" usage += "Options:\n" - usage += " -h --help -- Show this help screen \n" - usage += " --version -- Show version \n" + usage += " -h --help -- Show this help screen and exit \n" + usage += " --version -- Show version and exit \n" usage += " --config= -- [default: /etc/gagent/gagent.hcl] \n" usage += " --agent= -- filename of the agent to be uploaded to the G'Agent network \n" @@ -122,7 +124,7 @@ func main() { * Consume the usage variable and the command line arguments to create a * dictionary / map. */ - opts, _ := docopt.ParseArgs(usage, nil, versionNum) + opts, _ := docopt.ParseArgs(usage, nil, semVER) log.Printf("[DEBUG] Arguments are %v\n", opts) if opts["--config"] != nil {