Skip to content
Snippets Groups Projects

feat: Docker multi-stage build and CI/CD push

Merged Alen Zubic requested to merge multi-stage-build-and-push into main
Compare and
2 files
+ 22
131
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 9
124
stages:
- prepare
- test
- build
- dockerize
- deploy
default:
image: nikolaik/python-nodejs:python3.11-nodejs19-alpine
cache: &cache
key:
files:
- pnpm-lock.yaml
paths:
- .pnpm-store
- ./node_modules/
- ./apps/web/node_modules/
- ./libs/shared/node_modules/
policy: pull
before_script:
- npm i -g pnpm
- pnpm config set store-dir .pnpm-store
- apk add --no-cache --virtual .build-deps build-base g++ cairo-dev jpeg-dev pango-dev giflib-dev
- apk add --no-cache --virtual .runtime-deps cairo jpeg pango giflib
install:js:
stage: prepare
interruptible: true
cache:
<<: *cache
policy: push
script:
- pnpm install
# only:
# changes:
# - pnpm-lock.yaml
# - .gitlab-ci.yml
# - apps/**/*
# - libs/**/*
# refs:
# - main
# - merge_requests
.distributed:
interruptible: true
cache:
<<: *cache
before_script:
- npm i -g pnpm
- apk add --update git
artifacts:
paths:
- .pnpm-store
rules:
# - if: $CI_COMMIT_BRANCH == "main"
# - if: $CI_COMMIT_BRANCH == "merge_requests"
- changes:
- apps/**/*
- libs/**/*
- .gitlab-ci.yml
lint:
stage: test
extends: .distributed
script:
- pnpm lint
test:
stage: test
extends: .distributed
script:
- pnpm test
build-prod:
stage: build
extends: .distributed
rules:
# - if: $CI_COMMIT_BRANCH == "main"
- changes:
- apps/**/*
- libs/**/*
- .gitlab-ci.yml
artifacts:
paths:
- .pnpm-store
- dist/apps/web
script:
- pnpm build
build-docker:
image: docker:latest
services:
- name: docker:dind
alias: dockerdaemon
before_script:
- ''
stage: dockerize
tags:
- docker
# only:
# - main
script:
- echo "$CI_REGISTRY_PASSWORD" | docker login https://$CI_REGISTRY --username $CI_REGISTRY_USER --password-stdin
- cd ./apps/web
- docker build --progress plain -t $CI_REGISTRY/graphpolaris/frontend:latest .
- docker push $CI_REGISTRY/graphpolaris/frontend:latest
dependencies:
- build-prod
variables:
# Tell docker CLI how to talk to Docker daemon.
DOCKER_HOST: tcp://dockerdaemon:2375/
# Use the overlayfs driver for improved performance.
DOCKER_DRIVER: overlay2
# Disable TLS since we're running inside local network.
DOCKER_TLS_CERTDIR: ""
# deploy:
# stage: deploy
# script:
# - ./deploy.sh
# # only:
# # - main
# environment: production
variables:
CONTAINER_IMAGE: "graphpolaris/frontend"
IMAGE_TAG_HELM_FILE: "helm/staging/graphpolaris-frontend/values.yaml"
IMAGE_TAG_HELM_FILE_VARIABLE: "image.tag"
include:
- project: 'graphpolaris/pipelines'
ref: main
file: 'docker-build-push.yml'
Loading