diff --git a/.bin/scripts/setup-local-env.sh b/.bin/scripts/setup-local-env.sh index 95754acf41..5afe26e76c 100755 --- a/.bin/scripts/setup-local-env.sh +++ b/.bin/scripts/setup-local-env.sh @@ -34,18 +34,6 @@ echo "NEXT_PUBLIC_VERSION=0.0.0-local" >> "${ROOT_DIR}/ui/.env" echo "NEXT_PUBLIC_API_PORT=5001" >> "${ROOT_DIR}/ui/.env" yarn - -if [ "$OS_NAME" == "Linux" ]; then - chmod 440 "${ROOT_DIR}/.infra/local/mongo_keyfile" - chown 999:999 "${ROOT_DIR}/.infra/local/mongo_keyfile" -elif [ "$OS_NAME" == "Darwin" ]; then - chmod 400 "${ROOT_DIR}/.infra/local/mongo_keyfile" -else - echo "Système d'exploitation non pris en charge : $OS_NAME" -fi - -yarn -chmod 400 "${ROOT_DIR}/.infra/local/mongo_keyfile" yarn services:start yarn setup:mongodb yarn build:dev diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9333692c08..171bd07dea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,9 +44,7 @@ jobs: - name: start mongodb service run: | - chmod 400 .infra/local/mongo_keyfile - sudo chown 999:999 .infra/local/mongo_keyfile - docker compose up -d --wait mongodb + docker compose up --build -d --wait mongodb yarn setup:mongodb - name: test diff --git a/.infra/local/Dockerfile b/.infra/local/Dockerfile new file mode 100644 index 0000000000..34cb7fa3a0 --- /dev/null +++ b/.infra/local/Dockerfile @@ -0,0 +1,8 @@ +FROM mongo:7 +COPY ./mongo_keyfile /tmp/mongo_keyfile +COPY ./mongod.conf /etc/mongod.conf +RUN chown mongodb:mongodb /etc/mongod.conf +RUN chown mongodb:mongodb /tmp/mongo_keyfile +RUN chmod 400 /tmp/mongo_keyfile + +CMD ["mongod", "--config", "/etc/mongod.conf"] diff --git a/docker-compose.yml b/docker-compose.yml index 79f4de707c..9a8cc843cd 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,16 +1,13 @@ services: mongodb: - image: mongo:6.0.11 # locked by OVH production version + build: ./.infra/local/ restart: unless-stopped hostname: mongodb mem_limit: 5g ports: - "127.0.0.1:27017:27017" - command: ["-f", "/etc/mongod.conf"] volumes: - lba_mongodb_data:/data - - ./.infra/local/mongo_keyfile:/tmp/mongo_keyfile - - ./.infra/local/mongod.conf:/etc/mongod.conf healthcheck: test: ["CMD", "mongosh", "--eval", '''db.runCommand("ping").ok''', "--quiet"] interval: 10s diff --git a/package.json b/package.json index 08fb0a710b..1ad755f439 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "migration:create": "yarn cli migrations:create", "server:dev": "yarn workspace server dev", "ui:dev": "yarn workspace ui dev", - "services:start": "docker compose up --remove-orphans -d", + "services:start": "docker compose up --build --remove-orphans -d --wait", "services:stop": "docker compose down", "services:clean": "yarn services:stop; docker system prune --volumes", "seed:update": "./.bin/mna-lba seed:update",