Spaces:
Paused
Paused
Upload Dockerfile
Browse files- Dockerfile +27 -0
Dockerfile
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Start from the official Golang image
|
| 2 |
+
FROM golang:1.23-alpine AS build
|
| 3 |
+
|
| 4 |
+
# Set working directory
|
| 5 |
+
WORKDIR /app
|
| 6 |
+
|
| 7 |
+
# Copy go.mod and go.sum files first for better caching
|
| 8 |
+
COPY go.mod go.sum* ./
|
| 9 |
+
|
| 10 |
+
# Download dependencies
|
| 11 |
+
RUN go mod download
|
| 12 |
+
|
| 13 |
+
# Copy the source code
|
| 14 |
+
COPY . .
|
| 15 |
+
|
| 16 |
+
# Build the application
|
| 17 |
+
RUN CGO_ENABLED=0 GOOS=linux go build -o main ./main.go
|
| 18 |
+
|
| 19 |
+
# Create a minimal production image
|
| 20 |
+
FROM alpine:latest
|
| 21 |
+
|
| 22 |
+
# Create app directory and set permissions
|
| 23 |
+
WORKDIR /app
|
| 24 |
+
COPY --from=build /app/main .
|
| 25 |
+
|
| 26 |
+
# Command to run the executable
|
| 27 |
+
CMD ["./main"]
|