Skip to content

Commit 7540d42

Browse files
Add docker setup for Tin (#98)
Closes #93 - redis, celery worker, and django service - Uses `watchfiles` to reload on the change of python files in the `tin` directory. --------- Co-authored-by: Krishnan Shankar <krishnans2006@gmail.com>
1 parent 8b15637 commit 7540d42

10 files changed

Lines changed: 196 additions & 110 deletions

File tree

.github/workflows/ci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ jobs:
2121
image: redis
2222
ports:
2323
- 6379:6379
24-
options: --entrypoint redis-server
2524

2625
steps:
2726
- name: Set up repo

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@ docs/source/reference/
1616

1717
# from prettier
1818
node_modules/
19+
20+
celerybeat-schedule

Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM python:3.11-slim-bookworm
2+
3+
ENV PYTHONUNBUFFERED=1 PIPENV_VENV_IN_PROJECT=1 C_FORCE_ROOT=1
4+
5+
COPY Pipfile .
6+
COPY Pipfile.lock .
7+
8+
RUN apt-get update -y && apt-get install -y --no-install-recommends curl firejail bubblewrap
9+
10+
RUN pip install pipenv && \
11+
pipenv install --dev
12+
13+
ENV PATH="/.venv/bin:$PATH"
14+
15+
WORKDIR /app

Pipfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ furo = "*"
3434
myst-parser = "*"
3535
sphinx-copybutton = "*"
3636
sphinxcontrib-django = "*"
37+
watchfiles = "*"
3738

3839
[ci]
3940
pytest-cov = "*"

Pipfile.lock

Lines changed: 101 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

compose.yaml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
services:
2+
redis:
3+
container_name: tin_redis
4+
image: redis:latest
5+
networks:
6+
- tin-network
7+
expose:
8+
- "6379"
9+
10+
celery:
11+
container_name: tin_celery
12+
image: tin-base
13+
entrypoint:
14+
- watchfiles
15+
- --filter
16+
- python
17+
- celery -A tin worker
18+
- /app/tin
19+
networks:
20+
- tin-network
21+
depends_on:
22+
- redis
23+
volumes:
24+
- .:/app
25+
environment:
26+
IN_DOCKER: true
27+
28+
django:
29+
container_name: tin_django
30+
build: .
31+
image: tin-base
32+
restart: on-failure
33+
networks:
34+
- tin-network
35+
ports:
36+
- 8000:8080
37+
depends_on:
38+
- celery
39+
- redis
40+
volumes:
41+
- .:/app
42+
entrypoint:
43+
- ./manage.py
44+
- runserver
45+
- 0.0.0.0:8080
46+
healthcheck:
47+
test: ["CMD", "curl", "-f", "http://0.0.0.0:8080"]
48+
environment:
49+
IN_DOCKER: true
50+
51+
networks:
52+
tin-network:
53+
driver: bridge
54+
name: tin-dev-network

docs/source/contributing/setup.rst

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,12 @@ Now you're all set! Try running the development server
4343
Head on over to `http://127.0.0.1:8000 <http://127.0.0.1:8000>`_, and login
4444
as ``admin`` and the password you just entered.
4545

46+
Docker
47+
------
48+
If you prefer, you can also run the development setup with `Docker <https://www.docker.com/>`_. To do so,
49+
``cd`` into the project directory and run::
4650

51+
docker compose build
52+
docker compose up
4753

48-
NixOS Setup
49-
-----------
50-
A ``flake.nix`` file is provided for NixOS users. To use it, first enable the redis service globally.
51-
Place the following in your ``/etc/nixos/configuration.nix``::
52-
53-
services.redis.server."".enable = true
54-
55-
This will start a systemd service called ``redis``. After that, you can start the flake with::
56-
57-
nix develop
58-
59-
You can then install dependencies, setup the database, and run the development server as described above.
60-
61-
.. tip::
62-
63-
You may also need to set ``nix.settings.experimental-features = ["nix-command" "flakes"];`` in your ``configuration.nix``.
54+
The latter command will start up the django development server, as well as celery tasks for submissions.

flake.lock

Lines changed: 0 additions & 62 deletions
This file was deleted.

flake.nix

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)