Skip to content

Commit 53856cb

Browse files
committed
Replace Vagrant with Docker Compose
1 parent 3e91c69 commit 53856cb

File tree

13 files changed

+96
-47
lines changed

13 files changed

+96
-47
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
.vagrant
21
sandbox/db.sqlite3
32
docs/_build
43
dist/*

docker-compose.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
services:
2+
django: &django
3+
build:
4+
context: .
5+
dockerfile: sandbox/Dockerfile
6+
entrypoint: /app/entrypoint
7+
environment:
8+
REDIS_HOST: redis
9+
REDIS_PORT: 6379
10+
REDIS_DB: 0
11+
volumes:
12+
- ./sandbox:/app
13+
ports:
14+
- "8080:8080"
15+
depends_on:
16+
redis:
17+
condition: service_healthy
18+
19+
redis:
20+
image: redis:7-alpine
21+
healthcheck:
22+
test: ["CMD", "redis-cli", "ping"]
23+
interval: 5s
24+
timeout: 3s
25+
retries: 10
26+
27+
celery:
28+
depends_on:
29+
- django
30+
- redis
31+
<<: *django
32+
ports: []
33+
entrypoint: celery -A sandbox worker --loglevel=INFO
34+
35+
rqworker:
36+
depends_on:
37+
- django
38+
- redis
39+
<<: *django
40+
ports: []
41+
entrypoint: python manage.py rqworker

docs/contributing.rst

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,16 @@ all supported Django and Python versions::
3838
Sandbox VM
3939
==========
4040

41-
There is a ``VagrantFile`` for setting up a sandbox VM where you can play around
42-
with the functionality. Bring up the Vagrant box::
41+
Alternatively, there's a ``docker compose`` stack for setting up a sandbox
42+
environment where you can play around with the functionality.
43+
Bring up the compose stack::
4344

44-
$ vagrant up
45+
$ docker compose up
4546

46-
This may take a while but will set up a Ubuntu Precise64 VM with RabbitMQ
47-
installed. You can then SSH into the machine::
47+
The stack will start with Celery as a broker by default. You can Alternatively
48+
make use of rq by supplying the `Q` env var:
4849

49-
$ vagrant ssh
50-
$ cd /vagrant/sandbox
51-
52-
You can now decide to run the Celery implementation::
53-
54-
$ honcho -f Procfile.celery start
55-
56-
Or you can run the RQ implementation::
57-
58-
$ honcho -f Procfile.rq start
50+
$ Q=rq docker compose up
5951

6052
The above commands will start a Django runserver and the selected task worker.
6153
The dummy site will be available at ``http://localhost:8080`` on your host

docs/installation.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ up the `django-rq installation guide`_ for more details.
3535
Set up a cache
3636
~~~~~~~~~~~~~~
3737

38-
You also need to ensure you have `a cache set up`_. Most likely, you'll be using
39-
memcache so your settings will include something like::
38+
You also need to ensure you have `a cache set up`_. Most likely, you'll be using Redis
39+
or memcache so your settings will include something like::
4040

4141
CACHES = {
4242
'default': {
43-
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
43+
'BACKEND': 'django.core.cache.backends.memcached.PyMemcacheCache',
4444
'LOCATION': '127.0.0.1:11211',
4545
}
4646
}

pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ coverage = {version = ">=7.0", extras = ["toml"]}
5353
celery = ">=5.0"
5454
django-rq = ">=3"
5555

56+
57+
[tool.poetry.group.sandbox.dependencies]
58+
redis = "^7.1.0"
59+
django-debug-toolbar = "^6.1.0"
60+
5661
[tool.poetry.extras]
5762
celery = ["celery"]
5863
rq = ["django-rq"]

sandbox/Dockerfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM python:3.12-slim
2+
3+
ENV PYTHONDONTWRITEBYTECODE=1
4+
ENV PYTHONUNBUFFERED=1
5+
ENV POETRY_VIRTUALENVS_CREATE="false"
6+
7+
# Install lightweight build tools for any binary Python dependencies.
8+
RUN apt-get update \
9+
&& apt-get install -y --no-install-recommends build-essential \
10+
&& rm -rf /var/lib/apt/lists/*
11+
12+
RUN pip install --upgrade pip \
13+
&& pip install --no-cache-dir "poetry>=2"
14+
# && pip install --no-cache-dir -e .[celery,rq]
15+
16+
COPY . /package/
17+
WORKDIR /package
18+
19+
RUN poetry install --with sandbox
20+
21+
WORKDIR /app

sandbox/Procfile.celery

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

sandbox/Procfile.rq

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

sandbox/entrypoint

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
python manage.py migrate
4+
python manage.py loaddata fixture.json
5+
python manage.py runserver 0.0.0.0:8080

sandbox/provision.sh

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

0 commit comments

Comments
 (0)