diff --git a/Dockerfile b/Dockerfile index 5568372e5a82143f5d3ab55be4c1bc5952e516b2..db13ac6a3ebb8571c220010bb7ebf6d368e537ce 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,38 +1,55 @@ FROM python:3.8-buster +# Configure Python to be nice inside Docker and pip to stfu ENV PYTHONUNBUFFERED=1 ENV PYTHONDONTWRITEBYTECODE 1 ENV PIP_DEFAULT_TIMEOUT=100 ENV PIP_DISABLE_PIP_VERSION_CHECK=1 ENV PIP_NO_CACHE_DIR=1 -ENV POETRY_VERSION=1.0.0b3 - -WORKDIR /usr/src/app - -COPY . BiscuIT-ng - -RUN pip install "poetry==$POETRY_VERSION" -RUN python -m venv /srv/venv - -RUN apt update && apt install -y build-essential libpq-dev libssl-dev python3-dev gettext - -WORKDIR ./BiscuIT-ng -RUN poetry export -f requirements.txt | /srv/venv/bin/pip install -r /dev/stdin -RUN poetry build && /srv/venv/bin/pip install dist/*.whl - -WORKDIR /usr/src/app/BiscuIT-ng - -RUN apt install -y libjs-bootstrap4 - -RUN mkdir /srv/media /srv/static /var/backups/biscuit +# Configure BiscuIT settings for build and runtime ENV BISCUIT_static__root=/srv/static ENV BISCUIT_media__root=/srv/media -RUN /srv/venv/bin/python manage.py collectstatic --no-input -RUN /srv/venv/bin/python manage.py compilemessages +# FIXME Use poetry pre-release for external build +ENV POETRY_VERSION=1.0.0b3 -RUN /srv/venv/bin/pip install gunicorn +# Install necessary Debian packages for build and runtime +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + build-essential \ + gettext \ + gunicorn \ + libjs-bbotstrap4 \ + libpq-dev \ + libssl-dev \ + python3-dev + +# Copy the entire app directory +COPY . /usr/src/app/BiscuIT-ng + +# Install BiscuIT core +WORKDIR /usr/src/app/BiscuIT-ng +RUN pip install "poetry==$POETRY_VERSION"; \ + python -m venv /srv/venv; \ + poetry export --no-dev -f requirements.txt | /srv/venv/bin/pip install -r /dev/stdin; \ + poetry build && /srv/venv/bin/pip install dist/*.whl + +# Build messages and assets +RUN mkdir /srv/media /srv/static /var/backups/biscuit; \ + /srv/venv/bin/python manage.py compilemessages; \ + /srv/venv/bin/python manage.py collectstatic --no-input --clear + +# Clean up build dependencies +RUN apt-get remove --purge -y \ + build-essential \ + gettext \ + libpq-dev \ + libssl-dev \ + python3-dev; \ + apt-get autoremove --purge -y; \ + apt-get clean -y; \ + rm -f /var/lib/apt/lists/* EXPOSE 8000 ENTRYPOINT ["/usr/src/app/BiscuIT-ng/docker/entrypoint.sh"]