Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove several unused build files and update the docker images to work. #317

Merged
merged 3 commits into from
Oct 31, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
37 changes: 37 additions & 0 deletions .release/docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env sh
set -e

# check arguments for an option that would cause /argus to stop
# return true if there is one
_want_help() {
local arg
for arg; do
case "$arg" in
-'?'|--help|-v)
return 0
;;
esac
done
return 1
}

_main() {
# if command starts with an option, prepend argus
if [ "${1:0:1}" = '-' ]; then
set -- /argus "$@"
fi

# skip setup if they aren't running /argus or want an option that stops /argus
if [ "$1" = '/argus' ] && ! _want_help "$@"; then
echo "Entrypoint script for argus Server ${VERSION} started."

if [ ! -s /etc/argus/argus.yaml ]; then
echo "Building out template for file"
/bin/spruce merge /tmp/argus_spruce.yaml > /etc/argus/argus.yaml
fi
fi

exec "$@"
}

_main "$@"
33 changes: 27 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,40 @@ RUN apk add --no-cache --no-progress \
libc-dev \
upx

# Download spruce here to eliminate the need for curl in the final image
RUN mkdir -p /go/bin && \
curl -o /go/bin/spruce https://github.com/geofffranks/spruce/releases/download/v1.29.0/spruce-linux-amd64 && \
curl -L -o /go/bin/spruce https://github.com/geofffranks/spruce/releases/download/v1.29.0/spruce-linux-amd64 && \
chmod +x /go/bin/spruce

COPY . .

RUN make test release

FROM alpine:3.12.1
##########################
# Build the final image.
##########################

FROM alpine:latest

# Copy over the standard things you'd expect.
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /src/argus /
COPY --from=builder /src/.release/docker/entrypoint.sh /

# Copy over spruce and the spruce template file used to make the actual configuration file.
COPY --from=builder /src/.release/docker/argus_spruce.yaml /tmp/argus_spruce.yaml
COPY --from=builder /go/bin/spruce /bin/

COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /src/argus /src/argus.yaml /src/deploy/packaging/entrypoint.sh /go/bin/spruce /src/Dockerfile /src/NOTICE /src/LICENSE /src/CHANGELOG.md /
COPY --from=builder /src/deploy/packaging/argus_spruce.yaml /tmp/argus_spruce.yaml
# Include compliance details about the container and what it contains.
COPY --from=builder /src/Dockerfile \
/src/NOTICE \
/src/LICENSE \
/src/CHANGELOG.md /

RUN mkdir /etc/argus/ && touch /etc/argus/argus.yaml && chmod 666 /etc/argus/argus.yaml
# Make the location for the configuration file that will be used.
RUN mkdir /etc/argus/ \
&& touch /etc/argus/argus.yaml \
&& chmod 666 /etc/argus/argus.yaml

USER nobody

Expand Down
20 changes: 9 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@


DOCKER ?= docker
GO ?= go
GOFMT ?= $(GO)fmt
APP := argus
DOCKER_ORG := xmidt
DOCKER_ORG := ghcr.io/xmidt-org

VERSION ?= $(shell git describe --tag --always --dirty)
PROGVER ?= $(shell git describe --tags `git rev-list --tags --max-count=1` | tail -1 | sed 's/v\(.*\)/\1/')
Expand All @@ -16,21 +14,21 @@ GOBUILDFLAGS = -a -ldflags "-w -s -X 'main.BuildTime=$(BUILDTIME)' -X main.GitCo
default: build

generate:
$(GO) generate ./...
$(GO) install ./...
go generate ./...
go install ./...

test:
$(GO) test -v -race -coverprofile=coverage.txt ./...
$(GO) test -v -race -json ./... > report.json
go test -v -race -coverprofile=coverage.txt ./...
go test -v -race -json ./... > report.json

style:
! $(GOFMT) -d $$(find . -path ./vendor -prune -o -name '*.go' -print) | grep '^'
! gofmt -d $$(find . -path ./vendor -prune -o -name '*.go' -print) | grep '^'

check:
golangci-lint run -n | tee errors.txt

build:
CGO_ENABLED=0 $(GO) build $(GOBUILDFLAGS)
CGO_ENABLED=0 go build $(GOBUILDFLAGS)

release: build
upx $(APP)
Expand All @@ -42,8 +40,8 @@ docker:

binaries: generate
mkdir -p ./.ignore
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 $(GO) build -o ./.ignore/$(APP)-$(PROGVER).darwin-amd64 -ldflags "-X 'main.BuildTime=$(BUILDTIME)' -X main.GitCommit=$(GITCOMMIT) -X main.Version=$(VERSION)"
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GO) build -o ./.ignore/$(APP)-$(PROGVER).linux-amd64 -ldflags "-X 'main.BuildTime=$(BUILDTIME)' -X main.GitCommit=$(GITCOMMIT) -X main.Version=$(VERSION)"
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o ./.ignore/$(APP)-$(PROGVER).darwin-amd64 -ldflags "-X 'main.BuildTime=$(BUILDTIME)' -X main.GitCommit=$(GITCOMMIT) -X main.Version=$(VERSION)"
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ./.ignore/$(APP)-$(PROGVER).linux-amd64 -ldflags "-X 'main.BuildTime=$(BUILDTIME)' -X main.GitCommit=$(GITCOMMIT) -X main.Version=$(VERSION)"

upx ./.ignore/$(APP)-$(PROGVER).darwin-amd64
upx ./.ignore/$(APP)-$(PROGVER).linux-amd64
Expand Down
6 changes: 0 additions & 6 deletions conf/argus.env.example

This file was deleted.

18 changes: 0 additions & 18 deletions conf/argus.service

This file was deleted.

48 changes: 0 additions & 48 deletions deploy/Dockerfile

This file was deleted.

16 changes: 0 additions & 16 deletions deploy/docker_push

This file was deleted.

90 changes: 0 additions & 90 deletions deploy/packaging/argus.spec

This file was deleted.

49 changes: 0 additions & 49 deletions deploy/packaging/entrypoint.sh

This file was deleted.

2 changes: 0 additions & 2 deletions rpkg.conf

This file was deleted.

23 changes: 0 additions & 23 deletions rpkg.macros

This file was deleted.