-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
42 lines (30 loc) · 1.09 KB
/
Copy pathDockerfile
File metadata and controls
42 lines (30 loc) · 1.09 KB
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
37
38
39
40
41
42
# Stage 1: Build the application
FROM golang:1.26-alpine AS builder
# Install build dependencies: git and gcc/musl-dev for CGO (required by go-sqlite3)
RUN apk add --no-cache git gcc musl-dev
# Set the working directory inside the container
WORKDIR /app
# Copy go.mod and go.sum files first for better layer caching
COPY go.mod go.sum ./
RUN go mod download
# Copy the rest of the source code
COPY . .
# Build the application
# CGO_ENABLED=1 is required for go-sqlite3
RUN CGO_ENABLED=1 GOOS=linux go build -o quantix-math main.go
# Stage 2: Run the application
FROM alpine:latest
# Install ca-certificates and timezone data
RUN apk add --no-cache ca-certificates tzdata
WORKDIR /root/
# Copy the binary from the builder stage
COPY --from=builder /app/quantix-math .
# Copy runtime assets required by the application
# Based on your main.go, these are necessary:
COPY --from=builder /app/views ./views
COPY --from=builder /app/assets ./assets
COPY --from=builder /app/settings ./settings
# Expose the port the app listens on (from app.Listen(":3301"))
EXPOSE 3301
# Run the binary
CMD ["./quantix-math"]