fix(devops): Dockerfile & .local.env support added
Hello World / hello (push) Has been cancelled
Build / test-and-build (scribblers-linux-x64, ubuntu-latest) (push) Has been cancelled
Build / test-and-build (scribblers-macos-x64, macos-latest) (push) Has been cancelled
Build / test-and-build (scribblers-x64.exe, windows-latest) (push) Has been cancelled
Hello World / hello (push) Has been cancelled
Build / test-and-build (scribblers-linux-x64, ubuntu-latest) (push) Has been cancelled
Build / test-and-build (scribblers-macos-x64, macos-latest) (push) Has been cancelled
Build / test-and-build (scribblers-x64.exe, windows-latest) (push) Has been cancelled
This commit is contained in:
+42
@@ -0,0 +1,42 @@
|
||||
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 .env /.env
|
||||
# COPY --from=builder /public /public
|
||||
|
||||
# 3. Copy SSL certs (UNCOMMENTED)
|
||||
# COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
||||
|
||||
# 4. Security
|
||||
USER 248:248
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
# 5. Entry point
|
||||
ENTRYPOINT ["/dist"]
|
||||
Reference in New Issue
Block a user