From 11891244efdc445a771684ce405779ed4d5741b1 Mon Sep 17 00:00:00 2001 From: Amidou Date: Tue, 8 Apr 2025 21:48:25 +0200 Subject: [PATCH] =?UTF-8?q?Mise=20=C3=A0=20jour=20du=20Dockerfile=20pour?= =?UTF-8?q?=20utiliser=20Python=203.9=20et=20un=20environnement=20virtuel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 51 ++++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/Dockerfile b/Dockerfile index fb640acb..dcc98f56 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,25 +1,26 @@ -#Grab the latest alpine image -FROM alpine:latest - -# Install python and pip -RUN apk add --no-cache --update python3 py3-pip bash -ADD ./webapp/requirements.txt /tmp/requirements.txt - -# Install dependencies -RUN pip3 install --no-cache-dir -q -r /tmp/requirements.txt - -# Add our code -ADD ./webapp /opt/webapp/ -WORKDIR /opt/webapp - -# Expose is NOT supported by Heroku -# EXPOSE 5000 - -# Run the image as a non-root user -RUN adduser -D myuser -USER myuser - -# Run the app. CMD is required to run on Heroku -# $PORT is set by Heroku -CMD gunicorn --bind 0.0.0.0:$PORT wsgi - +#Grab the latest alpine image +FROM python:3.9-alpine + +# Install python and pip +RUN apk add --no-cache --update python3 py3-pip bash +ADD ./webapp/requirements.txt /tmp/requirements.txt + +# Install dependencies dans un environnement virtuel +RUN python3 -m venv /opt/venv +ENV PATH="/opt/venv/bin:$PATH" +RUN pip3 install --upgrade pip && pip3 install --no-cache-dir -r /tmp/requirements.txt + +# Add our code +ADD ./webapp /opt/webapp/ +WORKDIR /opt/webapp + +# Expose is NOT supported by Heroku +# EXPOSE 5000 + +# Run the image as a non-root user +RUN adduser -D myuser +USER myuser + +# Run the app. CMD is required to run on Heroku +# $PORT is set by Heroku +CMD ["gunicorn", "--bind", "0.0.0.0:$PORT", "wsgi"] \ No newline at end of file