El Dockerfile no incluía el directorio agent/, por eso GET /agent/install.sh y GET /agent/download/:filename devolvían 404 — los archivos no existían en /app/agent/ dentro del contenedor. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
46 lines
1.6 KiB
Docker
46 lines
1.6 KiB
Docker
# ──────────────────────────────────────────
|
|
# Stage 1: Build del binario Go
|
|
# Los assets del frontend (public/) se compilan localmente
|
|
# antes del push con: npm run production
|
|
# ──────────────────────────────────────────
|
|
FROM golang:1.24-alpine AS builder
|
|
WORKDIR /app
|
|
|
|
# Instalar dependencias del sistema necesarias para CGO (argon2, etc.)
|
|
RUN apk add --no-cache gcc musl-dev
|
|
|
|
COPY go.mod go.sum ./
|
|
RUN go mod download
|
|
|
|
COPY . .
|
|
|
|
RUN CGO_ENABLED=1 GOOS=linux go build -ldflags="-s -w" -o apiv2 .
|
|
|
|
# ──────────────────────────────────────────
|
|
# Stage 3: Imagen final mínima
|
|
# ──────────────────────────────────────────
|
|
FROM alpine:3.20
|
|
WORKDIR /app
|
|
|
|
# Certificados TLS y timezone
|
|
RUN apk add --no-cache ca-certificates tzdata
|
|
|
|
# Copiar binario compilado
|
|
COPY --from=builder /app/apiv2 .
|
|
|
|
# Copiar archivos estáticos y plantillas
|
|
COPY --from=builder /app/public ./public
|
|
COPY --from=builder /app/resources/views ./resources/views
|
|
COPY --from=builder /app/assets ./assets
|
|
|
|
# Copiar agente (binarios pre-compilados + install.sh para descarga)
|
|
COPY --from=builder /app/agent/install.sh ./agent/install.sh
|
|
COPY --from=builder /app/agent/dist ./agent/dist
|
|
|
|
# Copiar configuración real (las credenciales se sobreescriben con variables de entorno)
|
|
COPY config.yml ./config.yml
|
|
|
|
EXPOSE 8080
|
|
|
|
ENTRYPOINT ["./apiv2", "-config", "config.yml"]
|