File size: 1,702 Bytes
83a59ca
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# syntax=docker/dockerfile:1
# ============================================================
# Stage 1 — Nuxt 3 static SPA build (web/)
# ============================================================
FROM node:22-alpine AS web-builder
WORKDIR /build
COPY web/ ./
RUN npm install -g pnpm@11.11.0 \
 && pnpm install --frozen-lockfile
# web/.env (committed, public build-time config: API_BASE_URL, Firebase web config, Turnstile site key)
RUN pnpm generate
# -> /build/.output/public (static SPA)

# ============================================================
# Stage 2 — Go Fiber API build (api/)
# ============================================================
FROM golang:1.26-alpine AS api-builder
WORKDIR /build
COPY api/ ./
RUN CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags "-s -w" -o /httpsms-api .

# ============================================================
# Stage 3 — runtime: nginx :7860 + API :8000 + psql seeding
# ============================================================
FROM alpine:3.20
RUN apk add --no-cache nginx postgresql postgresql-client redis ca-certificates curl tzdata \
 && adduser -D -u 1000 user \
 && mkdir -p /usr/share/nginx/html /var/log/nginx /var/lib/nginx \
 && chown -R user:user /usr/share/nginx/html /var/log/nginx /var/lib/nginx /etc/nginx /tmp

COPY --from=web-builder --chown=user:user /build/.output/public/ /usr/share/nginx/html/
COPY --from=api-builder --chown=user:user /httpsms-api /usr/local/bin/httpsms-api
COPY --chown=user:user nginx.hf.conf /etc/nginx/nginx.conf
COPY --chown=user:user entrypoint.sh /entrypoint.sh

RUN chmod +x /entrypoint.sh

USER user
ENV HOME=/home/user
WORKDIR /home/user
EXPOSE 7860
ENTRYPOINT ["/entrypoint.sh"]