Skip to content

Commit 6bbed16

Browse files
authored
Cleanup backend dockerfile (#56)
1 parent 22d5f56 commit 6bbed16

3 files changed

Lines changed: 57 additions & 1 deletion

File tree

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ docker/*
22
.github/*
33
test/*
44
out/*
5+
target/*
6+
site/*

.github/workflows/docker.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
uses: docker/build-push-action@v6
5656
with:
5757
context: .
58-
file: docker/Dockerfile
58+
file: docker/Dockerfile.backend
5959
push: true
6060
tags: ${{ steps.meta.outputs.tags }}
6161
labels: ${{ steps.meta.outputs.labels }}

docker/Dockerfile.backend

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#######################
2+
# Docker.backend
3+
#
4+
# Author: Andrei Tumbar
5+
# Brief: Build the Hermes code
6+
#
7+
#######################
8+
9+
############################################################
10+
# Backend build stage
11+
############################################################
12+
FROM golang:1.26-alpine AS builder-backend
13+
14+
# Install build dependencies
15+
RUN apk add --no-cache git make
16+
17+
WORKDIR /build
18+
19+
# Copy go mod files first for better caching
20+
COPY go.mod go.sum ./
21+
RUN go mod download
22+
23+
# Copy source code
24+
COPY . .
25+
26+
# Build the backend binary
27+
RUN CGO_ENABLED=0 GOOS=linux go build -o backend ./cmd/backend
28+
29+
############################################################
30+
# Runtime stage
31+
############################################################
32+
FROM alpine
33+
34+
# Install runtime dependencies
35+
RUN apk add --no-cache ca-certificates tzdata
36+
37+
WORKDIR /app
38+
39+
# Copy backend binary from builder
40+
COPY --from=builder-backend /build/backend /app/backend
41+
42+
# Create directories for config and data
43+
RUN mkdir -p /app/config /app/data
44+
45+
EXPOSE 6880
46+
47+
# Health check
48+
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
49+
CMD ["/app/backend", "--help"] || exit 1
50+
51+
RUN /app/backend --generate-config > /app/config/hermes.toml
52+
53+
ENTRYPOINT ["/app/backend"]
54+
CMD ["--bind", "0.0.0.0:6880", "--config", "app/config/hermes.toml", "--root", "/app/data", "--verbose"]

0 commit comments

Comments
 (0)