variables: DOCKER_BUILDKIT: 1 IMAGE_DEPENDANCY: registry.nickbland.dev/nickbland/website-2/dependancy:latest IMAGE_BUILD: registry.nickbland.dev/nickbland/website-2/builder:latest IMAGE_FINAL: registry.nickbland.dev/nickbland/website-2/website:latest DOCKER_TLS_CERTDIR: "/certs" stages: - build - test - deploy # Run docker stuff before each stage to log into built in container registry and confirm version .base: image: docker:latest services: - docker:dind before_script: - docker --version - docker login -u "$CI_REGISTRY_USER" -p "$CI_JOB_TOKEN" "$CI_REGISTRY/$CI_PROJECT_PATH" # Create initial test cases below build:builder: extends: .base stage: build script: - docker build --build-arg BUILDKIT_INLINE_CACHE=1 --cache-from "$IMAGE_DEPENDANCY" --target dependancies -t "$IMAGE_DEPENDANCY" . - docker push "$IMAGE_DEPENDANCY" build:sourceCode: extends: .base stage: build script: - docker build --build-arg BUILDKIT_INLINE_CACHE=1 --cache-from "$IMAGE_DEPENDANCY" --cache-from "$IMAGE_BUILD" --target builder -t "$IMAGE_BUILD" . - docker push "$IMAGE_BUILD" ## ADD TEST CASES BELOW ## test:linter: extends: .base stage: test needs: ["build:builder"] script: - docker run "$IMAGE_BUILD" npm run lint # Create final minified image of production code deploy: extends: .base stage: deploy needs: ["test:linter"] script: - docker build --build-arg BUILDKIT_INLINE_CACHE=1 --cache-from "$IMAGE_DEPENDANCY" --cache-from "$IMAGE_BUILD" -t "$IMAGE_FINAL" . - docker push "$IMAGE_FINAL"