Update
This commit is contained in:
parent
4c6dc5c8b4
commit
c107733add
45
Dockerfile
45
Dockerfile
@ -1,43 +1,20 @@
|
||||
# =========================
|
||||
# 3) Production runtime
|
||||
# =========================
|
||||
# 1) Build stage
|
||||
FROM golang:1.21-alpine AS build
|
||||
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
|
||||
FROM debian:bullseye-slim AS production
|
||||
|
||||
# Install only minimal runtime deps
|
||||
RUN apt-get update && apt-get install -y \
|
||||
ca-certificates \
|
||||
tzdata \
|
||||
curl \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Create non-root user
|
||||
RUN apt-get update && apt-get install -y ca-certificates tzdata curl && rm -rf /var/lib/apt/lists/*
|
||||
RUN groupadd -r appuser && useradd -r -g appuser appuser
|
||||
|
||||
# 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
|
||||
|
||||
# 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
|
||||
|
||||
# Permissions
|
||||
RUN chown -R appuser:appuser /app /infra /migrations
|
||||
|
||||
# Env & timezone
|
||||
ENV TZ=Asia/Jakarta
|
||||
|
||||
# Network
|
||||
EXPOSE 3300
|
||||
|
||||
# Healthcheck
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
|
||||
CMD curl -fsS http://localhost:3300/health || exit 1
|
||||
|
||||
# Drop privileges
|
||||
USER appuser
|
||||
|
||||
# Default entrypoint -> run the server
|
||||
ENTRYPOINT ["/app"]
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
set -euo pipefail
|
||||
|
||||
APP_NAME="apskel-pos"
|
||||
PORT="3300" # match the app’s listen port (and EXPOSE/healthcheck)
|
||||
PORT="3300"
|
||||
|
||||
echo "🔄 Pulling latest code..."
|
||||
git pull
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user