-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
68 lines (49 loc) · 1.57 KB
/
Dockerfile
File metadata and controls
68 lines (49 loc) · 1.57 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Build stage
FROM golang:1.24-alpine AS builder
ARG VERSION=dev
RUN apk add --no-cache git
WORKDIR /app
# Copy go mod files first for caching
COPY go.mod go.sum ./
RUN go mod download
# Install templ
RUN go install github.com/a-h/templ/cmd/templ@latest
# Copy source code
COPY . .
# Generate templ files and build
RUN templ generate && \
CGO_ENABLED=0 GOOS=linux go build \
-ldflags="-s -w -X github.com/melonamin/ghvault/pkg/version.Version=${VERSION}" \
-o /ghv ./cmd/ghv
# Runtime stage
FROM alpine:3.20
ARG VERSION=dev
# OCI Image labels
LABEL org.opencontainers.image.title="GHVault"
LABEL org.opencontainers.image.description="GitHub backup tool for homelabs"
LABEL org.opencontainers.image.version="${VERSION}"
LABEL org.opencontainers.image.source="https://github.com/melonamin/ghvault"
LABEL org.opencontainers.image.licenses="MIT"
RUN apk add --no-cache \
git \
git-lfs \
openssh-client \
ca-certificates \
tzdata
# Create non-root user
RUN adduser -D -u 1000 ghvault
USER ghvault
WORKDIR /home/ghvault
# Copy binary from builder
COPY --from=builder /ghv /usr/local/bin/ghv
# Create directories for config and backups
RUN mkdir -p /home/ghvault/.config/ghvault /home/ghvault/backups
# Default environment
ENV GHVAULT_CONFIG=/home/ghvault/.config/ghvault/config.yaml
# Expose web UI port
EXPOSE 8080
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD wget -q --spider http://localhost:8080/api/health || exit 1
# Default command starts the web server
CMD ["ghv", "serve", "--addr", "0.0.0.0:8080"]