From 43eef28b12b55ef1931087b6798b933a0c3a232d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillaume=20Perr=C3=A9al?= <guillaume.perreal@inrae.fr> Date: Mon, 4 May 2020 11:54:12 +0200 Subject: [PATCH] Tente de construire et d'utiliser une image Docker en CI. --- .gitlab-ci.yml | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9aed573..aa20ab2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,15 +1,16 @@ default: - tags: [docker] - image: node:14 retry: 2 interruptible: true stages: - test + - build - deploy lint: stage: test + tags: [docker] + image: node:12-buster-slim variables: NPM_CONFIG_CACHE: "$CI_PROJECT_DIR/.npm" before_script: @@ -18,23 +19,30 @@ lint: - npm install script: - npm run lint - artifacts: - name: node_modules - expire_in: 1 day - paths: - - node_modules/ cache: - key: "$CI_COMMIT_REF_NAME-$CI_JOB_NAME" + key: "$CI_COMMIT_REF_SLUG-$CI_JOB_NAME" paths: - "$NPM_CONFIG_CACHE" +docker: + stage: build + tags: [dind] + variables: + - IMAGE: "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" + script: + - docker build --tag "$IMAGE" . + - docker run --rm "$IMAGE" build + - docker push "$IMAGE" + pages: stage: deploy - needs: [lint] + tags: [dind] rules: - if: $CI_COMMIT_BRANCH == "master" + variables: + - IMAGE: "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" script: - - npm run build + - docker run --rm -v "$PWD/src:/src/ro" -v "$PWD/public:/public" "$IMAGE" build artifacts: name: pages paths: -- GitLab