-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
38 lines (29 loc) · 1.13 KB
/
Dockerfile
File metadata and controls
38 lines (29 loc) · 1.13 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
# Use the official Golang image to build the weightless
FROM golang:1.25-alpine AS builder
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
ARG VERSION=dev
RUN CGO_ENABLED=0 go build \
-ldflags "-X main.version=${VERSION} -X main.commit=$(git rev-parse --short HEAD 2>/dev/null || echo unknown) -X main.date=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
-o weightless ./cmd/tracker/
# Use a lightweight alpine image for the final container
FROM alpine:latest
# Install Litestream
RUN apk add --no-cache ca-certificates
ADD https://github.com/benbjohnson/litestream/releases/download/v0.3.13/litestream-v0.3.13-linux-amd64.tar.gz /tmp/litestream.tar.gz
RUN tar -C /usr/local/bin -xzf /tmp/litestream.tar.gz
# Create data directory
RUN mkdir -p /data
# Copy weightless binary and configuration
COPY --from=builder /app/weightless /usr/local/bin/weightless
COPY .env.local /usr/local/bin/.env.local
COPY litestream.yml /etc/litestream.yml
COPY scripts/run.sh /usr/local/bin/run.sh
RUN chmod +x /usr/local/bin/run.sh
# Set DB path for the application
ENV DB_PATH=/data/weightless.db
ENV PORT=8080
EXPOSE 8080
CMD ["/usr/local/bin/run.sh"]