-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.template
34 lines (25 loc) · 1003 Bytes
/
Dockerfile.template
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
# Generated by https://chat.openai.com/share/005e710c-e4eb-4369-8ece-441d0c2b62c5
# First stage: build the executable
FROM golang:1.21 as builder
# Set the Current Working Directory inside the container
WORKDIR /app
# Copy go.mod and go.sum and download dependencies
COPY go.* ./
RUN go mod download
# Copy the source code into the container
COPY . .
# Build the application
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main ./cmd/twilio
# Second stage: create the final image
# Alpine is a minimalistic version of Linux suitable for Docker deployments, due to smaller attack surface,
# faster setup and such.
# BUT I historically had really hard time setting up more advanced libraries with it (as ffmpeg).
FROM alpine:latest
# Add CA Certificates
RUN apk --no-cache add ca-certificates
# Copy the pre-built binary file from the previous stage
COPY --from=builder /app/main .
# Expose port (if your app uses a port)
EXPOSE 8080
# Command to run the executable
CMD ["./main"]