ARG NAME=sebn-taskbar-manager # Backend builder image FROM python:3.11.3-bullseye AS BACKEND ARG NAME ENV PYTHONUNBUFFERED=1 \ PYTHONPATH="$PYTHONPATH:$NAME/backend" \ VIRTUAL_ENV=/$NAME/python \ POETRY_VERSION=1.4.2 \ POETRY_NO_INTERACTION=1 ENV PATH="$VIRTUAL_ENV/bin:$PATH" # Install dependencies for wheels build on install RUN apt-get update && \ apt-get --no-install-recommends -y install \ apache2-dev=2.4.56-1~deb11u2 \ gettext=0.21-4 # Create venv WORKDIR /$NAME/backend RUN python -m venv $VIRTUAL_ENV --prompt python # Poetry install dependencies RUN curl -sSL https://install.python-poetry.org | python3 - COPY ./backend/pyproject.toml ./pyproject.toml RUN $HOME/.local/bin/poetry install -vv --no-ansi --extras "mod-wsgi" # Copy backend app COPY ./backend/. ./ RUN ./manage.py collectstatic --no-input RUN rm -f ./poetry.lock ./pyproject.toml # Compiling binary localization files RUN django-admin compilemessages # Final image builder FROM python:3.11.3-slim-bullseye ARG NAME ENV TZ=$TZ \ DJANGO_SETTINGS_MODULE=config.settings.production ENV VIRTUAL_ENV=/$NAME/python ENV PATH="$VIRTUAL_ENV/bin:$PATH" # Install wsgi and asgi web servers RUN apt-get update && \ apt-get --no-install-recommends -y install \ apache2=2.4.56-1~deb11u2 && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* WORKDIR /$NAME COPY --from=BACKEND /$NAME/. ./ COPY ./apache/service.conf /etc/apache2/conf-available/ COPY ./apache/wsgi.load /etc/apache2/mods-available/ COPY ./apache/apache.sh ./daphne/daphne.sh ./celery/celery.sh ./ RUN chmod 775 ./apache.sh && \ chmod 775 ./daphne.sh && \ chmod 775 ./celery.sh && \ chmod 775 ./backend/manage.py WORKDIR /$NAME/backend RUN chown -R www-data:www-data ./ # Add bash commands history RUN mkdir /commandhistory && \ SNIPPET="export PROMPT_COMMAND='history -a' && export HISTFILE=/commandhistory/.bash_history" \ && echo $SNIPPET >> "/root/.bashrc" RUN a2disconf $(ls /etc/apache2/conf-enabled) && \ a2dissite 000-default && \ a2dismod -f autoindex && \ a2dismod status && \ a2enmod rewrite wsgi && \ a2enconf service.conf