Skip to content

Commit

Permalink
Working docker setup (without autoreload)
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonGrace2282 committed Jan 14, 2025
1 parent 8b15637 commit 5a11890
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 2 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ on:
- push
- pull_request

env:
CI: 1

defaults:
run:
shell: bash
Expand All @@ -21,7 +24,6 @@ jobs:
image: redis
ports:
- 6379:6379
options: --entrypoint redis-server

steps:
- name: Set up repo
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ docs/source/reference/

# from prettier
node_modules/

celerybeat-schedule
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM python:3.11-slim-bookworm

# reduce the number of celery warnings
RUN useradd celery

ENV PIPENV_VENV_IN_PROJECT=1

COPY Pipfile .
COPY Pipfile.lock .

RUN pip install pipenv && \
pipenv install

ENV PATH="/.venv/bin:$PATH"

WORKDIR /app
61 changes: 61 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
services:
redis:
image: redis:latest
networks:
- tin-network
expose:
- "6379"

celery:
image: tin-base
user: celery
entrypoint:
- celery
- -A
- tin
- worker
networks:
- tin-network
depends_on:
- django
volumes:
- .:/app

celerybeat:
container_name: tin_celerybeat
image: tin-base
entrypoint:
- celery
- -A
- tin
- beat
networks:
- tin-network
volumes:
- .:/app
depends_on:
- django

django:
container_name: tin_django
build: .
image: tin-base
restart: on-failure
networks:
- tin-network
ports:
- 8000:8000
volumes:
- .:/app
entrypoint:
- ./manage.py
- runserver
depends_on:
- redis
healthcheck:
test: ["CMD", "curl", "-f", "http://0.0.0.0:8000"]

networks:
tin-network:
driver: bridge
name: tin-dev-network
9 changes: 8 additions & 1 deletion tin/settings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

CI = "CI" in os.environ

ALLOWED_HOSTS = [
"127.0.0.1",
"localhost",
Expand Down Expand Up @@ -234,7 +236,12 @@
CELERY_RESULT_BACKEND = "django-db"


CELERY_BROKER_URL = "redis://localhost:6379/1"
if not CI and DEBUG:
CELERY_BROKER_URL = "redis://redis:6379/0"
else:
CELERY_BROKER_URL = "redis://localhost:6379/1"

CELERY_BROKER_CONNECTION_RETRY_ON_STARTUP = True


# Markdown
Expand Down

0 comments on commit 5a11890

Please sign in to comment.