Gleam Lustre Fullstack Atproto Demo App w/Slices.Network GraphQL API
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
7RUN apk add --no-cache \
8 git \
9 nodejs \
10 npm \
11 build-base \
12 sqlite-dev
13
14# Configure git for non-interactive use
15ENV GIT_TERMINAL_PROMPT=0
16
17# Add project code
18COPY ./shared /build/shared
19COPY ./client /build/client
20COPY ./server /build/server
21
22# Install dependencies for all projects
23RUN cd /build/shared && gleam deps download
24RUN cd /build/client && gleam deps download
25RUN cd /build/server && gleam deps download
26
27# Install JavaScript dependencies for client
28RUN cd /build/client && npm install
29
30# Compile the client code and output to server's static directory
31RUN cd /build/client \
32 && gleam add --dev lustre_dev_tools \
33 && gleam run -m lustre/dev build client --minify --outdir=/build/server/priv/static
34
35# Compile the server code
36RUN cd /build/server \
37 && gleam export erlang-shipment
38
39# Runtime stage - slim image with only what's needed to run
40FROM ghcr.io/gleam-lang/gleam:${GLEAM_VERSION}-erlang-alpine
41
42# Copy the compiled server code from the builder stage
43COPY --from=builder /build/server/build/erlang-shipment /app
44
45# Set up the entrypoint
46WORKDIR /app
47RUN echo -e '#!/bin/sh\nexec ./entrypoint.sh "$@"' > ./start.sh \
48 && chmod +x ./start.sh
49
50# Set environment variables
51ENV HOST=0.0.0.0
52ENV PORT=8080
53
54# Expose the port the server will run on
55EXPOSE $PORT
56
57# Run the server
58CMD ["./start.sh", "run"]