-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
50 lines (35 loc) · 1.26 KB
/
Dockerfile
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
48
49
50
# Build Stage
FROM golang:1.23-bookworm AS builder
# Set the working directory inside the container
WORKDIR /app
# Install certificates for secure communication
RUN apt-get update && apt-get install -y ca-certificates
# Copy the Go modules files for dependency installation
COPY go.mod go.sum ./
# Download Go module dependencies
RUN go mod download
# Copy the rest of the application files
COPY . .
# Build the Go application with CGO enabled for certificate validation
RUN CGO_ENABLED=1 GOOS=linux go build -o /myapp .
# Final Stage
FROM debian:bookworm-slim
# Install necessary certificates and update CA store
RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/*
# Copy the CA certificate into the container
COPY google_cert.crt /usr/local/share/ca-certificates/
RUN update-ca-certificates
# Set working directory
WORKDIR /app
# Copy the built application from the builder stage
COPY --from=builder /myapp /app/myapp
# Copy configuration files into the container
COPY .env /app/.env
COPY config.yaml /app/config.yaml
COPY google-service.json /app/google-service.json
# Expose the application port
EXPOSE 8000
# Ensure the executable has the right permissions
RUN chmod +x /app/myapp
# Command to run the application
CMD ["/app/myapp"]