commit bad397ea4b7becfaf736c45a50c93f7f5659b570 parent e0001487424dc23d4c58e179ef231afd5a5c4968 Author: Vetle Haflan <vetle@haflan.dev> Date: Sun, 19 Apr 2020 23:39:10 +0200 Add Dockerfile and attempted CI build+push Diffstat:
A | .gitlab-ci.yml | | | 6 | ++++++ |
A | Dockerfile | | | 25 | +++++++++++++++++++++++++ |
2 files changed, 31 insertions(+), 0 deletions(-)
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml @@ -0,0 +1,6 @@ +build_image: + script: + - docker build -t d.haflan.dev/general/sermoni:latest . + - docker push d.haflan.dev/general/sermoni + only: + - master diff --git a/Dockerfile b/Dockerfile @@ -0,0 +1,25 @@ +### Builder stage +FROM golang:alpine AS builder + +RUN apk update && apk add --no-cache git npm +COPY . $GOPATH/src/sermoni/ + +# Build website files and move html.go +WORKDIR $GOPATH/src/sermoni/ui/ +RUN npm install; \ + npm run build; \ + mv $GOPATH/src/sermoni/ui/dist/html.go $GOPATH/src/sermoni/internal/http/ +# Build the sermoni binary +WORKDIR $GOPATH/src/sermoni/ +RUN go get -d ./... ; \ + GOOS=linux GOOARCH=amd64 go build \ + -ldflags="-w -s" \ + -o /go/bin/sermoni \ + -tags PRODUCUTION \ + ./cmd/sermoni/ + +### Production image +FROM scratch +COPY --from=builder /go/bin/sermoni /sermoni +RUN mkdir -p /data +ENTRYPOINT ["/sermoni", "-d", "/data/sermoni.db"]