-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
47 lines (33 loc) · 1.31 KB
/
Dockerfile
File metadata and controls
47 lines (33 loc) · 1.31 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
# ── Stage 1: Build dos binários Go ──────────────────────────────
FROM golang:1.22-alpine AS builder
RUN apk add --no-cache git ca-certificates
WORKDIR /app
COPY go.mod ./
RUN go mod download || true
COPY . .
RUN go mod tidy
# Compila os 3 serviços
RUN CGO_ENABLED=0 GOOS=linux go build -o /bin/ingestor ./cmd/ingestor
RUN CGO_ENABLED=0 GOOS=linux go build -o /bin/predictor ./cmd/predictor
RUN CGO_ENABLED=0 GOOS=linux go build -o /bin/api ./cmd/api
# ── Stage 2: Imagem final mínima ────────────────────────────────
FROM alpine:3.19
RUN apk add --no-cache ca-certificates tzdata
ENV TZ=America/Bahia
WORKDIR /app
# Copia os binários compilados
COPY --from=builder /bin/ingestor ./ingestor
COPY --from=builder /bin/predictor ./predictor
COPY --from=builder /bin/api ./api
# Copia o frontend estático
COPY --from=builder /app/frontend ./frontend
# Variável para selecionar qual serviço rodar
# Valores: ingestor | predictor | api
ENV SERVICE=api
ENV PORT=8080
EXPOSE 8080
# Script de entrada que seleciona o serviço
RUN echo '#!/bin/sh' > /entrypoint.sh && \
echo 'exec /app/$SERVICE' >> /entrypoint.sh && \
chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]