Skip to content

Commit 99f3c4f

Browse files
committed
Add docker support;
1 parent f3a86c9 commit 99f3c4f

File tree

5 files changed

+110
-0
lines changed

5 files changed

+110
-0
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
**/node_modules/

docker-compose.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
version: '3.4'
2+
services:
3+
backend:
4+
build:
5+
context: .
6+
dockerfile: ./dockerfiles/backend/Dockerfile
7+
env_file: frontend/.env
8+
ports:
9+
- '5000:5000'
10+
healthcheck:
11+
test: ["CMD", "curl", "-f", "http://localhost:5000/healthy"]
12+
interval: 1s
13+
timeout: 3s
14+
retries: 10
15+
frontend:
16+
build:
17+
context: .
18+
dockerfile: ./dockerfiles/frontend/Dockerfile
19+
env_file: backend/.env
20+
ports:
21+
- '8080:8080'
22+
depends_on:
23+
- backend
24+
healthcheck:
25+
test: ["CMD", "curl", "-f", "http://localhost:8080/"]
26+
interval: 1s
27+
timeout: 3s
28+
retries: 10

dockerfiles/backend/Dockerfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM python:3.9-slim
2+
ENV PYTHONUNBUFFERED 1
3+
4+
MAINTAINER arkanister "[email protected]"
5+
6+
WORKDIR /app
7+
8+
COPY backend/src/ .
9+
10+
ADD ./backend/requirements.pip /
11+
ADD ./dockerfiles/backend/gunicorn.py /
12+
13+
# required for healthy check
14+
RUN apt update && apt install curl -y
15+
16+
# install requirements
17+
RUN pip install gunicorn==20.0 && \
18+
pip install -r /requirements.pip
19+
20+
ENTRYPOINT ["gunicorn", "-c", "/gunicorn.py", "wsgi:application"]
21+
EXPOSE 5000

dockerfiles/backend/gunicorn.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
"""
2+
Application Configuration File
3+
https://docs.gunicorn.org/en/stable/settings.html#settings
4+
"""
5+
import os
6+
import multiprocessing
7+
8+
9+
# Chdir to specified directory before apps loading.
10+
# https://docs.gunicorn.org/en/stable/settings.html#chdir
11+
chdir = '/app/'
12+
13+
# Bind the application on localhost both on ipv6 and ipv4 interfaces.
14+
# https://docs.gunicorn.org/en/stable/settings.html#bind
15+
bind = '0.0.0.0:5000'
16+
17+
18+
####################
19+
# Worker Processes #
20+
####################
21+
22+
# The number of worker processes for handling requests.
23+
# https://docs.gunicorn.org/en/stable/settings.html#workers
24+
workers = multiprocessing.cpu_count() * 2 + 1
25+
26+
# The number of worker threads for handling requests.
27+
# https://docs.gunicorn.org/en/stable/settings.html#threads
28+
threads = 2 * multiprocessing.cpu_count()
29+
30+
# The maximum number of requests a worker will process before restarting.
31+
# https://docs.gunicorn.org/en/stable/settings.html#max-requests
32+
max_requests = os.getenv('GUNICORN_WORKER_MAX_REQUESTS', default=2400)
33+
34+
# The maximum jitter to add to the max_requests setting.
35+
# https://docs.gunicorn.org/en/stable/settings.html#max-requests-jitter
36+
max_requests_jitter = os.getenv('GUNICORN_WORKER_MAX_REQUESTS_JITTER', default=50)
37+
38+
# Workers silent for more than this many seconds are killed and restarted.
39+
# https://docs.gunicorn.org/en/stable/settings.html#timeout
40+
timeout = os.getenv('GUNICORN_WORKER_TIMEOUT', default=30)

dockerfiles/frontend/Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM node:lts-alpine
2+
3+
MAINTAINER arkanister "[email protected]"
4+
5+
# install simple http server for serving static content
6+
RUN npm install -g http-server
7+
8+
WORKDIR /app
9+
10+
# copy both 'package.json' and 'package-lock.json' (if available)
11+
COPY frontend/ .
12+
13+
# install project dependencies
14+
RUN npm install
15+
16+
# build app for production with minification
17+
RUN npm run build
18+
19+
ENTRYPOINT ["http-server", "dist"]
20+
EXPOSE 8080

0 commit comments

Comments
 (0)