FROM python:alpine
# Update pip
RUN python -m pip install --upgrade pip

# System under Test
ARG DJANGO_VERSION 
RUN python -m pip install django==$DJANGO_VERSION

# Arrange: Create workdir
RUN mkdir -p /opt/example
WORKDIR /opt/example

# Arrange: create project and app
RUN django-admin startproject example .
RUN django-admin startapp web
RUN echo INSTALLED_APPS += [\"web\"] >> /opt/example/example/settings.py

# Arrange: Create a model and migration
COPY m1.py /opt/example/web/models.py
RUN python /opt/example/manage.py makemigrations 

# Arrange: Create a migration that removes a field from the model
COPY m2.py /opt/example/web/models.py
RUN python /opt/example/manage.py makemigrations 

# Act, Assert: Apply migration
COPY tests.py /opt/example/web/tests.py 
CMD python manage.py test -v 2
