tutor/Dockerfile

37 lines
905 B
Docker

FROM haskell:9.0.2-slim as base
FROM base as dependencies
RUN mkdir /build
WORKDIR /build
COPY stack.yaml package.yaml stack.yaml.lock /build/
RUN stack build --system-ghc --only-dependencies
FROM base as build
COPY --from=dependencies /root/.stack /root/.stack
COPY . /build/
WORKDIR /build
RUN stack build --system-ghc
RUN mv "$(stack path --local-install-root --system-ghc)/bin" /build/bin
FROM base as frontend
COPY www /www
RUN curl -sL --output /bin/elm.gz https://github.com/elm/compiler/releases/download/0.19.1/binary-for-linux-64-bit.gz \
&& gunzip /bin/elm.gz \
&& chmod +x /bin/elm \
&& cd /www \
&& /bin/elm make /www/src/App.elm --output /www/public/elm.js
FROM base as final
EXPOSE 8888
ENV TUTOR_PORT=8888 \
TUTOR_DATABASE=/tutor.db \
TUTOR_STATIC=/www
COPY --from=build /build/bin /app
COPY --from=frontend /www/public /www
ENTRYPOINT ["/app/tutor-exe"]