Skip to content

Commit f5d8871

Browse files
committed
Improve and document docker-compose development environment
1 parent 25546dc commit f5d8871

8 files changed

+33
-35
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ dist/
77
example/django-import-export-celery-import-change-summaries/
88
example/django-import-export-celery-import-jobs/
99
example/django-import-export-celery-export-jobs/
10-
pipenv/
10+
pyenv/
1111
django_import_export_celery.egg-info/
1212
db/
1313
.idea/

Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
FROM python:3.7
22
RUN pip3 install poetry celery
33
RUN apt-get update ; apt-get install -yq python3-psycopg2 gdal-bin
4-
RUN useradd test
4+
ARG UID
5+
RUN useradd test --uid $UID
56
RUN chsh test -s /bin/bash

Makefile

+7-30
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,8 @@
1-
VERSION = $(shell git describe --abbrev=0 --tags)
2-
REPO_FILES ?= git ls-files -z | xargs --null -I '{}' find '{}' -type f -print0
3-
REPO_TXT_FILES ?= git ls-files -z | xargs --null -I '{}' find '{}' -type f -print0 | egrep -zZv '(png|svg)$$'
1+
docker-compose: Dockerfile
2+
mkdir -p pyenv
3+
mkdir -p db
4+
sudo docker-compose build --build-arg UID=$(shell id -u)
5+
sudo docker-compose up -d web postgres
6+
sudo docker exec -it django-import-export-celery_web_1 /proj/setup-dev-env.sh
7+
sudo docker-compose down
48

5-
packages: clean
6-
python3 setup.py bdist_wheel
7-
git archive --format=tar.gz $(VERSION) > dist/django-import-export-celery-$(VERSION).tar.gz
8-
cd dist ; gpg --detach-sign -a *.whl
9-
cd dist ; gpg --detach-sign -a *.tar.gz
10-
11-
deploy-pypi:
12-
twine upload dist/*.whl
13-
twine upload dist/*.whl.asc
14-
15-
deploy: deploy-pypi
16-
echo Deployed
17-
18-
clean:
19-
rm -r dist ; exit 0
20-
rm -r django_import_export_celery.egg-info ; exit 0
21-
rm -r build ; exit 0
22-
23-
qa: qa-miscellaneous qa-https-everywhere
24-
25-
qa-miscellaneous:
26-
$(REPO_TXT_FILES) | grep -zZv 'setup.py$$' | xargs --null sed -i 's#LGPL\s*v3#LGPL-3.0#g;'
27-
28-
qa-https-everywhere:
29-
$(REPO_TXT_FILES) | xargs --null sed --regexp-extended --in-place 's#http(:\\?/\\?/)(momentjs\.com|overpass-turbo\.eu|www\.gnu\.org|stackoverflow\.com|(:?www\.)?openstreetmap\.(org|de)|nominatim\.openstreetmap\.org|taginfo\.openstreetmap\.org|wiki\.openstreetmap\.org|josm.openstreetmap.de|www.openstreetmap.org\\/copyright|github\.com|xkcd\.com|www\.heise\.de|www\.readthedocs\.org|askubuntu\.com|xpra\.org|docker\.com|linuxcontainers\.org|www\.ecma-international\.org|www\.w3\.org|example\.com|www\.example\.com)#https\1\2#g;'
30-
$(REPO_TXT_FILES) | xargs --null sed -i 's#http://overpass-api\.de#https://overpass-api.de#g;'
31-
$(REPO_TXT_FILES) | xargs --null sed --regexp-extended --in-place 's#http://(\w+\.wikipedia\.org)#https://\1#g;'

README.rst

+9
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,15 @@ Performing exports with celery
149149

150150
6. Click on the link near the bottom of the page titled `Exported file`.
151151

152+
For developers of this library
153+
------------------------------
154+
155+
You can enter a preconfigured dev environment by first running `make` and then launching `./develop.sh` to get into a docker compose environment packed with **redis**, **celery**, **postgres** and everything you need to run and test django-import-export-celery.
156+
157+
Before submitting a PR please run `flake8` and (in the examples directory) `python3 manange.py test`.
158+
159+
Please note, that you need to restart celery for changes to propogate to the workers. Do this with `docker-compose down celery`, `docker-compose up celery`.
160+
152161
Credits
153162
-------
154163

dev-entrypoint.sh

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
cd example
3+
poetry shell

develop.sh

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
docker-compose down
3+
docker-compose up -d
4+
exec docker exec -u test -it django-import-export-celery_web_1 bash --init-file "/proj/dev-entrypoint.sh"

docker-compose.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ services:
1414
user: test
1515
volumes:
1616
- ./:/proj/
17-
- ./pipenv:/home/test
17+
- ./pyenv:/home/test
1818
celery:
1919
build: .
20-
entrypoint: poetry run celery worker -A project.celery
20+
entrypoint: poetry run celery -A project.celery worker
2121
links:
2222
- postgres
2323
- redis
@@ -27,7 +27,7 @@ services:
2727
user: test
2828
volumes:
2929
- ./:/proj/
30-
- ./pipenv:/home/test
30+
- ./pyenv:/home/test
3131
redis:
3232
image: redis
3333
postgres:

setup-dev-env.sh

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
cd example
3+
poetry install
4+
poetry run python3 manage.py migrate

0 commit comments

Comments
 (0)