-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
35 lines (26 loc) · 725 Bytes
/
Copy pathDockerfile
File metadata and controls
35 lines (26 loc) · 725 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
# Build stage for Go application
FROM golang:1.25.1-alpine as go-builder
RUN apk update && \
apk upgrade --no-cache && \
apk add --no-cache binutils ca-certificates gcc musl-dev sqlite-dev
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
ENV CGO_ENABLED=1
ENV GOOS=linux
RUN go build -o api
# Production stage
FROM alpine:latest
RUN apk --no-cache add ca-certificates sqlite tzdata
WORKDIR /root/
# Copy the built application
COPY --from=go-builder /app/api .
# Create directory for SQLite database
RUN mkdir -p /data
# Expose port
EXPOSE 8080
# Set environment variable for database path
ENV DB_PATH=/data/dailies.db
# Run the application
CMD ["sh", "-c", "./api -port 8080 -db-path ${DB_PATH}"]