-
Notifications
You must be signed in to change notification settings - Fork 10
/
Dockerfile
40 lines (32 loc) · 1.04 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 --platform=$BUILDPLATFORM golang:1.23.3 as build
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
ARG TARGETPLATFORM
# Set Golang build envs based on Docker platform string
RUN --mount=type=cache,target=/root/.cache \
set -x \
&& case "$TARGETPLATFORM" in \
'linux/amd64') export GOARCH=amd64 ;; \
'linux/arm/v6') export GOARCH=arm GOARM=6 ;; \
'linux/arm/v7') export GOARCH=arm GOARM=7 ;; \
'linux/arm64' | 'linux/arm64/v8') export GOARCH=arm64 ;; \
*) echo "Unsupported target: $TARGETPLATFORM" && exit 1 ;; \
esac \
&& go generate \
&& CGO_ENABLED=0 go build -ldflags='-w -s' -trimpath -tags gzip
FROM alpine:3.20
RUN apk add --no-cache tzdata
ARG USERNAME=ascii-movie
ARG UID=1000
ARG GID=$UID
RUN addgroup -g "$GID" "$USERNAME" \
&& adduser -S -u "$UID" -G "$USERNAME" "$USERNAME"
COPY --from=build /app/ascii-movie /bin
ENV TERM=xterm-256color
ENV ASCII_MOVIE_SSH_HOST_KEY=/data/id_ed25519,/data/id_rsa
VOLUME /data
USER $UID
ENTRYPOINT ["ascii-movie"]
CMD ["serve"]