-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathDockerfile
34 lines (23 loc) · 1.08 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
# --- Stage 1: Build the Go binary ---
FROM golang:1.21-alpine AS builder
# Install git (needed for fetching dependencies)
RUN apk add --no-cache git
# Set the working directory inside the container
WORKDIR /app
# Copy go.mod and go.sum first for dependency resolution
COPY go.mod go.sum ./
# Download dependencies
RUN go mod download
# Copy the rest of the application source code
COPY . .
# Ensure the build is for Linux x86_64 (since you're on macOS)
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o remoteweather .
# --- Stage 2: Create a minimal runtime image ---
FROM alpine:latest
# Set working directory inside the container
WORKDIR /app
# Copy only the built binary from the builder stage
COPY --from=builder /app/remoteweather .
COPY entrypoint.sh .
# Set the default command to run the application
CMD ["./entrypoint.sh"]