-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
40 lines (31 loc) · 1.13 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
FROM node as compress
COPY web /web
RUN mkdir /compressed
RUN npm install html-minifier -g
RUN html-minifier --collapse-whitespace --remove-comments --remove-optional-tags --remove-redundant-attributes --remove-script-type-attributes --remove-tag-whitespace --use-short-doctype --minify-css true --minify-js true -o /compressed/index.html /web/index.html
FROM golang as builder
RUN dpkgArch="$(dpkg --print-architecture)"; \
case "$dpkgArch" in \
arm) ARCH='arm' ;; \
arm64) ARCH='arm64' ;; \
amd64) ARCH='amd64' ;; \
386) ARCH='386' ;; \
*) echo >&2 "error: unsupported architecture: $apkArch"; exit 1 ;; \
esac
RUN mkdir -p /app
RUN adduser --disabled-password --gecos "" --home /app --uid 1001 server
RUN mkdir -p /build
COPY main.go /build/main.go
COPY go.mod /build/go.mod
RUN cd /build && \
go mod tidy && \
CGO_ENABLED=0 GOOS=linux go build -trimpath -o '/app/server' ./main.go && \
chmod +x /app/server && \
chown -R 1001 /app/
FROM scratch
COPY --from=builder /app /app
COPY --from=compress /compressed /app/web
EXPOSE 8090
USER 1001
WORKDIR /app
ENTRYPOINT ["/app/server"]