-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
36 lines (24 loc) · 699 Bytes
/
Dockerfile
File metadata and controls
36 lines (24 loc) · 699 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
# Dockerfile
# Stage 1: Build the Golang binary
FROM golang:latest AS builder
WORKDIR /app
COPY go.mod .
COPY go.sum .
RUN go mod download
COPY . .
# Build the Go application
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app .
# Stage 2: Create a minimal image with only the binary and necessary files
FROM alpine:latest
WORKDIR /app
COPY --from=builder /app/app .
COPY --from=builder /app/docs/ ./docs/
COPY --from=builder /app/migrations ./migrations/
COPY --from=builder /app/.env ./.env
# Set environment variables
ENV DATABASE_URL $DSN
# Expose port 8000 for the Golang application
EXPOSE 8000
VOLUME /app/data
# Command to run the Golang application
CMD ["./app"]