PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, September 26, 2022

[FIXED] What is the best strategy for building microservices in a mono repo?

 September 26, 2022     continuous-delivery, continuous-deployment, continuous-integration, git, monorepo     No comments   

Issue

I have a mono repo (git) which houses multiple microservices that I am working on. On push, the 3rd party build service detects this push and starts processing the build and deployment.

This works great. But now I am trying to optimize this process and I would only like it to build the particular services I have been working on. This means that the build services has to detect which folders have been changed and build those services only.

I have gotten this process to work on Travis pretty well because it has a GIT_COMMIT_RANGE environment variable. So I can get all the commits in my latest push and then across all those commits get the folders that have changed.. this works really well.. but ONLY on travis.

I wish to cut out travis and build my docker images directly on a GCP or whatever other 3rd party container builder I am using, but I only wish to build the folders that have changed.

I am thinking that it might be possible to do this with a git commit hook. Through this hook I can start generating a list of folders to mark for the build server to build, or even start generating a build file (cloudbuild.yaml). Then on some git push hook, (is there even a post-push hook) I reset the contents of the cloudbuild.yaml file locally.


Solution

I have actually managed to solve this problem in a different repo using github actions

lucky for me someone created a github action to filter folders that have changed

- uses: dorny/paths-filter@v2
    id: changes
    with:
      filters: |
        src:
          - '<folder to check>/**'

In your following build steps you can then use an if statement to trigger the step if the path filter has returned true:

- name: Build node
    if: steps.changes.outputs.src == 'true'
    run: |
      <command goes here>

As you can see src will return true if anything in the subfolder has changed.

The action repo is available here https://github.com/dorny/paths-filter



Answered By - tensai
Answer Checked By - Mary Flores (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home
View mobile version

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing