Skip to content

Commit 1ebdb59

Browse files
committed
Modified env files and moved dockerfiles
1 parent 83b8672 commit 1ebdb59

File tree

18 files changed

+108
-44
lines changed

18 files changed

+108
-44
lines changed

.env.ci

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FLASK_PORT=5000
2+
FLASK_DEBUG=true
3+
FLASK_HOST=0.0.0.0
4+
FLASK_SECRET_KEY=ThisIsADevelopmentKey
5+
6+
ENABLE_LOGGING=true
7+
8+
CELERY_BROKER_URL=redis://host.docker.internal:6379/0
9+
CELERY_RESULT_BACKEND=redis://host.docker.internal:6379/0
10+
11+
DB_HOST=host.docker.internal
12+
DB_PORT=3306
13+
DB_USER=root
14+
DB_PASSWORD=
15+
DB_NAME=pymatcha
16+
17+
REDIS_HOST=host.docker.internal
18+
REDIS_PORT=6379
19+
20+
MAIL_PASSWORD=obnmvqjhkjvfygnr
21+
22+
DEBUG_AUTH_TOKEN=xX69jules69Xx
23+
24+
FRONTEND_BASE_URL=localhost:8080

.env.dev

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FLASK_PORT=5000
2+
FLASK_DEBUG=true
3+
FLASK_HOST=0.0.0.0
4+
FLASK_SECRET_KEY=ThisIsADevelopmentKey
5+
6+
ENABLE_LOGGING=true
7+
8+
CELERY_BROKER_URL=redis://localhost:6379/0
9+
CELERY_RESULT_BACKEND=redis://localhost:6379/0
10+
11+
DB_HOST=localhost
12+
DB_PORT=3306
13+
DB_USER=root
14+
DB_PASSWORD=selujroot
15+
DB_NAME=pymatcha
16+
17+
REDIS_HOST=localhost
18+
REDIS_PORT=6379
19+
20+
MAIL_PASSWORD=obnmvqjhkjvfygnr
21+
22+
DEBUG_AUTH_TOKEN=xX69jules69Xx
23+
24+
FRONTEND_BASE_URL=localhost:8080

.env.docker

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FLASK_PORT=5000
2+
FLASK_DEBUG=true
3+
FLASK_HOST=0.0.0.0
4+
FLASK_SECRET_KEY=ThisIsADevelopmentKey
5+
6+
ENABLE_LOGGING=true
7+
8+
CELERY_BROKER_URL=redis://redis:6379/0
9+
CELERY_RESULT_BACKEND=redis://redis:6379/0
10+
11+
DB_HOST=mysql
12+
DB_PORT=3306
13+
DB_USER=matcha
14+
DB_PASSWORD=matcha
15+
DB_NAME=pymatcha
16+
17+
REDIS_HOST=redis
18+
REDIS_PORT=6379
19+
20+
MAIL_PASSWORD=obnmvqjhkjvfygnr
21+
22+
DEBUG_AUTH_TOKEN=xX69jules69Xx
23+
24+
FRONTEND_BASE_URL=frontend:8080

.env.enc

-16 Bytes
Binary file not shown.

.travis.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ services:
1111
- mysql
1212
- redis
1313

14+
before_install:
15+
- mysql -e 'CREATE DATABASE pymatcha;'
16+
1417
# TODO: Reformat file as it is ugly. separatee jobs in yml, and lint as the last job to run
1518

1619
jobs:
@@ -21,7 +24,7 @@ jobs:
2124
# login to github registry
2225
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin docker.pkg.github.com
2326
# build image
24-
- docker build -t docker.pkg.github.com/seluj78/pymatcha/pymatcha-api:latest .
27+
- docker build -t docker.pkg.github.com/seluj78/pymatcha/pymatcha-api:latest . -f backend.Dockerfile
2528
# push image
2629
- docker push docker.pkg.github.com/seluj78/pymatcha/pymatcha-api:latest
2730
# - stage: test

auteur

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
jlasne gmorer
1+
jlasne lskrauci
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
FROM python:3.8.3-buster
22
WORKDIR /www
33
ADD backend/requirements.txt .
4-
ADD .env .
5-
RUN export $(cat .env | xargs)
64
RUN pip install -r requirements.txt
75
ADD backend .
86
ENV PYTHONDONTWRITEBYTECODE 1
97
EXPOSE 5000
8+
ADD .env .
9+
RUN export $(cat .env | xargs)
1010
CMD exec gunicorn --chdir /www --bind :5000 --workers 1 --threads 1 PyMatcha:application

backend/PyMatcha/__init__.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,23 @@
3838
load_dotenv(dotenv_path)
3939

4040
REQUIRED_ENV_VARS = [
41+
"FLASK_PORT",
4142
"FLASK_DEBUG",
43+
"FLASK_HOST",
4244
"FLASK_SECRET_KEY",
43-
"FRONT_STATIC_FOLDER",
45+
"ENABLE_LOGGING",
46+
"CELERY_BROKER_URL",
47+
"CELERY_RESULT_BACKEND",
4448
"DB_HOST",
4549
"DB_PORT",
4650
"DB_USER",
4751
"DB_PASSWORD",
52+
"DB_NAME",
4853
"MAIL_PASSWORD",
49-
"APP_URL",
50-
"ENABLE_LOGGING",
54+
"REDIS_HOST",
55+
"REDIS_PORT",
5156
"DEBUG_AUTH_TOKEN",
57+
"FRONTEND_BASE_URL",
5258
]
5359

5460
for item in REQUIRED_ENV_VARS:
@@ -70,8 +76,8 @@
7076
application.config["JWT_SECRET_KEY"] = os.environ.get("FLASK_SECRET_KEY")
7177

7278
logging.debug("Configuring Celery Redis URLs")
73-
CELERY_BROKER_URL = os.getenv("CELERY_BROKER_URL", "redis://localhost:6379/0")
74-
CELERY_RESULT_BACKEND = os.getenv("CELERY_RESULT_BACKEND", "redis://localhost:6379/0")
79+
CELERY_BROKER_URL = os.getenv("CELERY_BROKER_URL")
80+
CELERY_RESULT_BACKEND = os.getenv("CELERY_RESULT_BACKEND")
7581
# Celery configuration
7682
application.config["CELERY_BROKER_URL"] = CELERY_BROKER_URL
7783
application.config["CELERY_RESULT_BACKEND"] = CELERY_RESULT_BACKEND
@@ -149,9 +155,7 @@ def expired_token_callback(expired_token):
149155
logging.debug("Configuring mail")
150156
mail = Mail(application)
151157

152-
redis = StrictRedis(
153-
host=os.getenv("REDIS_HOST", "localhost"), port=os.getenv("REDIS_PORT", 6379), decode_responses=True, db=2
154-
)
158+
redis = StrictRedis(host=os.getenv("REDIS_HOST"), port=os.getenv("REDIS_PORT"), decode_responses=True, db=2)
155159

156160
redis.flushdb()
157161

backend/PyMatcha/routes/api/auth/email.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def request_new_email_conf():
9090
else:
9191
current_app.logger.debug("/auth/confirm/new -> User found, sending new confirmation email")
9292
token = generate_confirmation_token(email=email, token_type="confirm")
93-
link = os.getenv("APP_URL") + "/auth/confirm/" + token
93+
link = os.getenv("FRONTEND_BASE_URL") + "/auth/confirm/" + token
9494
rendered_html = render_template("confirm_email.html", link=link)
9595
send_mail_html.delay(dest=data["email"], subject="Confirm your email on PyMatcha", html=rendered_html)
9696
current_app.logger.debug("/auth/confirm/new -> New confirmation email sent if user exists in database")

backend/PyMatcha/routes/api/auth/password.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ def forgot_password():
5555
pass
5656
else:
5757
token = generate_confirmation_token(email=data["email"], token_type="reset")
58-
# link = os.getenv("APP_URL") + "/auth/password/forgot/" + token
59-
link = f"{os.getenv('FRONT_URL')}/accounts/password/reset?token={token}"
58+
link = f"{os.getenv('FRONTEND_BASE_URL')}/accounts/password/reset?token={token}"
6059
rendered_html = render_template("password_reset.html", link=link)
6160
current_app.logger.debug("/auth/password/forgot -> Sending worker request to send email")
6261
send_mail_html.delay(dest=data["email"], subject="Reset your password on PyMatcha", html=rendered_html)

0 commit comments

Comments
 (0)