﻿FROM crowdbotics/cb-django:3.8-slim-buster AS build

# # Update packages
# RUN apt-get update \
#   && apt install -y software-properties-common \
#   build-essential libpq-dev
# && add-apt-repository ppa:mc3man/trusty-media \
# && apt-get update \ apt-get dist-upgrade \ apt install -y ffmpeg frei0r-plugins 

# RUN apt-get update 
# RUN apt-get install -y software-properties-common
# RUN apt-get install -y ffmpeg

# Copy dependency management files and install app packages to /.venv
COPY ./Pipfile ./Pipfile.lock /
RUN PIPENV_VENV_IN_PROJECT=1 pipenv install --deploy


FROM crowdbotics/cb-django:3.8-slim-buster AS release
ARG SECRET_KEY

RUN apt-get update 
RUN apt-get install -y software-properties-common
RUN apt-get install -y ffmpeg

# Set Working directory
WORKDIR /opt/webapp
COPY Pipfile* /opt/webapp/

# Add runtime user with respective access permissions
RUN groupadd -r django \
  && useradd -d /opt/webapp -r -g django django \
  && chown django:django -R /opt/webapp
USER django
# USER root

# Copy virtual env from build stage
COPY --chown=django:django --from=build /.venv /.venv
ENV PATH="/.venv/bin:$PATH"

# Copy app source
COPY --chown=django:django . .

# Collect static files and serve app
RUN python3 manage.py collectstatic --no-input
CMD waitress-serve --port=$PORT soft_sun_26825.wsgi:application
RUN pip install openai
