From e5d8ba27e0caf0e923d54f3610f6dfa55486461a Mon Sep 17 00:00:00 2001 From: Mateusz Kikmunter Date: Wed, 1 May 2024 22:47:21 +0100 Subject: [PATCH] separate things and fix docker on mac --- .gitignore | 1 + db/dockerfile | 7 +++++++ docker/compose.yml | 6 ++---- makefile | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) create mode 100644 db/dockerfile diff --git a/.gitignore b/.gitignore index c0b4390..9b3f044 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ db/bk db/bson/user.bson db/bson/user.metadata.json db/init-prod.js +db/db sample-app/node_modules docker-compose.yml .idea diff --git a/db/dockerfile b/db/dockerfile new file mode 100644 index 0000000..560954d --- /dev/null +++ b/db/dockerfile @@ -0,0 +1,7 @@ +FROM mongo:7.0-jammy as lotr_mongo + +COPY ./bson/* /db/data/init/ + +EXPOSE 27017 + +RUN echo "mongorestore -d lotr db/data/init" > /docker-entrypoint-initdb.d/init.sh diff --git a/docker/compose.yml b/docker/compose.yml index ae72139..dd0f494 100644 --- a/docker/compose.yml +++ b/docker/compose.yml @@ -2,16 +2,14 @@ name: lotr services: mongo: build: - context: .. - dockerfile: docker/dockerfile - target: lotr_mongo + context: ../db environment: MONGO_INITDB_DATABASE: lotr ports: - 27017:27017 restart: on-failure volumes: - - ./db:/data + - ${PWD}/../db:/data backend: build: ../backend diff --git a/makefile b/makefile index 938d292..9bee421 100644 --- a/makefile +++ b/makefile @@ -5,7 +5,7 @@ build: # start and stop the local environment up: - docker compose -f docker/compose.yml up + docker compose -f docker/compose.yml up -d down: docker compose -f docker/compose.yml down