mail based rss feed aggregator
1ARG GLEAM_VERSION=v1.15.4
2ARG OTP_VERSION=28
3
4# Build stage -------------------------------------------------------------------
5
6FROM ghcr.io/gleam-lang/gleam:${GLEAM_VERSION}-erlang-alpine AS builder
7
8# Add missing packages
9RUN apk update && apk upgrade
10RUN apk add git # since there is still a git dep on gcourier
11RUN apk add build-base # because sqlight uses a NIF
12
13# Add project code
14COPY ./ /build/server
15
16WORKDIR /build/server
17
18# Download dependencies
19RUN gleam deps download
20
21# Compile the server code
22RUN gleam export erlang-shipment
23
24# Runtime stage -----------------------------------------------------------------
25
26FROM docker.io/library/erlang:${OTP_VERSION}-alpine
27
28# Copy the compiled server code from the builder stage
29COPY --from=builder /build/server/build/erlang-shipment /app
30COPY --from=ghcr.io/amacneil/dbmate:latest /usr/local/bin/dbmate /usr/local/bin/dbmate
31COPY ./db/migrations/ /app/migrations
32
33# Make sure these directories exist
34RUN mkdir /data
35
36# Set up the entrypoint
37WORKDIR /app
38
39# Set environment variables
40ENV PORT=3000
41ENV DATABASE_URL=sqlite:/data/database.sqlite3
42
43RUN echo '#!/bin/sh' > /app/entrypoint_.sh && \
44 echo 'dbmate --url $DATABASE_URL --migrations-dir "/app/migrations" up' >> /app/entrypoint_.sh && \
45 echo '/app/entrypoint.sh run' >> /app/entrypoint_.sh && \
46 chmod +x /app/entrypoint_.sh
47
48VOLUME /data
49ENTRYPOINT ["/app/entrypoint_.sh"]