FROM docker.io/golang:1.25.5 AS builder WORKDIR /app # 1. Cache modules # RUN go env -w GOPROXY=https://package-mirror.liara.ir/repository/go/ # RUN go env -w GOSUMDB=off COPY go.mod go.sum ./ RUN go mod download -x # 2. Copy source code COPY . . # 3. Build arguments ARG VERSION="dev" # 4. Build the binary ENV CGO_ENABLED=0 RUN go build -trimpath -ldflags "-w -s -X 'medad.fun/internal/version.Version=${VERSION}'" -tags timetzdata -o /s ./cmd/main.go # ----------------------------------------- # Stage 2: Runner # ----------------------------------------- FROM scratch # 1. Copy the binary (CRITICAL) COPY --from=builder /s /dist # 2. Copy public assets (FIXED syntax) # COPY --from=builder /public /public # 3. Copy SSL certs COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ # 4. Security USER 248:248 EXPOSE 3000 # 5. Entry point ENTRYPOINT ["/dist"]