Skip to content

Add FE template

Move the template in Eden to ci-devops, so other FE repos can use it.

https://git.iwoca.co.uk/iwoca/eden/-/blob/master/gitlab/templates/fe-rhea-k8s.yml

Template is the following
# yaml-language-server: $schema=https://gitlab.com/gitlab-org/gitlab/-/raw/master/app/assets/javascripts/editor/schema/ci.json

# --------------------------------- #
#    INHERITABLE TASK SETTINGS      #
# --------------------------------- #


# Base task to inherit from, just uses gitlab runner. Generally used to prepare docker images, push them or deploy GitLab pages
.base-task:
  image:
  before_script: []
  tags: []

# Kubernetes task that uses the prepared docker image, setting up the node_modules folder and outputting HW stats of the node. Default performances for the node to run on.
.k8s-task:
  image: $CURRENT_BASE_IMAGE
  before_script:
    - ln -s /node_modules ./node_modules
    - node scripts/output_hardware_stats.js
  tags:
    - k8s-default


# Kubernetes task that uses the prepared docker image, setting up the node_modules folder and outputting HW stats of the node. Default performances for the node to run on.
.k8s-task-full-node_modules:
  image: $CURRENT_BASE_IMAGE
  before_script:
    - time mv /node_modules ./node_modules
    - node scripts/output_hardware_stats.js
  tags:
    - k8s-default


# Task to build an image using
#  - Docker BuildKit flag
#  - Create and Delete the .npmrc file based on GITLAB_API_TOKEN
#  - Mount the npm registry configuration .npmrc file mount as a secret
# Requires the variables:
#  - $CURRENT_BASE_IMAGE
#  - $LATEST_BASE_IMAGE
#  - $GITLAB_API_TOKEN
.build_node_image:
  extends: .base-task
  script:
    - echo -e "\\e[0Ksection_start:`date +%s`:docker_pull\\r\\e[0K> Docker pull"
    - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
    - docker pull $LATEST_BASE_IMAGE
    - echo -e "\\e[0Ksection_end:`date +%s`:docker_pull\\r\\e[0K"
    - echo -e "\\e[0Ksection_start:`date +%s`:docker_build\\r\\e[0K> Docker build"
    - echo "@iwoca:registry=https://git.iwoca.co.uk/api/v4/packages/npm/" > .npmrc
    - echo "//git.iwoca.co.uk/api/v4/packages/npm/:_authToken=\"$GITLAB_API_TOKEN\"" >> .npmrc
    - echo "//git.iwoca.co.uk/api/v4/projects/:_authToken=\"$GITLAB_API_TOKEN\"" >> .npmrc
    - DOCKER_BUILDKIT=1 docker build . -t $CURRENT_BASE_IMAGE --cache-from $LATEST_BASE_IMAGE --rm=false --build-arg BUILDKIT_INLINE_CACHE=1  --secret id=npmrc,src=./.npmrc
    - rm .npmrc
    - echo -e "\\e[0Ksection_end:`date +%s`:docker_build\\r\\e[0K"
    - echo -e "\\e[0Ksection_start:`date +%s`:docker_push\\r\\e[0K> Docker push"
    - docker push $CURRENT_BASE_IMAGE
    - echo -e "\\e[0Ksection_end:`date +%s`:docker_push\\r\\e[0K"