-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
53 lines (37 loc) · 1.69 KB
/
Copy pathDockerfile
File metadata and controls
53 lines (37 loc) · 1.69 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
43
44
45
46
47
48
49
50
51
52
53
# Build stage
FROM golang:1.23.12-alpine AS builder
# Install build dependencies for CGo (required by go-sqlite3)
RUN apk add --no-cache gcc musl-dev
WORKDIR /app
# Download dependencies first (layer caching)
COPY go.mod go.sum ./
RUN go mod download
# Copy source code and build
COPY . .
RUN CGO_ENABLED=1 go build -o relay-server -ldflags="-s -w" ./cmd/relay
# Runtime stage
FROM alpine:3.20
# OCI labels — required by GHCR to link the package to the repository and
# display metadata on the package page.
# Ref: https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry#labelling-container-images
LABEL org.opencontainers.image.source="https://github.com/AOSSIE-Org/ThruBox-Server" \
org.opencontainers.image.description="Lightweight, self-hosted relay server for ephemeral message passing" \
org.opencontainers.image.licenses="GPL-3.0" \
org.opencontainers.image.title="ThruBox-Server" \
org.opencontainers.image.vendor="AOSSIE"
RUN apk add --no-cache ca-certificates
RUN addgroup -S relay && adduser -S -G relay relay
COPY --from=builder /app/relay-server /usr/local/bin/relay-server
COPY --from=builder /app/config.yaml /etc/relay/config.yaml
# Create data directory for SQLite and set ownership
RUN mkdir -p /data && chown -R relay:relay /data
# Set default storage path to the mounted volume
ENV RELAY_STORAGE_PATH=/data/relay.db
# Point the binary at the config file copied in above. Without this the
# process starts from / and silently falls back to built-in defaults,
# ignoring the bundled config.yaml entirely.
ENV RELAY_CONFIG_PATH=/etc/relay/config.yaml
USER relay
EXPOSE 3000
VOLUME ["/data"]
CMD ["relay-server"]