diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 22dfbcd..52d03dc 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,6 +8,7 @@ docker-build: before_script: - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY script: + - docker build . -f Dockerfile.cache -t node-cache - docker build --pull -t "$DOCKER_IMAGE_NAME" . - docker push "$DOCKER_IMAGE_NAME" - | diff --git a/Dockerfile b/Dockerfile index ee3a826..a2ecf29 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,10 @@ +FROM node-cache as cache + FROM node:20.9.0-alpine3.18 +COPY --from=cache /node_modules /app/node_modules +COPY package.json /app +COPY yarn.lock /app COPY . /app WORKDIR /app diff --git a/Dockerfile.cache b/Dockerfile.cache new file mode 100644 index 0000000..e73736f --- /dev/null +++ b/Dockerfile.cache @@ -0,0 +1,6 @@ +FROM node:20.9.0-alpine3.18 + +COPY package.json ./ +COPY yarn.lock ./ + +RUN yarn install