-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
37 lines (25 loc) · 861 Bytes
/
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
# Stage 1: Build the Go application
FROM golang:1.22-alpine AS builder
# Set the working directory inside the container
WORKDIR /app
# Copy the go.mod and go.sum files first to utilize Docker cache efficiently
COPY go.mod go.sum ./
# Download dependencies
RUN go mod download
# Copy the rest of the application source code
COPY cmd/ ./cmd/
COPY pkg/ ./pkg/
# Build the Go application binary
RUN go build -o main ./cmd/main.go
# Stage 2: Create a small image with the compiled binary
FROM alpine:latest
# Install curl in the Alpine image
RUN apk add --no-cache curl
# Set the working directory inside the container
WORKDIR /app
# Copy the binary and script from the builder stage
COPY --from=builder /app/main .
COPY scripts/entrypoint.sh /app/entrypoint.sh
RUN chmod +x /app/entrypoint.sh
# Command to run the Go application
CMD ["./entrypoint.sh"]