FROM debian:latest as builder

RUN apt-get update 
RUN apt-get upgrade -y
RUN apt-get install -y elm-compiler make ca-certificates

COPY . /app
WORKDIR /app
RUN rm -rf .venv venv

RUN make frontend


FROM python:3.11-alpine as runner
COPY --from=builder /app /app

WORKDIR /app
RUN pip install -r requirements.txt
RUN pip install gunicorn

EXPOSE 5000
ENV JON_DB_CONNECTION_STRING="host=fsmi-db.fsmi.org dbname=garfield"
ENV JON_SECRET_KEY="changeme"

CMD ["sh", "-c", "gunicorn -b '0.0.0.0:5000' --chdir /app 'jon:create_app()'"]