vsam
vsam

Reputation: 642

How to build and deploy Angular 17 Microfrontend Apps in a Monorepo

I have an npm workspace that includes three Angular standalone applications (ver. 17), all built as standalone apps without using the Nx framework (Since we are using an internal framework, I can't use Nx). Each application has its own specific library, along with a shared library used across all apps using module federation. The goal is to manage these applications as microfrontends within a monorepo structure .

I want to optimize the CI/CD pipeline in GitLab so that only the specific application (or its associated library) that has been modified is rebuilt, rather than rebuilding all applications in the workspace. For deployment, I'm using Rancher, and my next objective is to configure it so that each Angular application can be deployed independently on its own pod.

Could you advise on the best approach to deploy each application separately on Rancher and integrate this setup with single GitLab pipeline and dockerfile?

Upvotes: 0

Views: 105

Answers (1)

Giverseal
Giverseal

Reputation: 128

i think the best approach to achieve that even though you have a single pipeline is to use a dockerfile for each project, you first need to separates projects into different folders (project1,project2,..) then in each folder you can put a dockerfile:

stages:
- build
build_project1:
  stage: build
  image:
    name: gcr.io/kaniko-project/executor:debug
    entrypoint: [ "" ]
  script:
    - echo "building container for project1"
    - /kaniko/executor
      --context $CI_PROJECT_DIR/project1
      --dockerfile $CI_PROJECT_DIR/project1/Dockerfile
      --destination $DOCKER_HOST/project1
only:
  changes:
    - project1/**/*
build_project2:
  stage: build
  image:
    name: gcr.io/kaniko-project/executor:debug
    entrypoint: [ "" ]
  script:
    - echo "building container for project2"
    - /kaniko/executor
      --context $CI_PROJECT_DIR/project2
      --dockerfile $CI_PROJECT_DIR/project2/Dockerfile
      --destination $DOCKER_HOST/project2
  only:
    changes:
      - project2/**/*

...

the build_projectx will only trigger if files where changed in the projectx/ path. you can do the same to the deploy step, you just need to add a stage for deploying only the projects being updated.

PS: don't forget to define $DOCKER_HOST variable ,i'm also using kaniko instead of rancher as i'm more experienced with it.

Upvotes: 0

Related Questions