Skip to content

Commit

Permalink
Create setup for Docker containers
Browse files Browse the repository at this point in the history
  • Loading branch information
rennerocha committed Oct 6, 2020
1 parent 75a66ab commit 868b153
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM python:3.8

ENV APP_ROOT /dojopuzzles

RUN mkdir ${APP_ROOT}
WORKDIR ${APP_ROOT}

EXPOSE 8100

COPY start_app.sh requirements ${APP_ROOT}/
RUN pip install -r ${APP_ROOT}/requirements

ADD dojopuzzles/ ${APP_ROOT}

CMD ["gunicorn", "--bind", "0.0.0.0:8100", "dojopuzzles.wsgi"]
19 changes: 19 additions & 0 deletions docker-compose-prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: "3.3"

services:
nginx-proxy:
image: jwilder/nginx-proxy
ports:
- "80:80"
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro

dojopuzzles-app:
environment:
- VIRTUAL_HOST=app.production.domain

dojopuzzles-app-static:
environment:
- VIRTUAL_HOST=static.production.domain
expose:
- "8101"
30 changes: 30 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
version: "3.3"

services:
dojopuzzles-app:
build: .
container_name: dojopuzzles-app
restart: always
volumes:
- dojopuzzles_static_data:/static
expose:
- "8100"
env_file:
- .env
command: "/dojopuzzles/start_app.sh"

dojopuzzles-app-static:
image: nginx:latest
container_name: dojopuzzles-app-static
restart: always
volumes:
- dojopuzzles_static_data:/usr/share/nginx/html
ports:
- "8101:80"
env_file:
- .env
depends_on:
- dojopuzzles-app

volumes:
dojopuzzles_static_data:
1 change: 1 addition & 0 deletions requirements
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
Django==3.1
gunicorn==20.0.4
python-decouple==3.3
8 changes: 8 additions & 0 deletions start_app.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

printenv | grep -v "no_proxy" >> /etc/environment

python manage.py collectstatic --noinput
python manage.py migrate

gunicorn --workers=2 --bind=0.0.0.0:8100 dojopuzzles.wsgi:application

0 comments on commit 868b153

Please sign in to comment.