-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
executable file
·39 lines (38 loc) · 1019 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
37
38
39
FROM golang:1.21 as builder
ENV USER=appuser \
UID=10001 \
GO111MODULE=on \
CGO_ENABLED=0 \
GOOS=linux
RUN adduser \
--disabled-password \
--gecos "" \
--home "/nonexistent" \
--shell "/sbin/nologin" \
--no-create-home \
--uid "${UID}" \
"${USER}"
WORKDIR /app
RUN mkdir -p /app/templates
RUN mkdir -p /app/static
COPY *.go /app/
COPY go.* /app/
COPY templates /app/templates/
COPY static /app/static/
RUN cd /app && \
go build -ldflags="-s -w" -a -o server
FROM ubuntu:23.04
COPY --from=builder /etc/passwd /etc/passwd
COPY --from=builder /etc/group /etc/group
ENV DEBIAN_FRONTEND=noninteractive \
USER=appuser \
APP_PORT=8000
WORKDIR /app
COPY --chown=${USER}:${USER} --from=builder /app/server .
RUN chown -Rv ${USER}:${USER} /app
EXPOSE ${APP_PORT}
RUN apt-get -qq update && apt-get -qq install -y --no-install-recommends curl net-tools netcat-openbsd dnsutils && \
apt clean && \
rm -rf /var/lib/apt/lists/*
USER ${USER}:${USER}
CMD ["/app/server"]