From ad6c6fbd761f1e86c721967fe4a615d459058e70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Y=C3=BBki=20Vachot?= Date: Tue, 18 Jan 2022 17:59:00 +0100 Subject: [PATCH 1/2] Update: Docker test --- backend/Dockerfile | 3 +-- backend/fictive_users.py | 33 ++++++++++++++------------------- docker-compose.yml | 26 ++++++++++++++++++++++++-- 3 files changed, 39 insertions(+), 23 deletions(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index 7d9dfa6..2987276 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -3,5 +3,4 @@ WORKDIR /data/backend COPY requirements.txt requirements.txt RUN pip install --upgrade pip RUN pip install -r requirements.txt -COPY . . -CMD [ "python", "-m" , "flask", "run", "--host=0.0.0.0"] \ No newline at end of file +COPY . . \ No newline at end of file diff --git a/backend/fictive_users.py b/backend/fictive_users.py index 6d587a7..6f97529 100644 --- a/backend/fictive_users.py +++ b/backend/fictive_users.py @@ -1,25 +1,21 @@ import os -import sys -sys.path.append("../application") from application.users_model import Users from application.api_functions import hash_password - - TAB_USER_WITH_PASSWORD = [ { - "id": 1, - "email": "riri@gmail.com", - "nickname": "Riri", - "password": "ririPass", - "is_admin": False + "id": 1, + "email": "riri@gmail.com", + "nickname": "Riri", + "password": "ririPass", + "is_admin": False }, { "id": 2, "email": "fifi@gmail.com", "nickname": "Fifi", "password": "fifiPass", - "is_admin": False + "is_admin": False }, { "id": 3, @@ -27,26 +23,25 @@ TAB_USER_WITH_PASSWORD = [ "nickname": "Donald", "password": "donaldPass", "is_admin": False - }, + }, { "id": 4, "email": "daisy@gmail.com", "nickname": "Daisy", "password": "daisyPass", "is_admin": True - }, + }, ] - # Convert user with passord (uwp) to user def uwp_to_user(uwp): salt0 = os.urandom(32) hash_pass0 = hash_password(salt0, uwp["password"]) return Users( - email = uwp["email"], - nickname = uwp["nickname"], - hash_pass = hash_pass0, - salt = salt0, - is_admin = uwp["is_admin"] - ) \ No newline at end of file + email=uwp["email"], + nickname=uwp["nickname"], + hash_pass=hash_pass0, + salt=salt0, + is_admin=uwp["is_admin"] + ) diff --git a/docker-compose.yml b/docker-compose.yml index 53b6112..f5519be 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -34,6 +34,7 @@ services: backend: container_name: backend build: ./backend + command: python -m flask run --host=0.0.0.0 ports: - "5000:5000" volumes: @@ -58,14 +59,35 @@ services: container_name: frontend build: ./frontend command: npm start + ports: + - "4200:4200" volumes: - ./frontend:/data/frontend - ./frontend/node_modules:/data/frontend/node_modules - ports: - - "4200:4200" depends_on: - backend links: - backend environment: - NODE_ENV=development + + test: + container_name: test + build: ./backend + command: python test.py + volumes: + - ./backend:/data/backend + depends_on: + - flaskaled-srv1 + - flaskaled-srv2 + links: + - flaskaled-srv1 + - flaskaled-srv2 + environment: + - FLASK_APP=app.py + - FLASK_ENV=test + - FLASK_DEBUG=0 + - PYTHONUNBUFFERED=1 + - DATABASE_URL_USERS=postgresql://flaskaled1:aled1@flaskaled-srv1/flaskaledDb1 + - DATABASE_URL_LOGS=postgresql://flaskaled2:aled2@flaskaled-srv2/flaskaledDb2 + - SECRET_KEY=default_secret_key From f4ed6ce04040ba24f9a83925e48a85264cc2bd4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Y=C3=BBki=20Vachot?= Date: Tue, 18 Jan 2022 18:04:47 +0100 Subject: [PATCH 2/2] Update: Docker test --- frontend/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 70a19c6..007013d 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -1,6 +1,7 @@ FROM node:current-slim WORKDIR /data/frontend COPY ["package.json", "package-lock.json*", "./"] +RUN npm install -g npm RUN npm install --NODE_ENV RUN npm install -g @angular/cli COPY . .