Dockerfile update
parent
2ea97c1111
commit
e3fbf65ad6
47
Dockerfile
47
Dockerfile
|
|
@ -1,41 +1,38 @@
|
||||||
# ====== STAGE 1: build ======
|
# ====== STAGE 1: build (Chainguard/Wolfi -> usa apk) ======
|
||||||
FROM golang:latest AS builder
|
FROM cgr.dev/chainguard/go:latest AS builder
|
||||||
|
|
||||||
# Installa tool utili per mod e certs (git, ca)
|
|
||||||
RUN apt install git ca-certificates -y
|
|
||||||
|
|
||||||
|
#RUN apk add --no-cache git ca-certificates
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
|
|
||||||
|
# (consigliato: scarica mod prima per caching)
|
||||||
|
#COPY go.mod go.sum ./
|
||||||
|
#RUN go mod download
|
||||||
|
#RUN go mod vendor
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN go mod tidy ; go mod vendor
|
RUN go mod tidy
|
||||||
|
RUN go mod vendor
|
||||||
|
ENV CGO_ENABLED=0 GOOS=linux GOARCH=amd64
|
||||||
# Compila binario statico e snello
|
|
||||||
ENV CGO_ENABLED=0
|
|
||||||
RUN go build -trimpath -ldflags="-s -w" -o /out/money ./...
|
RUN go build -trimpath -ldflags="-s -w" -o /out/money ./...
|
||||||
|
|
||||||
# ====== STAGE 2: runtime ======
|
# ====== STAGE 2: runtime (Debian da ECR Public) ======
|
||||||
FROM alpine:3.20
|
FROM public.ecr.aws/docker/library/debian:bookworm-slim
|
||||||
|
|
||||||
# Certificati TLS per HTTPS (Binance/THOR/Matrix) + tzdata opzionale
|
RUN set -eux; \
|
||||||
RUN apk add --no-cache ca-certificates tzdata
|
apt-get update; \
|
||||||
|
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
|
||||||
|
ca-certificates tzdata bash curl git; \
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Crea utente non-root
|
# crea utente non-root (USER appuser ti falliva perché non esisteva)
|
||||||
RUN adduser -D -u 1001 appuser
|
RUN useradd -r -u 10001 -g root appuser
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Directory dati persistenti (montabili come volume)
|
|
||||||
RUN mkdir -p /app/data /app/state && chown -R appuser:appuser /app
|
|
||||||
|
|
||||||
# Copia binario
|
|
||||||
COPY --from=builder /out/money /app/money
|
COPY --from=builder /out/money /app/money
|
||||||
|
|
||||||
USER appuser
|
USER 10001
|
||||||
|
|
||||||
# Env di default (puoi sovrascriverle in compose)
|
|
||||||
ENV DATA_DIR=/app/data \
|
ENV DATA_DIR=/app/data \
|
||||||
STATE_DIR=/app/state
|
STATE_DIR=/app/state
|
||||||
|
|
||||||
# Avvio demone
|
ENTRYPOINT ["/app/money"]
|
||||||
CMD ["/app/money"]
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue