-
Notifications
You must be signed in to change notification settings - Fork 56
Expand file tree
/
Copy pathDockerfile.bundle.sqlite
More file actions
94 lines (77 loc) · 3.35 KB
/
Dockerfile.bundle.sqlite
File metadata and controls
94 lines (77 loc) · 3.35 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# Multi-stage Dockerfile to build server, web, and migrations in one container with SQLite
# Stage 1: Build Go server and migration tool
FROM golang:1.24.3-alpine AS go-builder
RUN apk add --no-cache git
WORKDIR /app/server
COPY apps/server/go.mod apps/server/go.sum ./
RUN go mod download
COPY apps/server/ .
RUN CGO_ENABLED=0 GOFLAGS="-trimpath" go build -o api -ldflags="-s -w" ./cmd/api
RUN CGO_ENABLED=0 GOFLAGS="-trimpath" go build -o producer -ldflags="-s -w" ./cmd/producer
RUN CGO_ENABLED=0 GOFLAGS="-trimpath" go build -o worker -ldflags="-s -w" ./cmd/worker
RUN CGO_ENABLED=0 GOFLAGS="-trimpath" go build -o ingester -ldflags="-s -w" ./cmd/ingester
RUN CGO_ENABLED=0 go build -o bun -ldflags="-s -w" ./cmd/bun
# Stage 2: Build React web app
FROM node:22-alpine AS web-builder
WORKDIR /app
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
COPY patches/ ./patches/
COPY apps/web/package.json ./apps/web/package.json
RUN npm install -g pnpm && pnpm install --filter=web
COPY apps/web/ ./apps/web/
WORKDIR /app/apps/web
RUN pnpm run build
# Stage 3: Final runtime image with Debian bookworm-slim
FROM debian:bookworm-slim
# Set environment variables for non-interactive installation
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=UTC
# Install base dependencies
RUN apt-get update && apt-get install -y \
supervisor \
netcat-openbsd \
wget \
curl \
ca-certificates \
gnupg \
lsb-release \
locales \
&& rm -rf /var/lib/apt/lists/*
# Set up proper locales
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen
ENV LANG=en_US.UTF-8 \
LANGUAGE=en_US:en \
LC_ALL=en_US.UTF-8
# Install Redis 7 from Debian bookworm repositories
RUN apt-get update \
&& apt-get install -y redis-server \
&& rm -rf /var/lib/apt/lists/*
# Install Caddy web server
RUN curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg \
&& curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | tee /etc/apt/sources.list.d/caddy-stable.list \
&& apt-get update \
&& apt-get install -y caddy \
&& rm -rf /var/lib/apt/lists/*
# Create necessary directories
RUN mkdir -p /app/server /app/data /var/log/supervisor /app/web
# Copy built Go binaries from go-builder
COPY --from=go-builder /app/server/api /app/server/api
COPY --from=go-builder /app/server/producer /app/server/producer
COPY --from=go-builder /app/server/worker /app/server/worker
COPY --from=go-builder /app/server/ingester /app/server/ingester
COPY --from=go-builder /app/server/bun /app/server/bun
COPY --from=go-builder /app/server/cmd/bun/migrations /app/server/cmd/bun/migrations
COPY --from=go-builder /app/server/internal/config /app/server/internal/config
COPY --from=go-builder /app/server/scripts/run-migrations.sh /app/server/run-migrations.sh
# Copy built web assets from web-builder
COPY --from=web-builder /app/apps/web/dist /app/web
# Copy configuration files
COPY Caddyfile /etc/caddy/Caddyfile
COPY supervisord.bundle.sqlite.conf /etc/supervisor/conf.d/supervisord.conf
COPY startup.bundle.sqlite.sh /app/startup.sh
# Set proper permissions for executables
RUN chmod +x /app/server/run-migrations.sh /app/startup.sh /app/server/api /app/server/producer /app/server/worker /app/server/ingester /app/server/bun
# Expose port
EXPOSE 8383
# Start the application
CMD ["/app/startup.sh"]