-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
29 lines (20 loc) · 710 Bytes
/
Dockerfile
File metadata and controls
29 lines (20 loc) · 710 Bytes
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
# Use an official Golang runtime as a parent image
FROM golang:1.24 AS builder
# Set the working directory
WORKDIR /app
# Copy the file from your host to your current location
COPY go.mod go.sum ./
# Download all dependencies. Dependencies will be cached if the go.mod and go.sum files are not changed
RUN go mod download
# Copy the rest of the source code
COPY . .
# Build the Go app
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o filetree cmd/server/main.go
# Use a minimal alpine image
FROM alpine:latest
# Set the working directory
WORKDIR /root/
# Copy the Pre-built binary file from the previous stage
COPY --from=builder /app/filetree .
# Set the entry point
CMD ["./filetree"]