Skip to content

Commit b0ca957

Browse files
authored
Merge pull request #91 from Xpirix/dev_environment
Dev environment updated instructions
2 parents c363810 + 13adbaf commit b0ca957

19 files changed

+166
-350
lines changed

INSTALL.md

Lines changed: 51 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,28 @@
77
- Path to your repo should be `<your current directory>/QGIS-Plugins-Website `
88
- Go to dockerize directory `cd QGIS-Plugins-Website/dockerize`
99

10+
- Create .env file
11+
```bash
12+
$ cp .env.template .env
13+
```
14+
15+
- Edit .env file and set your environment variables
16+
- Enable debug mode by setting `DEBUG=True`.
17+
- Uncomment RABBITMQ_IMAGE if you want to use a different image version.
18+
Default is `rabbitmq:3.7-alpine`. This is useful if you encounter any issues
19+
with the default image (can be also use to change the image without editing the code).
20+
Please also see [this discussion](https://github.com/qgis/QGIS-Plugins-Website/issues/80).
21+
1022
- Build and spin container
1123
```bash
1224
$ make build
13-
$ make web
1425
$ make devweb
1526
```
1627

17-
- Run migrate
28+
- Run migrate and seed db
1829
```bash
19-
$ make migrate
30+
$ make devweb-migrate
31+
$ make dbseed
2032
```
2133

2234
If you have a backup, you can restore it:
@@ -25,16 +37,47 @@ If you have a backup, you can restore it:
2537
make dbrestore
2638
```
2739

28-
otherwise, you can seed initial data from fixtures:
40+
- Set up python interpreter in PyCharm or just runserver from devweb container:
41+
```bash
42+
$ make devweb-runserver
2943
```
30-
make dbseed
44+
and now, you can see your site at `http://localhost:62202` `http://0.0.0.0:62202`.
45+
46+
- Run unit tests
47+
```bash
48+
$ make devweb-runtests
3149
```
3250

33-
- Set up python interpreter in PyCharm or just runserver from devweb container:
51+
- You can use the following credentials to log in if you ran the `make dbseed` command:
52+
```
53+
Admin account:
54+
username: admin
55+
password: admin
56+
57+
Staff account:
58+
username: staff
59+
password: staff
60+
61+
Plugin author account:
62+
username: creator
63+
password: creator
64+
```
65+
66+
- Update migrations:
3467
```bash
35-
$ make devweb-runserver
68+
$ make devweb-makemigrations app='plugins'
69+
```
70+
71+
- Run a django command from the devweb container
72+
```bash
73+
$ make devweb-exec c='python manage.py createsuperuser'
74+
$ make devweb-exec c='pip freeze'
75+
```
76+
77+
- Enter the devweb container shell
78+
```bash
79+
$ make devweb-shell
3680
```
37-
and now, you can see your site at `http://0.0.0.0:62202` (skip this step if you are using PyCharm interpreter)
3881

3982
- If 'None' appears in the search results, it indicates a misalignment between the search index and the database. This discrepancy often arises when a plugin is deleted from the model but persists in the search index. To rectify this issue, it is essential to synchronize the search index with the database by rebuilding it. Execute the following command to initiate the rebuilding process:
4083

dockerize/.env.template

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,7 @@ SENTRY_RATE=1.0
4545
METABASE_DOWNLOAD_STATS_URL='https://plugins.qgis.org/metabase/public/dashboard/<dashboard_id>'
4646

4747
# Uwsgi Docker image
48-
UWSGI_DOCKER_IMAGE='qgis/qgis-plugins-uwsgi:latest'
48+
UWSGI_DOCKER_IMAGE='qgis/qgis-plugins-uwsgi:latest'
49+
50+
# Rabbitmq docker image
51+
# RABBITMQ_IMAGE='rabbitmq:3.13.7-alpine'

dockerize/Makefile

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -199,13 +199,6 @@ exec:
199199
@echo "------------------------------------------------------------------"
200200
@docker compose -p $(PROJECT_ID) $(c)
201201

202-
loadmenu:
203-
@echo
204-
@echo "------------------------------------------------------------------"
205-
@echo "Delete all simplemenu entries and load from fixtures/all_menu.json"
206-
@echo "------------------------------------------------------------------"
207-
@docker compose -p $(PROJECT_ID) exec uwsgi python manage.py clear_simplemenu
208-
@docker compose -p $(PROJECT_ID) exec uwsgi python manage.py loaddata fixtures/all_menu.json
209202
# ----------------------------------------------------------------------------
210203
# D E V E L O P M E N T C O M M A N D S
211204
# ----------------------------------------------------------------------------
@@ -231,6 +224,34 @@ devweb: db
231224
@echo "------------------------------------------------------------------"
232225
@docker compose -p $(PROJECT_ID) up --no-deps -d devweb rabbitmq worker beat webpack
233226

227+
devweb-migrate:
228+
@echo
229+
@echo "------------------------------------------------------------------"
230+
@echo "Migrate in development mode only"
231+
@echo "------------------------------------------------------------------"
232+
@docker compose -p $(PROJECT_ID) exec devweb python manage.py migrate
233+
234+
devweb-makemigrations:
235+
@echo
236+
@echo "------------------------------------------------------------------"
237+
@echo "Migrate in development mode only"
238+
@echo "------------------------------------------------------------------"
239+
@docker compose -p $(PROJECT_ID) exec devweb python manage.py makemigrations $(app)
240+
241+
devweb-exec:
242+
@echo
243+
@echo "------------------------------------------------------------------"
244+
@echo "Execute a specific docker command"
245+
@echo "------------------------------------------------------------------"
246+
@docker compose -p $(PROJECT_ID) exec devweb $(c)
247+
248+
devweb-shell:
249+
@echo
250+
@echo "------------------------------------------------------------------"
251+
@echo "Shelling into the devweb container(s)"
252+
@echo "------------------------------------------------------------------"
253+
@docker compose -p $(PROJECT_ID) exec devweb bash
254+
234255
devweb-runserver: devweb
235256
@echo
236257
@echo "------------------------------------------------------------------"
@@ -244,3 +265,11 @@ dbseed:
244265
@echo "Seed db with JSON data from /fixtures/*.json"
245266
@echo "------------------------------------------------------------------"
246267
@docker compose -p $(PROJECT_ID) exec devweb bash -c 'python manage.py loaddata fixtures/*.json'
268+
269+
devweb-runtests:
270+
@echo
271+
@echo "------------------------------------------------------------------"
272+
@echo "Running unit tests in development mode"
273+
@echo "------------------------------------------------------------------"
274+
@docker compose -p $(PROJECT_ID) exec devweb bash -c 'python manage.py makemigrations'
275+
@docker compose -p $(PROJECT_ID) exec devweb bash -c 'python manage.py test'

dockerize/README.md

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,6 @@ make metabase
3737
make web
3838
```
3939

40-
- **dbbackups**: Starts the database backups container.
41-
```sh
42-
make dbbackups
43-
```
44-
4540
- **certbot**: Starts the Certbot container for managing SSL certificates.
4641
```sh
4742
make certbot
@@ -164,11 +159,31 @@ make build-dev
164159
make devweb-test
165160
```
166161

167-
- **devweb:** Starts the `devweb` container for development, along with RabbitMQ, worker, and beat containers.
162+
- **devweb:** Starts the `devweb` container for development, along with RabbitMQ, worker, beat, and webpack containers.
168163
```sh
169164
make devweb
170165
```
171166

167+
- **devweb-migrate:** Runs database migrations in the `devweb` container.
168+
```sh
169+
make devweb-migrate
170+
```
171+
172+
- **devweb-makemigrations:** Creates new migration files based on changes in models in the `devweb` container.
173+
```sh
174+
make devweb-makemigrations app=app_name
175+
```
176+
177+
- **devweb-exec:** Executes a specific Docker command in the `devweb` container. Specify the command with the `c` variable.
178+
```sh
179+
make devweb-exec c="command"
180+
```
181+
182+
- **devweb-shell:** Opens a shell in the `devweb` container.
183+
```sh
184+
make devweb-shell
185+
```
186+
172187
- **devweb-runserver:** Runs the Django development server inside the `devweb` container.
173188
```sh
174189
make devweb-runserver
@@ -177,9 +192,4 @@ make devweb-runserver
177192
- **dbseed:** Seeds the database with initial data from JSON files in the `fixtures` directory.
178193
```sh
179194
make dbseed
180-
```
181-
182-
- **loadmenu:** Clear all menu entries and load menu from JSON file at `fixtures/simplemenu.json`.
183-
```sh
184-
make loadmenu
185195
```

dockerize/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ services:
104104
- ${QGISPLUGINS_MEDIA_VOLUME}:/home/web/media:rw
105105

106106
rabbitmq:
107-
image: rabbitmq:3.7-alpine
107+
image: ${RABBITMQ_IMAGE:-rabbitmq:3.7-alpine}
108108
hostname: rabbitmq
109109
volumes:
110110
- rabbitmq:/var/lib/rabbitmq

qgis-app/base/tests/test_middleware.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from django.urls import reverse
66

77
class HandleTemplateDoesNotExistMiddlewareTest(TestCase):
8-
fixtures = ["fixtures/simplemenu.json"]
98
def setUp(self):
109
# Mock get_response function
1110
self.factory = RequestFactory()

0 commit comments

Comments
 (0)