-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
138 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
**/__pycache__ | ||
**/*.pyc | ||
.tox | ||
.vim/ | ||
.vim* | ||
.git/ | ||
*.sql | ||
*.sql.gz | ||
.mypy_cache/ | ||
.pytest_cache/ | ||
.ipython/ | ||
docker-compose.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
FROM python:3.8 | ||
|
||
ENV PYTHONUNBUFFERED=1 | ||
ENV PYTHONDONTWRITEBYTECODE=1 | ||
ENV POETRY_VIRTUALENVS_CREATE=0 | ||
|
||
RUN adduser --uid 1000 --gecos --quiet --disabled-password app_user | ||
|
||
RUN mkdir -p /usr/src/app \ | ||
&& chown app_user.app_user /usr/src/app | ||
WORKDIR /usr/src/app | ||
|
||
COPY --chown=app_user requirements.txt ./ | ||
|
||
ARG PIP_ARGS= | ||
RUN set -eux \ | ||
&& apt update \ | ||
&& apt upgrade -y \ | ||
&& apt install -y curl\ | ||
&& pip3 install -r requirements.txt $PIP_ARGS \ | ||
&& apt autoremove -y \ | ||
&& rm -rf /root/.cache/pip /var/cache/apt | ||
|
||
COPY --chown=app_user . . | ||
|
||
USER app_user | ||
|
||
CMD ["/usr/local/bin/gunicorn", "base_app.asgi:application", "-k", "uvicorn.workers.UvicornWorker", "--bind", "0.0.0.0:8000"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
version: '3.8' | ||
|
||
volumes: | ||
python-pkgs: | ||
db-data: | ||
cache-data: | ||
|
||
x-common: &app-common | ||
build: | ||
context: . | ||
env_file: .env | ||
environment: | ||
DATABASE_URL: psql://db/base_app | ||
DATABASE_USER: postgres | ||
DATABASE_PASSWORD: postgres | ||
CACHE_URL: redis://cache:6379/0 | ||
CELERY_BROKER_URL: redis://cache:6379/1 | ||
CELERY_RESULT_BACKEND: redis://cache:6379/2 | ||
user: ${UID:-app_user} | ||
volumes: | ||
- ${COMPOSE_APP_PATH:-.}:/usr/src/app:delegated | ||
- ${COMPOSE_PYTHON_PKG_PATH:-python-pkgs}:/usr/local/lib/python3.8/site-packages:z | ||
|
||
services: | ||
app: | ||
<<: *app-common | ||
command: | ||
- uvicorn | ||
- base_app.asgi:application | ||
- --workers=${COMPOSE_WEB_WORKERS:-4} | ||
- --host=0.0.0.0 | ||
- --port=8000 | ||
- --reload | ||
- --log-level=${COMPOSE_WEB_LOG_LEVEL:-info} | ||
- --lifespan=off | ||
restart: unless-stopped | ||
depends_on: | ||
- cache | ||
- db | ||
tty: true | ||
ports: | ||
- "${COMPOSE_WEB_PORT:-8002}:8000" | ||
|
||
task_worker: | ||
<<: *app-common | ||
command: | ||
- celery | ||
- worker | ||
- --events | ||
- --app | ||
- base_app.celery | ||
- --loglevel=${COMPOSE_TASK_LOG_LEVEL:-info} | ||
- --pool=gevent | ||
- --concurrency=${COMPOSE_TASK_CONCURRENCY:-100} | ||
restart: unless-stopped | ||
depends_on: | ||
- cache | ||
- db | ||
|
||
db: | ||
image: postgres:12-alpine | ||
environment: | ||
POSTGRES_USER: postgres | ||
POSTGRES_PASSWORD: postgres | ||
POSTGRES_DB: base_app | ||
restart: unless-stopped | ||
ports: | ||
- '${COMPOSE_DB_PORT:-0}:5432' | ||
volumes: | ||
- db-data:/var/lib/postgresql/data | ||
|
||
cache: | ||
image: redis:5-alpine | ||
restart: unless-stopped | ||
volumes: | ||
- cache-data:/var/lib/redis | ||
ports: | ||
- '${COMPOSE_CACHE_PORT:-0}:6379' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters