-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
33 lines (22 loc) · 732 Bytes
/
Dockerfile
File metadata and controls
33 lines (22 loc) · 732 Bytes
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
# build 1
FROM golang:1.24.4-alpine3.21 AS build
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN go build -ldflags "-X main.version=v1.3.1" -o poke-cli .
# build 2
FROM --platform=$BUILDPLATFORM alpine:latest
# Install only necessary packages and remove them after use
RUN apk add --no-cache shadow && \
addgroup -S poke_group && adduser -S poke_user -G poke_group && \
sed -i 's/^root:.*/root:!*:0:0:root:\/root:\/sbin\/nologin/' /etc/passwd && \
apk del shadow
COPY --from=build /app/poke-cli /app/poke-cli
ENV TERM=xterm-256color
ENV COLOR_OUTPUT=true
# Set correct permissions
RUN chown -R poke_user:poke_group /app
# Switch to non-root user
USER poke_user
ENTRYPOINT ["/app/poke-cli"]