apskel-pos-backend/Dockerfile

44 lines
1.1 KiB
Docker
Raw Normal View History

2025-09-01 16:14:15 +07:00
# =========================
# 3) Production runtime
# =========================
2025-07-18 20:10:29 +07:00
FROM debian:bullseye-slim AS production
2025-09-01 16:14:15 +07:00
# Install only minimal runtime deps
2025-07-18 20:10:29 +07:00
RUN apt-get update && apt-get install -y \
ca-certificates \
tzdata \
curl \
2025-09-01 16:14:15 +07:00
&& rm -rf /var/lib/apt/lists/*
2025-07-18 20:10:29 +07:00
2025-09-01 16:14:15 +07:00
# Create non-root user
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 app binary from build
COPY --from=build /out/app /app
# Copy infra/config files (if your app reads config/templates from here)
COPY --from=migration /src/infra /infra
2023-10-08 15:59:42 +07:00
2025-09-01 16:14:15 +07:00
# Optionally copy migrations and migrate binary so you can run migrations
COPY --from=migration /go/bin/migrate /usr/local/bin/migrate
COPY --from=migration /src/migrations /migrations
2025-07-18 20:10:29 +07:00
2025-09-01 16:14:15 +07:00
# Permissions
RUN chown -R appuser:appuser /app /infra /migrations
2023-10-08 15:59:42 +07:00
2025-09-01 16:14:15 +07:00
# Env & timezone
2023-10-08 15:59:42 +07:00
ENV TZ=Asia/Jakarta
2025-09-01 16:14:15 +07:00
# Network
2025-07-18 20:10:29 +07:00
EXPOSE 3300
2025-09-01 16:14:15 +07:00
# Healthcheck
2025-07-18 20:10:29 +07:00
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
2025-09-01 16:14:15 +07:00
CMD curl -fsS http://localhost:3300/health || exit 1
2025-07-18 20:10:29 +07:00
2025-09-01 16:14:15 +07:00
# Drop privileges
2025-07-18 20:10:29 +07:00
USER appuser
2025-09-01 16:14:15 +07:00
# Default entrypoint -> run the server
2023-10-08 15:59:42 +07:00
ENTRYPOINT ["/app"]