Files
apskel-pos-backend/Dockerfile
T

21 lines
708 B
Docker
Raw Normal View History

2025-09-01 16:20:27 +07:00
# 1) Build stage
2026-05-12 18:46:12 +07:00
FROM golang:1.24-alpine AS build
2025-09-01 16:20:27 +07:00
RUN apk --no-cache add ca-certificates tzdata git curl
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o /out/app ./cmd/server
# 2) Production stage
2025-07-18 20:10:29 +07:00
FROM debian:bullseye-slim AS production
2025-09-01 16:20:27 +07:00
RUN apt-get update && apt-get install -y ca-certificates tzdata curl && rm -rf /var/lib/apt/lists/*
2025-07-18 20:10:29 +07:00
RUN groupadd -r appuser && useradd -r -g appuser appuser
2025-09-01 16:14:15 +07:00
COPY --from=build /out/app /app
2025-07-18 20:10:29 +07:00
ENV TZ=Asia/Jakarta
2026-04-26 23:25:54 +07:00
EXPOSE 4000
2025-07-18 20:10:29 +07:00
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
CMD curl -fsS http://localhost:4000/health || exit 1
2025-07-18 20:10:29 +07:00
USER appuser
2023-10-08 15:59:42 +07:00
ENTRYPOINT ["/app"]