Update Dockerfile

This commit is contained in:
Astra 2026-02-16 17:41:35 +00:00
parent 03c5ec07c1
commit d44e3c09d3

View file

@ -1,15 +1,36 @@
FROM golang:1.25.6-alpine AS builder FROM golang:1.25.6-alpine AS builder
WORKDIR /go/src/git.zio.sh/telegram-approval-join WORKDIR /src
# Install git for module downloads
RUN apk add --no-cache git
# Cache modules
COPY go.mod go.sum ./
RUN go mod download
# Copy source and build a static, stripped binary
COPY . . COPY . .
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
go build -ldflags="-s -w" -o /bin/telegram-approval-join ./...
RUN apk update && \ FROM alpine:3.19
apk add --no-cache git bash && \
go get -d -v ./... && \
go install
FROM alpine:latest # Install CA certs for TLS
RUN apk add --no-cache ca-certificates
COPY --from=builder /go/bin/telegram-approval-join /usr/local/bin/telegram-approval-join # Set working directory where config.yaml will live
WORKDIR /opt
CMD ["telegram-approval-join"] # Copy binary into a standard location
COPY --from=builder /bin/telegram-approval-join /usr/local/bin/telegram-approval-join
# Create a non-root user and group with specific UID:GID and set ownership
RUN addgroup -g 65532 app && \
adduser -D -H -u 65532 -G app -s /sbin/nologin app -h /opt && \
chown -R app:app /opt/telegram-approval-join /usr/local/bin/telegram-approval-join
# Run as the created non-root user
USER app:app
ENTRYPOINT ["/usr/local/bin/telegram-approval-join"]