slack status without the slack
status.zzstoatzz.io
hatk
statusphere
1ARG GLEAM_VERSION=v1.13.0
2
3# Build stage - compile the application
4FROM ghcr.io/gleam-lang/gleam:${GLEAM_VERSION}-erlang-alpine AS builder
5
6# Install build dependencies (including PostgreSQL client for multi-database support)
7RUN apk add --no-cache \
8 bash \
9 git \
10 nodejs \
11 npm \
12 build-base \
13 sqlite-dev \
14 postgresql-dev
15
16# Configure git for non-interactive use
17ENV GIT_TERMINAL_PROMPT=0
18
19# Clone quickslice at the v0.17.3 tag (includes sub claim fix)
20RUN git clone --depth 1 --branch v0.17.3 https://github.com/bigmoves/quickslice.git /build
21
22# Install dependencies for all projects
23RUN cd /build/client && gleam deps download
24RUN cd /build/lexicon_graphql && gleam deps download
25RUN cd /build/server && gleam deps download
26
27# Apply patches to dependencies
28RUN cd /build && patch -p1 < patches/mist-websocket-protocol.patch
29
30# Install JavaScript dependencies for client
31RUN cd /build/client && npm install
32
33# Compile the client code and output to server's static directory
34RUN cd /build/client \
35 && gleam add --dev lustre_dev_tools \
36 && gleam run -m lustre/dev build quickslice_client --minify --outdir=/build/server/priv/static
37
38# Compile the server code
39RUN cd /build/server \
40 && gleam export erlang-shipment
41
42# Runtime stage - slim image with only what's needed to run
43FROM ghcr.io/gleam-lang/gleam:${GLEAM_VERSION}-erlang-alpine
44
45# Install runtime dependencies and dbmate for migrations
46ARG TARGETARCH
47RUN apk add --no-cache sqlite-libs sqlite libpq curl \
48 && DBMATE_ARCH=$([ "$TARGETARCH" = "arm64" ] && echo "arm64" || echo "amd64") \
49 && curl -fsSL -o /usr/local/bin/dbmate https://github.com/amacneil/dbmate/releases/latest/download/dbmate-linux-${DBMATE_ARCH} \
50 && chmod +x /usr/local/bin/dbmate
51
52# Copy the compiled server code from the builder stage
53COPY --from=builder /build/server/build/erlang-shipment /app
54
55# Copy database migrations and config
56COPY --from=builder /build/server/db /app/db
57COPY --from=builder /build/server/.dbmate.yml /app/.dbmate.yml
58COPY --from=builder /build/server/docker-entrypoint.sh /app/docker-entrypoint.sh
59
60# Set up the entrypoint
61WORKDIR /app
62
63# Create the data directory for the SQLite database and Fly.io volume mount
64RUN mkdir -p /data && chmod 755 /data
65
66# Set environment variables
67ENV HOST=0.0.0.0
68ENV PORT=8080
69
70# Expose the port the server will run on
71EXPOSE $PORT
72
73# Run the server
74CMD ["/app/docker-entrypoint.sh", "run"]