forked from awsl-project/maxx
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
78 lines (54 loc) · 1.67 KB
/
Dockerfile
File metadata and controls
78 lines (54 loc) · 1.67 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
69
70
71
72
73
74
75
76
77
78
# Multi-stage build for maxx
# Stage 1: Build frontend
FROM node:22-alpine AS frontend-builder
# Install pnpm
RUN corepack enable && corepack prepare pnpm@latest --activate
WORKDIR /app/web
# Copy frontend package files
COPY web/package.json ./
# Install frontend dependencies
RUN pnpm install
# Copy frontend source
COPY web/ ./
# Build args for version info
ARG VITE_COMMIT=unknown
# Build frontend
RUN VITE_COMMIT=${VITE_COMMIT} pnpm build
# Stage 2: Build backend
FROM golang:alpine AS backend-builder
# Install build dependencies
RUN apk add --no-cache git
WORKDIR /app
# Copy go mod files
COPY go.mod go.sum ./
# Download dependencies
RUN go mod download
# Copy source code
COPY cmd/ ./cmd/
COPY internal/ ./internal/
# Build args for version info
ARG VERSION=dev
ARG COMMIT=unknown
ARG BUILD_TIME=unknown
# Build backend binary with version info
RUN CGO_ENABLED=0 GOOS=linux go build \
-ldflags="-s -w \
-X github.com/awsl-project/maxx/internal/version.Version=${VERSION} \
-X github.com/awsl-project/maxx/internal/version.Commit=${COMMIT} \
-X github.com/awsl-project/maxx/internal/version.BuildTime=${BUILD_TIME}" \
-o maxx cmd/maxx/main.go
# Stage 3: Final runtime image
FROM alpine:latest
# Install runtime dependencies (tzdata for timezone support)
RUN apk add --no-cache ca-certificates tzdata
WORKDIR /app
# Copy binary from backend builder
COPY --from=backend-builder /app/maxx .
# Copy built frontend from frontend builder
COPY --from=frontend-builder /app/web/dist ./web/dist
# Create directory for data (database, logs, etc.)
RUN mkdir -p /data
# Expose port
EXPOSE 9880
# Run the application
CMD ["./maxx", "-addr", ":9880", "-data", "/data"]