diff --git a/README.md b/README.md index 7a251ac2..3793c10d 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,6 @@ docker compose up -d **Initialize backend** ```bash -sudo chmod 777 -R ./data/ cd backend/ ./push.sh ./seed.sh diff --git a/backend/Dockerfile b/backend/Dockerfile index cdcf9469..9c4ca14f 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,4 +1,4 @@ -FROM node:22.20.0-alpine as third-party-ext +FROM node:22.20.0-alpine AS third-party-ext RUN apk add python3 g++ make WORKDIR /extensions ADD extensions . @@ -9,4 +9,4 @@ RUN cd node_modules && find . -maxdepth 1 -type d -name "directus-extension-*" - FROM directus/directus:11.17.4 # Copy third party extensions -COPY --from=third-party-ext /extensions/directus ./extensions \ No newline at end of file +COPY --from=third-party-ext /extensions/directus ./extensions diff --git a/backend/README.md b/backend/README.md index ee2e97f1..770f2fb7 100644 --- a/backend/README.md +++ b/backend/README.md @@ -16,7 +16,7 @@ In order to pull data from your locally running backend (see [docker-compose](.. ``` -npx directus-sync pull \ +npx directus-sync@3.5.1 pull \ --dump-path ./directus-config/development \ --directus-url http://localhost:8055 \ --directus-email admin@it4c.dev \ @@ -29,7 +29,7 @@ You can run `./pull.sh` to run this command and modify it via `export PROJECT=.. To push local changes or to seed directus use the following command ``` -npx directus-sync push \ +npx directus-sync@3.5.1 push \ --dump-path ./directus-config/development \ --directus-url http://localhost:8055 \ --directus-email admin@it4c.dev \ @@ -73,11 +73,11 @@ echo "REASSIGN OWNED BY admin TO directus" | docker exec -i utopia-map-database- ## Access Data on local drive -In order to access the postgress data mounted to the local drive at `/data/database` you need to make it accessible (assuming you are not root): +In order to access the postgres data mounted to the local drive at `./data/database` you need to make it accessible (assuming you are not root): ``` -sudo chmod 777 -R ./data/ +sudo chmod -R 777 ./data/database ``` -This process is to be repeated whenever you restart the database docker container +This process is to be repeated whenever you restart the database docker container. -The same applies for the uploads and extension folder - ensure that the folder is writeable or file uploads will fail. +The `./data/uploads` folder is taken care of automatically by the `init-uploads` service in `docker-compose.yml`, which runs once before the backend starts and makes the directory writeable. No manual chmod needed. diff --git a/backend/directus-sync.config.json b/backend/directus-sync.config.json new file mode 100644 index 00000000..c511b5f2 --- /dev/null +++ b/backend/directus-sync.config.json @@ -0,0 +1,3 @@ +{ + "dumpPath": "./directus-config/development" +} diff --git a/cypress/README.md b/cypress/README.md index a6d8478f..10bd63d7 100644 --- a/cypress/README.md +++ b/cypress/README.md @@ -163,7 +163,10 @@ docker compose down && docker compose up -d docker compose down && sudo rm -rf ./data/database && docker compose up -d ``` -**Permission denied on ./data** +**Permission denied on ./data/database** ```bash -sudo chmod 777 -R ./data +sudo chmod -R 777 ./data/database ``` + +(The `./data/uploads` directory is fixed automatically by the +`init-uploads` service in `docker-compose.yml`.) diff --git a/docker-compose.yml b/docker-compose.yml index 51162bd6..603988a2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,6 +6,16 @@ services: volumes: - ./app/dist:/srv:ro + # One-shot helper that runs before the backend starts. + # Ensures ./data/uploads exists and is writeable by the Directus + # container (which runs as a non-root user). Without this, a fresh + # checkout fails on a permission-denied error. + init-uploads: + image: busybox + command: ["sh", "-c", "mkdir -p /uploads && chmod -R 777 /uploads"] + volumes: + - ./data/uploads:/uploads + database: image: postgis/postgis:13-master volumes: @@ -41,6 +51,8 @@ services: condition: service_healthy cache: condition: service_healthy + init-uploads: + condition: service_completed_successfully ports: - 8055:8055 volumes: