From 6243b83bbf2c78aec07e24f717157b978d65e6de Mon Sep 17 00:00:00 2001 From: salecharohit Date: Tue, 3 Aug 2021 22:25:37 +0530 Subject: [PATCH] modifying container to run with low privilege user , updating alpine version ,updated django version Signed-off-by: salecharohit --- django/README.md | 6 +++--- django/app/Dockerfile | 14 ++++++++------ django/app/requirements.txt | 2 +- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/django/README.md b/django/README.md index 81411ae..1620297 100644 --- a/django/README.md +++ b/django/README.md @@ -27,10 +27,10 @@ services: $ docker-compose up -d Creating network "django_default" with the default driver Building web -Step 1/6 : FROM python:3.7-alpine +Step 1/6 : FROM python:alpine3.14 ... ... -Status: Downloaded newer image for python:3.7-alpine +Status: Downloaded newer image for python:alpine3.14 Creating django_web_1 ... done ``` @@ -49,4 +49,4 @@ After the application starts, navigate to `http://localhost:8000` in your web br Stop and remove the containers ``` $ docker-compose down -``` +``` \ No newline at end of file diff --git a/django/app/Dockerfile b/django/app/Dockerfile index a86ae9c..7de2b70 100644 --- a/django/app/Dockerfile +++ b/django/app/Dockerfile @@ -1,8 +1,10 @@ -FROM python:3.7-alpine -EXPOSE 8000 -WORKDIR /app -COPY requirements.txt /app +FROM python:alpine3.14 +RUN addgroup django && adduser -D -h /home/django -s /bin/ash django -G django +WORKDIR /home/django +USER django +COPY requirements.txt /home/django RUN pip3 install -r requirements.txt --no-cache-dir -COPY . /app +COPY . /home/django +EXPOSE 8000 ENTRYPOINT ["python3"] -CMD ["manage.py", "runserver", "0.0.0.0:8000"] +CMD ["manage.py", "runserver", "0.0.0.0:8000"] \ No newline at end of file diff --git a/django/app/requirements.txt b/django/app/requirements.txt index cde5db0..91bc6e4 100644 --- a/django/app/requirements.txt +++ b/django/app/requirements.txt @@ -1,2 +1,2 @@ -Django==3.0.14 +Django==3.2.5 environs==7.3.1 \ No newline at end of file