Skip to content

Commit

Permalink
Step 3-2 - Simulating the production environment
Browse files Browse the repository at this point in the history
  • Loading branch information
lgiordani committed Dec 22, 2020
1 parent b475c5e commit 1c0fcf1
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 0 deletions.
34 changes: 34 additions & 0 deletions config/production.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[
{
"name": "FLASK_ENV",
"value": "production"
},
{
"name": "FLASK_CONFIG",
"value": "production"
},
{
"name": "POSTGRES_DB",
"value": "postgres"
},
{
"name": "POSTGRES_USER",
"value": "postgres"
},
{
"name": "POSTGRES_HOSTNAME",
"value": "localhost"
},
{
"name": "POSTGRES_PORT",
"value": "5432"
},
{
"name": "POSTGRES_PASSWORD",
"value": "postgres"
},
{
"name": "APPLICATION_DB",
"value": "application"
}
]
10 changes: 10 additions & 0 deletions docker/Dockerfile.production
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM python:3

ENV PYTHONUNBUFFERED 1

RUN mkdir /opt/code
RUN mkdir /opt/requirements
WORKDIR /opt/code

ADD requirements /opt/requirements
RUN pip install -r /opt/requirements/production.txt
33 changes: 33 additions & 0 deletions docker/production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
version: '3.4'

services:
db:
image: postgres
environment:
POSTGRES_DB: ${POSTGRES_DB}
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
ports:
- "${POSTGRES_PORT}:5432"
volumes:
- pgdata:/var/lib/postgresql/data
web:
build:
context: ${PWD}
dockerfile: docker/Dockerfile.production
environment:
FLASK_ENV: ${FLASK_ENV}
FLASK_CONFIG: ${FLASK_CONFIG}
APPLICATION_DB: ${APPLICATION_DB}
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_HOSTNAME: "db"
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_PORT: ${POSTGRES_PORT}
command: gunicorn -w 4 -b 0.0.0.0 wsgi:app
volumes:
- ${PWD}:/opt/code
ports:
- "8000:8000"

volumes:
pgdata:
1 change: 1 addition & 0 deletions requirements/production.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ Flask
flask-sqlalchemy
psycopg2
flask-migrate
gunicorn

0 comments on commit 1c0fcf1

Please sign in to comment.