Update Dockerfile
Browse files- Dockerfile +29 -1
Dockerfile
CHANGED
|
@@ -1,13 +1,41 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
USER root
|
| 4 |
|
|
|
|
|
|
|
| 5 |
RUN chmod -R 777 /app
|
| 6 |
|
|
|
|
|
|
|
| 7 |
COPY entrypoint.sh /entrypoint.sh
|
| 8 |
|
| 9 |
RUN chmod +x /entrypoint.sh
|
| 10 |
|
|
|
|
|
|
|
| 11 |
USER 10001
|
| 12 |
|
| 13 |
ENTRYPOINT ["/entrypoint.sh"]
|
|
|
|
|
|
|
|
|
| 1 |
+
# ---------- Build stage ----------
|
| 2 |
+
ARG GO_VERSION=1.24
|
| 3 |
+
FROM golang:${GO_VERSION}-bookworm AS builder
|
| 4 |
+
WORKDIR /src
|
| 5 |
+
|
| 6 |
+
RUN apt-get update && apt-get install -y git
|
| 7 |
+
|
| 8 |
+
# Clone sources from GitHub
|
| 9 |
+
RUN git clone https://github.com/boltrunner/gcli2api.git .
|
| 10 |
+
|
| 11 |
+
COPY server.go /internal/server/server.go
|
| 12 |
+
|
| 13 |
+
# Optionally download modules, build
|
| 14 |
+
RUN go mod download
|
| 15 |
+
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH:-amd64} \
|
| 16 |
+
go build -trimpath -ldflags="-s -w" -o /out/gcli2api .
|
| 17 |
+
|
| 18 |
+
# ---------- Runtime stage ----------
|
| 19 |
+
FROM alpine:3.20 AS runtime
|
| 20 |
+
|
| 21 |
+
WORKDIR /app
|
| 22 |
|
| 23 |
USER root
|
| 24 |
|
| 25 |
+
RUN apk --no-cache add ca-certificates
|
| 26 |
+
|
| 27 |
RUN chmod -R 777 /app
|
| 28 |
|
| 29 |
+
COPY --from=builder /out/gcli2api /app/gcli2api
|
| 30 |
+
|
| 31 |
COPY entrypoint.sh /entrypoint.sh
|
| 32 |
|
| 33 |
RUN chmod +x /entrypoint.sh
|
| 34 |
|
| 35 |
+
RUN adduser -D -H -u 10001 appuser
|
| 36 |
+
|
| 37 |
USER 10001
|
| 38 |
|
| 39 |
ENTRYPOINT ["/entrypoint.sh"]
|
| 40 |
+
|
| 41 |
+
CMD ["server", "-c", "/app/config.json"]
|