-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdockerfile
More file actions
35 lines (24 loc) · 868 Bytes
/
dockerfile
File metadata and controls
35 lines (24 loc) · 868 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
30
31
32
33
34
35
# Stage 1: Build the application
FROM golang:1.25-alpine AS builder
WORKDIR /app
# Copy go.mod and go.sum first to leverage Docker layer caching
COPY go.mod go.sum ./
RUN go mod download
# Copy the rest of the application source code
COPY . .
# Build the Go application
RUN CGO_ENABLED=0 GOOS=linux go build -o /go-app ./cli/sandbox/main.go
# Stage 2: Create a minimal runtime image
FROM alpine:latest
WORKDIR /app
# Copy the built binary from the builder stage
COPY --from=builder /go-app .
# ✅ Copy SQLite/DB file from the builder stage
# Assuming your project path is: /app/pkg/db/sql/index.db
COPY --from=builder /app/pkg/db/sql/index.db /app/pkg/db/sql/index.db
# Create directory if not exists (optional edge case fix)
RUN mkdir -p /app/sql
# Expose the port your application listens on
EXPOSE 8088
# Command to run the application
CMD ["./go-app"]