Skip to content

Commit d0ea0de

Browse files
committed
chore
1 parent e9a92fd commit d0ea0de

29 files changed

+209
-198
lines changed

.env/.dev-sample

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FLASK_DEBUG=1
22
FLASK_CONFIG=development
3-
DATABASE_URL=postgresql://flask_celery:flask_celery@db/flask_celery
3+
DATABASE_URL=postgresql+psycopg://flask_celery:flask_celery@db/flask_celery
44
SECRET_KEY=my_precious
55
CELERY_BROKER_URL=redis://redis:6379/0
66
CELERY_RESULT_BACKEND=redis://redis:6379/0
7-
SOCKETIO_MESSAGE_QUEUE=redis://redis:6379/0
7+
SOCKETIO_MESSAGE_QUEUE=redis://redis:6379/0

.env/.prod-sample

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FLASK_DEBUG=0
22
FLASK_CONFIG=production
3-
DATABASE_URL=postgresql://flask_celery:flask_celery@db/flask_celery
3+
DATABASE_URL=postgresql+psycopg://flask_celery:flask_celery@db/flask_celery
44
SECRET_KEY=my_precious
55
CELERY_BROKER_URL=amqp://admin:admin@rabbitmq:5672/
66
CELERY_RESULT_BACKEND=redis://redis:6379/0

app.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
import eventlet
2-
eventlet.monkey_patch()
1+
import os
2+
if not os.environ.get('FLASK_RUN_FROM_CLI'):
3+
# avoid patching if running with flask shell
4+
import eventlet
5+
eventlet.monkey_patch()
36

47
from project import create_app, ext_celery, socketio
58

69
app = create_app()
10+
celery = ext_celery.celery
711

812

913
@app.route("/")
@@ -16,5 +20,6 @@ def hello_world():
1620
app,
1721
debug=True,
1822
use_reloader=True,
19-
host='0.0.0.0'
23+
host='0.0.0.0',
24+
allow_unsafe_werkzeug=True,
2025
)

compose/local/flask/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
FROM python:3.9-slim-buster
1+
FROM python:3.11-slim-buster
22

33
ENV PYTHONUNBUFFERED 1
44
ENV PYTHONDONTWRITEBYTECODE 1
55

66
RUN apt-get update \
77
# dependencies for building Python packages
88
&& apt-get install -y build-essential \
9-
# psycopg2 dependencies
9+
# psycopg dependencies
1010
&& apt-get install -y libpq-dev \
1111
# Additional dependencies
1212
&& apt-get install -y telnet netcat \

compose/local/flask/entrypoint

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ postgres_ready() {
1111
python << END
1212
import sys
1313
14-
import psycopg2
14+
import psycopg
1515
import urllib.parse as urlparse
1616
import os
1717
@@ -23,14 +23,14 @@ host = url.hostname
2323
port = url.port
2424
2525
try:
26-
psycopg2.connect(
26+
psycopg.connect(
2727
dbname=dbname,
2828
user=user,
2929
password=password,
3030
host=host,
3131
port=port
3232
)
33-
except psycopg2.OperationalError:
33+
except psycopg.OperationalError:
3434
sys.exit(-1)
3535
sys.exit(0)
3636

compose/local/flask/start

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ set -o nounset
66

77
flask db upgrade
88
# flask run --host=0.0.0.0
9-
python app.py
9+
python app.py

compose/production/flask/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.9-slim-buster
1+
FROM python:3.11-slim-buster
22

33
ENV PYTHONUNBUFFERED 1
44
ENV PYTHONDONTWRITEBYTECODE 1

compose/production/flask/entrypoint

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ postgres_ready() {
1111
python << END
1212
import sys
1313
14-
import psycopg2
14+
import psycopg
1515
import urllib.parse as urlparse
1616
import os
1717
@@ -23,14 +23,14 @@ host = url.hostname
2323
port = url.port
2424
2525
try:
26-
psycopg2.connect(
26+
psycopg.connect(
2727
dbname=dbname,
2828
user=user,
2929
password=password,
3030
host=host,
3131
port=port
3232
)
33-
except psycopg2.OperationalError:
33+
except psycopg.OperationalError:
3434
sys.exit(-1)
3535
sys.exit(0)
3636
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM nginx:1.23-alpine
1+
FROM nginx:1.27-alpine
22

33
RUN rm /etc/nginx/conf.d/default.conf
44
COPY nginx.conf /etc/nginx/conf.d

compose/production/nginx/nginx.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ server {
2020
client_max_body_size 20M;
2121
}
2222
location /upload/ {
23-
alias /app/upload/;
23+
alias /app/uploadfiles/;
2424
}
2525

2626
location /socket.io {

0 commit comments

Comments
 (0)