-
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Dockerfile
33 lines (22 loc) · 797 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
FROM golang:1.20-alpine AS builder
ARG VERSION="0.0.0-docker"
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 \
CGO_ENABLED=0 go install -ldflags "-X main.version=$VERSION" ./cmd/...
FROM alpine
RUN adduser -S -D -H -h /app appuser
USER 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 /go/bin/* /bin/
ENV PORT=8080
EXPOSE $PORT
VOLUME ["/var/www"]
CMD ["serve", "--dir", "/var/www"]