feat: Converting to semantic versioning and add .devcontainer.

This commit is contained in:
James Wells 2021-09-08 18:40:57 -07:00
parent f7d62890dd
commit 7e805a399e
Signed by: jwells
GPG key ID: 73196D10B8E65666
4 changed files with 62 additions and 12 deletions

View file

@ -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.'"
}

View file

@ -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}

View file

@ -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

View file

@ -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=<config> -- [default: /etc/gagent/gagent.hcl] \n"
usage += " --agent=<file> -- 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 {