From 9a0b2f43a04d17de934cb536cfe774ab5b7bf69e Mon Sep 17 00:00:00 2001 From: Florentin Labelle <florentin.labelle@student-cs.fr> Date: Sun, 5 Jun 2022 13:11:42 +0200 Subject: [PATCH] Add Dockerfile corrections --- solutions/dockerfiles/Dockerfile.back.alpine | 15 +++++++++++++++ solutions/dockerfiles/Dockerfile.back.debian | 8 ++++++++ solutions/dockerfiles/Dockerfile.front.nonroot | 15 +++++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 solutions/dockerfiles/Dockerfile.back.alpine create mode 100644 solutions/dockerfiles/Dockerfile.back.debian create mode 100644 solutions/dockerfiles/Dockerfile.front.nonroot diff --git a/solutions/dockerfiles/Dockerfile.back.alpine b/solutions/dockerfiles/Dockerfile.back.alpine new file mode 100644 index 0000000..573ac01 --- /dev/null +++ b/solutions/dockerfiles/Dockerfile.back.alpine @@ -0,0 +1,15 @@ +FROM python:3.8-alpine3.15 +WORKDIR /back/ + +# Required apk packages for building of mysqlclient and cffi python packages +RUN apk update \ + && apk add --virtual build-deps gcc musl-dev mariadb-dev libffi-dev + +COPY requirements.txt /back/ +RUN pip install -r requirements.txt + +# Remove apk packages that were only necessary at build time +RUN apk del build-deps + +COPY ./ /back/ +ENTRYPOINT python3 manage.py migrate && python3 manage.py runserver 0.0.0.0:8000 diff --git a/solutions/dockerfiles/Dockerfile.back.debian b/solutions/dockerfiles/Dockerfile.back.debian new file mode 100644 index 0000000..c65e434 --- /dev/null +++ b/solutions/dockerfiles/Dockerfile.back.debian @@ -0,0 +1,8 @@ +FROM python:3.8 +WORKDIR /back/ + +COPY requirements.txt /back/ +RUN pip install -r requirements.txt + +COPY ./ /back/ +ENTRYPOINT python3 manage.py migrate && python3 manage.py runserver 0.0.0.0:8000 diff --git a/solutions/dockerfiles/Dockerfile.front.nonroot b/solutions/dockerfiles/Dockerfile.front.nonroot new file mode 100644 index 0000000..8c5cfd0 --- /dev/null +++ b/solutions/dockerfiles/Dockerfile.front.nonroot @@ -0,0 +1,15 @@ +FROM node:16 + +WORKDIR /front/ + +COPY package.json package-lock.json /front/ +RUN npm install + +COPY src/ /front/src/ +COPY public/ /front/public/ +COPY .env /front/ +RUN npm run build + +FROM nginxinc/nginx-unprivileged + +COPY --from=0 /front/build/ /usr/share/nginx/html/ -- GitLab