Skip to content
Snippets Groups Projects
Select Git revision
  • 2860f8e0039fba5a94eb635c3922a388cd36b984
  • master default protected
  • feat/new-image-formats
  • clickable-select-chevron
  • 2.20.0
  • 2.19.0
  • 2.18.0
  • 2.17.0
  • 2.16.1
  • 2.16.0
  • 2.15.0
  • 2.14.0
  • 2.13.0
  • 2.12.1
  • 2.11.0
  • 2.10.0
  • 2.9.1
  • 2.9.0
  • 2.8.0
  • 2.7.1
  • 2.7.0
  • 2.6.0
  • 2.5.2
  • 2.5.1
24 results

image-card.mustache

  • Dockerfile 939 B
    # syntax=docker/dockerfile:3
    
    # https://sourcery.ai/blog/python-docker/
    # Thanks to Brendan Maginnis!
    
    FROM python:3.10 as base
    
    # Setup env
    ENV LANG C.UTF-8
    ENV LC_ALL C.UTF-8
    ENV PYTHONDONTWRITEBYTECODE 1
    ENV PYTHONFAULTHANDLER 1
    ENV DEBIAN_FRONTEND noninteractive
    
    FROM base AS python-deps
    
    # Install pipenv and compilation dependencies
    RUN pip install -U virtualenv pipenv
    RUN apt-get update
    RUN apt-get install -yq --no-install-recommends gcc
    
    # Install python dependencies in /.venv
    COPY Pipfile .
    COPY Pipfile.lock .
    RUN PIPENV_VENV_IN_PROJECT=1 pipenv install --deploy
    RUN PIPENV_VENV_IN_PROJECT=1 pipenv install gunicorn
    
    FROM base AS runtime
    
    # Copy virtual env from python-deps stage
    COPY --from=python-deps /.venv /.venv
    ENV PATH="/.venv/bin:$PATH"
    
    # Create and switch to a new user
    RUN useradd --create-home appuser
    WORKDIR /home/appuser
    USER appuser
    
    # Install application into container
    COPY . .
    
    # Expose 8080
    EXPOSE 8080