forked from fetch-rewards/receipt-processor-challenge
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
36 lines (23 loc) · 830 Bytes
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
FROM golang:1.22-alpine AS builder
RUN apk add --update --no-cache \
ca-certificates tzdata openssh git mercurial && update-ca-certificates \
&& rm -rf /var/cache/apk/*
WORKDIR /src
COPY go.mod* go.sum* ./
RUN --mount=type=cache,target=/go/pkg/mod go mod download
COPY . .
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
go install ./cmd/...
# RUN --mount=type=cache,target=/go/pkg/mod go generate ./...
FROM alpine
RUN adduser -S -D -H -h /app appuser
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder --chown=appuser:appuser /go/bin/* /bin/
COPY --chown=appuser:appuser ./static /app/static
WORKDIR /app
USER appuser
ENV PORT=8080
EXPOSE $PORT
CMD ["app"]