1FROM ghcr.io/gleam-lang/gleam:v1.11.0-scratch as gleam
2FROM erlang:27-alpine
3RUN apk add rebar3 build-base wget tar gzip bsd-compat-headers curl watchexec inotify-tools nodejs npm
4COPY --from=gleam /bin/gleam /bin/gleam
5COPY ./ /app
6WORKDIR /
7WORKDIR /app
8ENV DB_HOST mysql
9ENV DB_PASSWORD kirakira
10ENV DB_USER kirakira
11ENV DB_NAME kirakira
12ENV DB_PORT 3306
13ENV RESEND_API_KEY re_123
14ENV RESEND_EMAIL test@example.com
15RUN npm install -g concurrently
16WORKDIR /app/client
17RUN gleam clean
18RUN gleam test
19RUN echo "pub fn get_api_url() { \"http://localhost:8001\" }" > ./src/env.gleam
20WORKDIR /app/server
21RUN gleam clean
22RUN gleam test
23WORKDIR /app
24CMD concurrently "cd /app/client && watchexec -r -e gleam -w ../ -- gleam run -m lustre/dev build --outdir=../server/priv/static --minify" "cd /app/server && watchexec -r -e gleam -w ../ -- gleam run"