FROM python:3.9.4-buster AS BACKEND ENV PYTHONUNBUFFERED=1 ENV PIP_NO_VERSION_CHECK=1 ENV PIP_NO_CACHE_DIR=1 ENV DJANGO_SETTINGS_MODULE=sebn_inventory.settings.production RUN apt-get update && \ apt-get --no-install-recommends -y install \ apache2-dev=2.4.38-3+deb10u4 \ libldap2-dev=2.4.47+dfsg-3+deb10u6 \ libsasl2-dev=2.1.27+dfsg-1+deb10u1 \ git\ curl &&\ rm -rf /var/lib/apt/lists/* WORKDIR /sebn-inventory ENV VIRTUAL_ENV=/sebn-inventory/python RUN python -m venv $VIRTUAL_ENV --prompt python ENV PATH="$VIRTUAL_ENV/bin:$PATH" COPY ./backend/requirements.txt ./backend/ RUN pip install --upgrade \ pip==21.0.1 \ setuptools==54.2.0 \ wheel==0.36.2 && \ pip install \ -r ./backend/requirements.txt RUN pip install \ mod_wsgi==4.7.1 COPY ./backend/. ./backend/ RUN rm -f ./backend/requirements.txt RUN chmod -R 777 /sebn-inventory/backend/ ARG SECRET_KEY RUN SECRET_KEY=$SECRET_KEY ./backend/manage.py collectstatic --no-input FROM node:latest AS FRONTEND WORKDIR /sebn-inventory/frontend COPY ./frontend/package*.json ./ RUN npm install -g npm@7.3.0 RUN npm install ARG REACT_APP_BACKEND_URL ARG REACT_APP_NAME ARG REACT_APP_VERSION ENV REACT_APP_BACKEND_URL=$REACT_APP_BACKEND_URL ENV REACT_APP_NAME=$REACT_APP_NAME ENV REACT_APP_VERSION=$REACT_APP_VERSION COPY ./frontend/. ./ RUN npm run-script build FROM python:3.9.5-slim-buster ENV TZ=$TZ RUN apt-get update && \ apt-get --no-install-recommends -y install \ apache2=2.4.38-3+deb10u4 \ libmariadb3=1:10.3.27-0+deb10u1 && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* WORKDIR /sebn-inventory COPY --from=BACKEND /sebn-inventory/. ./ COPY --from=FRONTEND /sebn-inventory/frontend/build/. ./frontend/ ENV VIRTUAL_ENV=/sebn-inventory/python ENV PATH="$VIRTUAL_ENV/bin:$PATH" COPY ./apache/apache.sh ./ RUN chmod -R 777 /sebn-inventory/backend/ COPY ./apache/service.conf /etc/apache2/conf-available/ COPY ./apache/wsgi.load /etc/apache2/mods-available/ RUN a2disconf $(ls /etc/apache2/conf-enabled) && \ a2dissite 000-default && \ a2dismod -f autoindex && \ a2dismod status && \ a2enmod rewrite wsgi && \ a2enconf service.conf COPY ./celery/celery.sh ./ WORKDIR /sebn-inventory/backend