-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
48 lines (33 loc) · 1.26 KB
/
Copy pathDockerfile
File metadata and controls
48 lines (33 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# ─── Multi-stage build ──────────────────────────────────
# Stage 1: Build Go binary
FROM golang:1.22-alpine AS builder
RUN apk add --no-cache gcc musl-dev
WORKDIR /app
# Cache dependencies
COPY go.mod go.sum ./
RUN go mod download
# Build (CGO_ENABLED=0 since we use PGX, not SQLite CGO)
COPY . .
RUN CGO_ENABLED=0 go build -ldflags="-s -w" -o /app/container-cost ./cmd/server
# Stage 2: Runtime
FROM alpine:3.19
RUN apk add --no-cache ca-certificates tzdata
ENV TZ=Asia/Jakarta
WORKDIR /app
# Copy binary
COPY --from=builder /app/container-cost .
# Copy frontend (only needed for server mode, harmless for agent)
COPY --from=builder /app/web/dist ./web/dist
# Volume for config & database (server mode only)
VOLUME ["/data"]
# Expose API port (server mode only)
EXPOSE 8080
# Default env
ENV PORT=8080
ENV CONTAINER_COST_CONFIG_DIR=/data
# Labels for GitHub Container Registry
LABEL org.opencontainers.image.title="Container Cost"
LABEL org.opencontainers.image.description="Docker Container Cost Calculator — Agent & Central Server"
LABEL org.opencontainers.image.source="https://github.com/edsuwarna/container-cost"
LABEL org.opencontainers.image.licenses="MIT"
ENTRYPOINT ["/app/container-cost"]