-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
59 lines (42 loc) · 1.38 KB
/
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
FROM node:16.14.2 AS node-builder
RUN npm i -g [email protected]
WORKDIR /build
COPY ./frontend ./
RUN pnpm install --frozen-lockfile
RUN pnpm build
FROM golang:1.18-alpine AS go-builder
RUN apk update && apk add --no-cache git ca-certificates tzdata && update-ca-certificates
ENV USER=tiny
ENV UID=10001
RUN adduser \
--disabled-password \
--gecos "" \
--home "/nonexistent" \
--shell "/sbin/nologin" \
--no-create-home \
--uid "${UID}" \
"${USER}"
WORKDIR $GOPATH/src/github.com/lukecarr/tiny-todo
COPY go.mod .
ENV GO111MODULE=on
RUN go mod download
RUN go mod verify
COPY . .
COPY --from=node-builder /build/dist ./frontend/dist/
ENV CGO_ENABLED=0
ENV GOOS=linux
ENV GOARCH=amd64
ARG BUILD_VERSION
ARG BUILD_COMMIT
ARG BUILD_DATE
RUN go build -ldflags="-w -s -extldflags '-static' -X github.com/lukecarr/tiny-todo/internal/info.Version=${BUILD_VERSION} -X github.com/lukecarr/tiny-todo/internal/info.Commit=${BUILD_COMMIT} -X github.com/lukecarr/tiny-todo/internal/info.Date=${BUILD_DATE}" -a -o /usr/bin/tiny-todo main.go
FROM scratch
COPY --from=go-builder /usr/share/zoneinfo /usr/share/zoneinfo
COPY --from=go-builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=go-builder /etc/passwd /etc/passwd
COPY --from=go-builder /etc/group /etc/group
COPY --from=go-builder /usr/bin/tiny-todo /usr/bin/tiny-todo
EXPOSE 3000
USER tiny
ENTRYPOINT ["tiny-todo"]
CMD ["serve"]