Skip to content

Commit

Permalink
Feature/tags in documents (#61)
Browse files Browse the repository at this point in the history
* improve README for quick development with docker
* add Tag relationship to document model and related migration file
* add documentation to get_env_variable
* add custom autocomplete fields to simplify relationship in admin
* Update docker-compose.yml
* add tags and related documents in document serializer
  • Loading branch information
danieleguido authored Nov 14, 2024
1 parent 5f52f40 commit 94f3f79
Show file tree
Hide file tree
Showing 13 changed files with 495 additions and 414 deletions.
33 changes: 27 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,46 @@ a very basic django app to run "digital exhibition websites"

# Install for development

We use docker to make development easier:
We use docker to make development easier, even if you can run the app without it.
Let's create the two env files, one for docker and one for pipenv:

cp docker/.env.example docker/.env
```bash
cp ./docker/.env.example ./docker/.env
cp .env.example .development.env
```

edit the `./docker/.env` file using a proper database name and change the password; then
copy the `./example.env` file to `.env` and fill the fields using the same database name and password.
Now edit the `./docker/.env` file by choosing proper **database configss** and change the password; then
edit the `.development.env` and fill the fields using the same configuration.
This second step is needed because the **environment variable names** are different in
docker and in miller.

```ini
SECRET_KEY=*****
DEBUG=True
MILLER_DATABASE_NAME=your db name
MILLER_DATABASE_USER=your db user
MILLER_DATABASE_PASSWORD=your db pass
MILLER_DATABASE_HOST=localhost
```

then start the development docker with:

make run-dev
```bash
ENV=development make run-pipenv
```

And in another terminal:

```bash
ENV=development
```

Under the hood `make run-pipenv` runs the following command:

```bash
cd docker && docker compose down --remove-orphans && \
docker compose --env-file=../.${ENV}.env -f docker-compose.pipenv.yml up
```

This will install all images (redis, postgres...) and build locally celery and miller for you.
`Watchdog` takes care of restarting miller and celery when a py file change in the codebase.
Expand Down Expand Up @@ -65,7 +86,7 @@ We still recommend to run docker image for running Postgres and Redis:
-e POSTGRES_USER=miller \
-e PGDATA=/var/lib/postgresql/data/pgdata \
-v "$PWD/docker/postgres-data:/var/lib/postgresql/data" \
-p 54320:5432 \
-p 5432:5432 \
postgres:14.1

In this case, use the sae POSTGRES_PASSWORD and POSTGRES_USER in the env file and
Expand Down
6 changes: 3 additions & 3 deletions docker/.env.example
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
POSTGRES_USER=miller
POSTGRES_DB=miller
POSTGRES_PASSWORD=miller
MILLER_TAG=latest
DEBUG=False
ALLOWED_HOSTS=localhost,127.0.0.1
STATIC_URL=/miller-assets/
MILLER_SCHEMA_ROOT=/contents/schema
LANGUAGES="en|American English|en_US|english,fr|French|fr_FR|french,de|German|de_DE|german"
NGINX_PORT=80
MILLER_DATABASE_USER=****
MILLER_DATABASE_PASSWORD=****
MILLER_DATABASE_NAME=****
32 changes: 16 additions & 16 deletions docker/docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ services:
- ./data/redis:/data:z
entrypoint: redis-server --appendonly yes
ports:
- "63790:6379"
- '63790:6379'
postgresdb:
image: postgres:14
ports:
- "54320:5432"
- '54320:5432'
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_DB: ${POSTGRES_DB}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_USER: ${MILLER_DATABASE_USER}
POSTGRES_DB: ${MILLER_DATABASE_NAME}
POSTGRES_PASSWORD: ${MILLER_DATABASE_PASSWORD}
volumes:
- ./data/initdb.d:/docker-entrypoint-initdb.d:Z
- ./data/postgres:/var/lib/postgresql/data:Z
Expand All @@ -26,9 +26,9 @@ services:
environment:
DEBUG: ${DEBUG}
LANGUAGES: ${LANGUAGES}
MILLER_DATABASE_NAME: ${POSTGRES_DB}
MILLER_DATABASE_USER: ${POSTGRES_USER}
MILLER_DATABASE_PASSWORD: ${POSTGRES_PASSWORD}
MILLER_DATABASE_NAME: ${MILLER_DATABASE_NAME}
MILLER_DATABASE_USER: ${MILLER_DATABASE_USER}
MILLER_DATABASE_PASSWORD: ${MILLER_DATABASE_PASSWORD}
MILLER_DATABASE_HOST: postgresdb
MILLER_DATABASE_PORT: 5432
MILLER_SCHEMA_ROOT: ${MILLER_SCHEMA_ROOT}
Expand Down Expand Up @@ -57,9 +57,9 @@ services:
ALLOWED_HOSTS: ${ALLOWED_HOSTS}
LANGUAGES: ${LANGUAGES}
STATIC_URL: ${STATIC_URL}
MILLER_DATABASE_NAME: ${POSTGRES_DB}
MILLER_DATABASE_USER: ${POSTGRES_USER}
MILLER_DATABASE_PASSWORD: ${POSTGRES_PASSWORD}
MILLER_DATABASE_NAME: ${MILLER_DATABASE_NAME}
MILLER_DATABASE_USER: ${MILLER_DATABASE_USER}
MILLER_DATABASE_PASSWORD: ${MILLER_DATABASE_PASSWORD}
MILLER_DATABASE_HOST: postgresdb
MILLER_DATABASE_PORT: 5432
MILLER_SCHEMA_ROOT: ${MILLER_SCHEMA_ROOT}
Expand All @@ -75,12 +75,12 @@ services:
- redis
- postgresdb
entrypoint:
- "/bin/sh"
- '/bin/sh'
- -c
- |
PYTHONPATH=/ python miller/dbconnection.py \
&& python manage.py migrate \
&& watchmedo auto-restart --recursive --patterns="*.py;*.json;*.js;*.html" --directory="/miller" -- /bin/sh -i miller/docker-compose-dev.entrypoint.sh
PYTHONPATH=/ python miller/dbconnection.py \
&& python manage.py migrate \
&& watchmedo auto-restart --recursive --patterns="*.py;*.json;*.js;*.html" --directory="/miller" -- /bin/sh -i miller/docker-compose-dev.entrypoint.sh
# ports:
# - 8008:8000
volumes:
Expand All @@ -93,7 +93,7 @@ services:
restart: always
image: nginx:1.17-alpine
ports:
- "${NGINX_PORT}:80"
- '${NGINX_PORT}:80'
depends_on:
- miller
- celery
Expand Down
34 changes: 17 additions & 17 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,27 @@ services:
postgresdb:
image: postgres:14
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_DB: ${POSTGRES_DB}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_USER: ${MILLER_DATABASE_USER}
POSTGRES_DB: ${MILLER_DATABASE_NAME}
POSTGRES_PASSWORD: ${MILLER_DATABASE_PASSWORD}
volumes:
- ./data/initdb.d:/docker-entrypoint-initdb.d:Z
- ./data/postgres:/var/lib/postgresql/data:Z
celery:
image: c2dhunilu/miller-v2:${MILLER_TAG}
restart: always
environment:
DEBUG: ${DEBUG}
LANGUAGES: ${LANGUAGES}
MILLER_DATABASE_NAME: ${POSTGRES_DB}
MILLER_DATABASE_USER: ${POSTGRES_USER}
MILLER_DATABASE_PASSWORD: ${POSTGRES_PASSWORD}
MILLER_DATABASE_HOST: postgresdb
MILLER_DATABASE_PORT: 5432
MILLER_SCHEMA_ROOT: ${MILLER_SCHEMA_ROOT}
REDIS_HOST: redis
REDIS_PORT: 6379
STATIC_URL: ${STATIC_URL}
DEBUG: ${DEBUG}
LANGUAGES: ${LANGUAGES}
MILLER_DATABASE_NAME: ${MILLER_DATABASE_NAME}
MILLER_DATABASE_USER: ${POSTGRES_USER}
MILLER_DATABASE_PASSWORD: ${MILLER_DATABASE_PASSWORD}
MILLER_DATABASE_HOST: postgresdb
MILLER_DATABASE_PORT: 5432
MILLER_SCHEMA_ROOT: ${MILLER_SCHEMA_ROOT}
REDIS_HOST: redis
REDIS_PORT: 6379
STATIC_URL: ${STATIC_URL}
depends_on:
- miller
entrypoint: celery -A miller worker -l info
Expand All @@ -46,9 +46,9 @@ services:
DEBUG: ${DEBUG}
ALLOWED_HOSTS: ${ALLOWED_HOSTS}
LANGUAGES: ${LANGUAGES}
MILLER_DATABASE_NAME: ${POSTGRES_DB}
MILLER_DATABASE_NAME: ${MILLER_DATABASE_NAME}
MILLER_DATABASE_USER: ${POSTGRES_USER}
MILLER_DATABASE_PASSWORD: ${POSTGRES_PASSWORD}
MILLER_DATABASE_PASSWORD: ${MILLER_DATABASE_PASSWORD}
MILLER_DATABASE_HOST: postgresdb
MILLER_DATABASE_PORT: 5432
MILLER_SCHEMA_ROOT: ${MILLER_SCHEMA_ROOT}
Expand Down Expand Up @@ -82,7 +82,7 @@ services:
image: nginx:1.17-alpine
restart: always
ports:
- "${NGINX_PORT}:80"
- '${NGINX_PORT}:80'
depends_on:
- miller
- celery
Expand Down
Loading

0 comments on commit 94f3f79

Please sign in to comment.