-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
39 lines (27 loc) · 689 Bytes
/
Dockerfile
File metadata and controls
39 lines (27 loc) · 689 Bytes
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
# Etapa de build
FROM golang:1.25.1-alpine AS builder
WORKDIR /app
# Dependencias
RUN apk add --no-cache make bash git
# Copiar go.mod y descargar deps primero para cachear layers
COPY go.mod go.sum ./
RUN go mod download
# Copiar todo el proyecto
COPY . .
# Instalar pq
RUN go get github.com/lib/pq@latest
# Compilar
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o tmp/my-app .
# Etapa final
FROM alpine:latest
#WORKDIR /app
WORKDIR /root/
# Copiar binario desde builder
COPY --from=builder /app/tmp/my-app .
# Copiar directorio static
COPY --from=builder /app/static ./static
# Exponer puerto
EXPOSE 8080
# Ejecutar app
CMD ["./my-app"]
#CMD ["air", "-c", ".air.toml"]