2022-03-20 13:05:10 +01:00
|
|
|
FROM golang:1.17-alpine as builder
|
2021-12-09 12:19:56 +01:00
|
|
|
|
2022-01-13 10:34:14 +01:00
|
|
|
# Install dependencies for copy
|
2022-03-20 13:05:10 +01:00
|
|
|
RUN apk add -U --no-cache ca-certificates tzdata git
|
2021-12-09 17:56:55 +01:00
|
|
|
|
2022-01-13 10:34:14 +01:00
|
|
|
# Use an valid GOPATH and copy the files
|
2021-12-09 12:19:56 +01:00
|
|
|
WORKDIR /go/src/github.com/cooperspencer/gickup
|
2022-03-20 13:05:10 +01:00
|
|
|
COPY go.mod .
|
|
|
|
COPY go.sum .
|
|
|
|
RUN go mod tidy
|
2021-12-09 12:19:56 +01:00
|
|
|
COPY . .
|
|
|
|
|
2022-01-13 10:34:14 +01:00
|
|
|
# Fetching dependencies and build the app
|
2021-12-09 12:19:56 +01:00
|
|
|
RUN go get -d -v ./...
|
|
|
|
RUN CGO_ENABLED=0 go build -a -installsuffix cgo -o app .
|
|
|
|
|
2022-01-13 10:34:14 +01:00
|
|
|
# Use scratch as production environment -> Small builds
|
2021-12-09 12:19:56 +01:00
|
|
|
FROM scratch as production
|
|
|
|
WORKDIR /
|
2022-01-13 10:34:14 +01:00
|
|
|
# Copy valid SSL certs from the builder for fetching github/gitlab/...
|
2021-12-09 17:56:55 +01:00
|
|
|
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
2022-01-13 10:34:14 +01:00
|
|
|
# Copy zoneinfo for getting the right cron timezone
|
2021-12-17 05:15:45 +01:00
|
|
|
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
|
2022-01-13 10:34:14 +01:00
|
|
|
# Copy the main executable from the builder
|
|
|
|
COPY --from=builder /go/src/github.com/cooperspencer/gickup/app /gickup/app
|
|
|
|
|
|
|
|
ENTRYPOINT [ "/gickup/app" ]
|
|
|
|
CMD [ "/gickup/conf.yml" ]
|