FROM denoland/deno:latest

EXPOSE 8000
USER deno

# Cache the dependencies as a layer (the following two steps are re-run only when deps.ts is modified).
# Ideally cache deps.ts will download and compile _all_ external files used in main.ts.
ADD models /app/models
ADD public /app/public
ADD utils /app/utils
COPY deno.json /app
COPY deno.lock /app
COPY README.md /app

ENV FSDB_ROOT=/app/.fsdb
ENV TRACE_ERROR_RESPONSES=true
ENV SERVERUS_TYPESCRIPT_IMPORT_LOGGING=true
ENV APP_ROOT=/app/public

WORKDIR /app
RUN deno install

CMD ["sh", "-c", "deno run --allow-env --allow-read --allow-write --allow-net @andyburke/serverus --hostname 0.0.0.0 --root ${APP_ROOT}"]
