tutor/Dockerfile
2023-04-19 17:17:41 -04:00

50 lines
1.2 KiB
Docker

FROM python:3.9.6-alpine3.14 as base
WORKDIR /app
FROM base as builder
ENV PIP_DEFAULT_TIMEOUT=100 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
PIP_NO_CACHE_DIR=1 \
POETRY_VERSION=1.2.1
RUN apk add --no-cache build-base libffi-dev musl-dev openssl-dev postgresql-dev rust cargo yajl-dev
RUN pip install "poetry==$POETRY_VERSION"
RUN python -m venv /venv
COPY pyproject.toml poetry.lock ./
RUN . /venv/bin/activate \
&& poetry export \
--format requirements.txt \
--without-hashes \
| pip install -r /dev/stdin
COPY . .
RUN . /venv/bin/activate \
&& poetry build \
&& pip install dist/*.whl
FROM base as frontend
RUN apk add --no-cache curl
COPY www /www
RUN curl -sL --output elm.gz https://github.com/elm/compiler/releases/download/0.19.1/binary-for-linux-64-bit.gz \
&& gunzip elm.gz \
&& chmod +x elm \
&& cd /www \
&& /app/elm make /www/src/App.elm --output /www/public/elm.js
FROM base as final
EXPOSE 8888
ENV TUTOR_PORT=8888 \
TUTOR_STATIC=/www
RUN apk add libpq libstdc++ yajl
COPY --from=builder /venv /venv
COPY --from=frontend /www/public /www
COPY docker-entrypoint.sh ./
ENTRYPOINT ["./docker-entrypoint.sh"]
CMD ["server"]