Skip to content

Commit f621a7a

Browse files
author
mikespub
committed
use gunicorn + update params
1 parent db4904b commit f621a7a

7 files changed

Lines changed: 15 additions & 7 deletions

File tree

.env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
FLASK_PORT=5080
2+
FLASK_HOST=0.0.0.0
3+
HOST_PORT=5080

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ADD requirements.txt /app/requirements.txt
99
RUN pip install -r requirements.txt
1010

1111
# Copy our code from the current folder to /app inside the container
12-
ADD . /app
12+
ADD *.py /app/
1313

1414
# Make port 5080 available for links and/or publish
1515
ENV FLASK_PORT 5080
@@ -20,4 +20,4 @@ ENV FLASK_HOST 0.0.0.0
2020
ENV NAME World
2121

2222
# Define our command to be run when launching the container
23-
CMD ["python", "app.py"]
23+
CMD ["gunicorn", "-c", "guniconfig.py", "app:app"]

docker-compose.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ services:
66
links:
77
- redis
88
ports:
9-
- "${FLASK_PORT}:5080"
9+
- "${HOST_PORT}:${FLASK_PORT}"
1010
environment:
11-
- FLASK_PORT=5080
12-
- FLASK_HOST=0.0.0.0
11+
- FLASK_PORT=${FLASK_PORT}
12+
- FLASK_HOST=${FLASK_HOST}
1313
redis:
1414
image: redis

guniconfig.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# gunicorn configuration file
2+
import os
3+
4+
bind = "%s:%s" % (os.getenv('FLASK_HOST', '0.0.0.0'), os.getenv('FLASK_PORT', 5080))

python-app.dockerapp/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ services:
55
links:
66
- redis
77
ports:
8-
- "${FLASK_PORT}:5080"
8+
- "${HOST_PORT}:${FLASK_PORT}"
99
environment:
1010
- FLASK_PORT=${FLASK_PORT}
1111
- FLASK_HOST=${FLASK_HOST}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
FLASK_PORT: 5080
22
FLASK_HOST: 0.0.0.0
3+
HOST_PORT: 5080

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
Flask
2-
Redis
2+
redis
3+
gunicorn

0 commit comments

Comments
 (0)