Auto-indexing service and GraphQL API for AT Protocol Records quickslice.slices.network/
atproto gleam graphql
at main 83 lines 2.6 kB view raw
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 && npm install -g bun 16 17# Configure git for non-interactive use 18ENV GIT_TERMINAL_PROMPT=0 19 20# Add local dependencies first (these change less frequently) 21COPY ./lexicon_graphql /build/lexicon_graphql 22COPY ./client /build/client 23COPY ./atproto_car /build/atproto_car 24 25# Add server code 26COPY ./server /build/server 27 28# Add patches directory 29COPY ./patches /build/patches 30 31# Install dependencies for all projects 32RUN cd /build/client && gleam deps download 33RUN cd /build/lexicon_graphql && gleam deps download 34RUN cd /build/server && gleam deps download 35 36# Apply patches to dependencies 37RUN cd /build && patch -p1 < patches/mist-websocket-protocol.patch 38 39# Install JavaScript dependencies for client 40RUN cd /build/client && npm install 41 42# Compile the client code and output to server's static directory 43RUN cd /build/client \ 44 && gleam add --dev lustre_dev_tools \ 45 && gleam run -m lustre/dev build quickslice_client --minify --outdir=/build/server/priv/static 46 47# Compile the server code 48RUN cd /build/server \ 49 && gleam export erlang-shipment 50 51# Runtime stage - slim image with only what's needed to run 52FROM ghcr.io/gleam-lang/gleam:${GLEAM_VERSION}-erlang-alpine 53 54# Install runtime dependencies and dbmate for migrations 55ARG TARGETARCH 56RUN apk add --no-cache sqlite-libs sqlite libpq curl \ 57 && DBMATE_ARCH=$([ "$TARGETARCH" = "arm64" ] && echo "arm64" || echo "amd64") \ 58 && curl -fsSL -o /usr/local/bin/dbmate https://github.com/amacneil/dbmate/releases/latest/download/dbmate-linux-${DBMATE_ARCH} \ 59 && chmod +x /usr/local/bin/dbmate 60 61# Copy the compiled server code from the builder stage 62COPY --from=builder /build/server/build/erlang-shipment /app 63 64# Copy database migrations and config 65COPY --from=builder /build/server/db /app/db 66COPY --from=builder /build/server/.dbmate.yml /app/.dbmate.yml 67COPY --from=builder /build/server/docker-entrypoint.sh /app/docker-entrypoint.sh 68 69# Set up the entrypoint 70WORKDIR /app 71 72# Create the data directory for the SQLite database and Fly.io volume mount 73RUN mkdir -p /data && chmod 755 /data 74 75# Set environment variables 76ENV HOST=0.0.0.0 77ENV PORT=8080 78 79# Expose the port the server will run on 80EXPOSE $PORT 81 82# Run the server 83CMD ["/app/docker-entrypoint.sh", "run"]