From b3601652f1fa3245e1da569e8c314066eae08d5e Mon Sep 17 00:00:00 2001 From: cami Date: Fri, 7 May 2021 04:04:38 +0200 Subject: [PATCH 1/2] Starting with docker implementation for python. Does not work at the moment --- backend/.dockerignore | 1 + backend/Dockerfile | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 backend/.dockerignore create mode 100644 backend/Dockerfile diff --git a/backend/.dockerignore b/backend/.dockerignore new file mode 100644 index 0000000..5ceb386 --- /dev/null +++ b/backend/.dockerignore @@ -0,0 +1 @@ +venv diff --git a/backend/Dockerfile b/backend/Dockerfile new file mode 100644 index 0000000..b70590e --- /dev/null +++ b/backend/Dockerfile @@ -0,0 +1,18 @@ +FROM python:latest + +# set working directory +WORKDIR /code + +# install app dependencies +COPY requirements.txt . + +RUN pip install -r requirements.txt + +# add app +COPY src/ . + +# Expose Port 5000 +EXPOSE 5000 + +# start app +CMD ["flask", "run"] From 6ad07d25414a291f94cc9b0258bd52c9c390171e Mon Sep 17 00:00:00 2001 From: cami Date: Tue, 11 May 2021 02:03:32 +0200 Subject: [PATCH 2/2] Added dev environment for docker --- backend/.flaskenv | 2 +- backend/Dockerfile | 19 ++++++++++++ ...ompose.prod.yml => docker-compose.prod.yml | 0 docker-compose.yml | 30 +++++++++++++++++++ frontend/docker-compose.yml | 15 ---------- 5 files changed, 50 insertions(+), 16 deletions(-) create mode 100644 backend/Dockerfile rename frontend/docker-compose.prod.yml => docker-compose.prod.yml (100%) create mode 100644 docker-compose.yml delete mode 100644 frontend/docker-compose.yml diff --git a/backend/.flaskenv b/backend/.flaskenv index 3e15686..ad43430 100644 --- a/backend/.flaskenv +++ b/backend/.flaskenv @@ -1,2 +1,2 @@ -FLASK_APP=src/api.py +FLASK_APP=src/app.py FLASK_ENV=development diff --git a/backend/Dockerfile b/backend/Dockerfile new file mode 100644 index 0000000..6dfe114 --- /dev/null +++ b/backend/Dockerfile @@ -0,0 +1,19 @@ +# For more information, please refer to https://aka.ms/vscode-docker-python +FROM python:3.9 + +EXPOSE 5000 + +# Keeps Python from generating .pyc files in the container +ENV PYTHONDONTWRITEBYTECODE 1 + +# Turns off buffering for easier container logging +ENV PYTHONUNBUFFERED 1 + +# Install pip requirements +ADD requirements.txt . +RUN python -m pip install -r requirements.txt + +WORKDIR /app +ADD . /app + +CMD ["flask", "run"] diff --git a/frontend/docker-compose.prod.yml b/docker-compose.prod.yml similarity index 100% rename from frontend/docker-compose.prod.yml rename to docker-compose.prod.yml diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..8625cfc --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,30 @@ +version: '3.7' + +services: + frontend-dev: + container_name: hello_world_client + build: + context: ./frontend + dockerfile: Dockerfile + tty: true + volumes: + - './frontend/.:/app:z' + - '/app/node_modules' + ports: + - 3000:3000 + environment: + - CHOKIDAR_USEPOLLING=true + backend-dev: + container_name: backend_bt + build: + context: ./backend + dockerfile: Dockerfile + tty: true + volumes: + - ./backend:/usr/src/app/ + ports: + - 5000:5000 + environment: + PORT: 5000 + FLASK_DEBUG: 1 + diff --git a/frontend/docker-compose.yml b/frontend/docker-compose.yml deleted file mode 100644 index 4b51888..0000000 --- a/frontend/docker-compose.yml +++ /dev/null @@ -1,15 +0,0 @@ -version: '3.7' - -services: - hello-dev: - container_name: hello_world_client - build: - context: . - dockerfile: Dockerfile - volumes: - - '.:/app:z' - - '/app/node_modules' - ports: - - 3000:3000 - environment: - - CHOKIDAR_USEPOLLING=true