From 7aa48c45815921ac2165d83a5302d219ea434b20 Mon Sep 17 00:00:00 2001 From: Dominik Hebeler <dominik@hebeler.club> Date: Wed, 1 Mar 2023 10:11:38 +0100 Subject: [PATCH] building npm deps --- .gitlab-ci.yml | 20 ++++++++++++++++++++ build/pass/Dockerfile | 11 +++++++++-- docker-compose.yml | 1 + 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 175c0c3..5e6571e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,4 +1,5 @@ variables: + NODE_IMAGE: node:19-bullseye DOCKER_HOST: "tcp://docker-dind.gitlab-suma:2375" DOCKER_BUILD_IMAGE: docker:20.10.15 DOCKER_IMAGE_NAME: keymanager @@ -11,9 +12,28 @@ stages: - build - deploy +npm_deps: + stage: build + image: ${NODE_IMAGE} + variables: + npm_config_cache: /app/.npm + cache: + key: npm-cache + paths: + - .npm + artifacts: + public: false + paths: + - node_modules + script: + - npm i + build: stage: build image: ${DOCKER_BUILD_IMAGE} + needs: + - job: npm_deps + artifacts: true before_script: - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY script: diff --git a/build/pass/Dockerfile b/build/pass/Dockerfile index e289bc8..93680b4 100644 --- a/build/pass/Dockerfile +++ b/build/pass/Dockerfile @@ -1,8 +1,15 @@ -FROM node:19-bullseye +FROM node:19-bullseye as development RUN mkdir /data && chown 1000:1000 /data VOLUME ["/data"] USER 1000 +WORKDIR /app -CMD [ "bash", "-c", "npm i && npm run dev"] \ No newline at end of file +CMD [ "bash", "-c", "npm i && npm run dev"] + +FROM development as production + +ADD pass /app + +CMD ["npm", "start"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 8a509bd..80a6c46 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,6 +17,7 @@ services: express: build: context: ./build/pass + target: development networks: - metager environment: -- GitLab