From 28e3fd6ed4cfa11e378d7b85f85940fb44290123 Mon Sep 17 00:00:00 2001 From: Emma Date: Fri, 16 Aug 2024 10:25:31 +0100 Subject: [PATCH] tidy up --- docker/Dockerfile | 6 ++---- docker/run | 4 +++- package.json | 7 +++++++ scripts/run-dependencies | 9 ++++----- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index d1050cad..df02006d 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -6,11 +6,9 @@ ENV NODE_ENV=production WORKDIR /src -COPY --link package.json package-lock.json . +COPY . . RUN npm install --production=false -COPY --link . . - # Generate the prisma client code RUN npx prisma generate @@ -19,4 +17,4 @@ RUN npm run build ENV PORT=$PORT # migrate the db before running the server -CMD npx prisma migrate deploy;node .output/server/index.mjs +CMD ["/bin/bash", "-c", "npx prisma migrate deploy;node .output/server/index.mjs"] diff --git a/docker/run b/docker/run index f0d907be..99d931fe 100755 --- a/docker/run +++ b/docker/run @@ -4,7 +4,9 @@ HERE=$(dirname $0) . $HERE/common # NB SHA image must be built before running this script -docker run --rm -d \ +# run-dependencies should also have been run, to create network and db container (the web app container will apply +# migrations to the db, so the db container must be running first). +docker run -d \ --name "$APP_IMAGE_NAME" \ --network=daedalus \ -p 3000:3000 \ diff --git a/package.json b/package.json index c4033318..4d433376 100644 --- a/package.json +++ b/package.json @@ -70,5 +70,12 @@ "1": "==============================", "2": "Vue version is overridden because of the issue described in the 'tip' in", "3": "the installation section of https://pinia.vuejs.org/ssr/nuxt.html" + }, + "simple-git-hooks": { + "pre-commit": "npx lint-staged" + }, + "lint-staged": { + "*": "eslint --fix", + "*/schema.prisma": "prisma format" } } diff --git a/scripts/run-dependencies b/scripts/run-dependencies index 794a66bb..9cfed2be 100755 --- a/scripts/run-dependencies +++ b/scripts/run-dependencies @@ -43,11 +43,10 @@ fi docker exec daedalus-web-app-db wait-for-db +docker network create daedalus +docker network connect daedalus daedalus-web-app-db + # Pull and run the R API image R_API_IMAGE='mrcide/daedalus.api:latest' docker pull $R_API_IMAGE # There will be a 'latest' tag: https://github.com/jameel-institute/daedalus.api/pull/2#issuecomment-2252491603 -docker run -d --name daedalus-api --rm -p 8001:8001 $R_API_IMAGE - -docker network create daedalus -docker network connect daedalus daedalus-api -docker network connect daedalus daedalus-web-app-db +docker run -d --name daedalus-api --rm --network=daedalus -p 8001:8001 $R_API_IMAGE