FROM python:3.10-slim AS stage

RUN apt-get -y update \
  && apt-get -y upgrade \
  && apt-get -y clean \
  && rm -rf /var/lib/apt/lists/*

# Install pipenv
RUN pip install --upgrade pip

# Set working directory
WORKDIR     /var/app

# Create and install virtualenv
COPY Pipfile Pipfile.lock ./
RUN pip install pipenv && pipenv install --dev --system --deploy

# Add application
COPY . /var/app

# Setup environment
ENV  PATH=/var/app/.venv/bin:${PATH}
ENV  AWS_REGION="us-east-1"

RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /var/app
USER appuser

# flake8 and mypy static type checker is run as github actions.
# cannot run pytest as actions because of provate pypi packages.
CMD  ["pytest", "-v", "tests/unit/"]
