SolomonDefi / solomon-monorepo

Monorepo containing core Solomon apps, services, libraries, and deploy config.
6 stars 4 forks source link

Staging builds & image tagging strategy #183

Open kelvin-wong opened 2 years ago

kelvin-wong commented 2 years ago

Implement staging environment builds for all apps.

Example of what this could look like for web-evidence:

  build-docker-web-evidence-stg:
    name: Web Evidence Staging Image
    runs-on: ubuntu-20.04
    environment: staging
    env:
      APP_NAME: web-evidence
      BRANCH_NAME: main
    steps:
      - name: Get last commit short SHA
        id: slug
        run: echo "::set-output name=sha7::$(echo ${GITHUB_SHA} | cut -c1-7)"
      - name: Checkout code into workspace directory
        uses: actions/checkout@v2
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v1
      - name: Login to GitHub Container Registry
        uses: docker/login-action@v1
        with:
          registry: ghcr.io
          username: ${{github.actor}}
          password: ${{secrets.GITHUB_TOKEN}}
      - name: Sanitize repo owner slug
        uses: actions/github-script@v5
        id: repo_slug
        with:
          result-encoding: string
          script: return `ghcr.io/${context.repo.owner.toLowerCase()}/${context.repo.repo.toLowerCase()}`
      - name: Build prod docker image
        id: docker_build
        uses: docker/build-push-action@v2
        with:
          context: ${{env.WORKSPACE_ROOT}}
          push: true
          file: ${{env.WORKSPACE_ROOT}}/apps/${{env.APP_NAME}}/Dockerfile
          target: stg
          tags: |
            ${{steps.repo_slug.outputs.result}}/${{env.APP_NAME}}:${{env.BRANCH_NAME}}-${{steps.slug.outputs.sha7}}-${{github.run_number}}
            ${{steps.repo_slug.outputs.result}}/${{env.APP_NAME}}:latest

In this example, the app environment for staging is stg

@kelvin-wong If we do it this way, it means we'll bypass skaffold for the build stage. I think it's better, because otherwise we need to get skaffold working in Github CI, which may not be trivial. I think this method is more flexible.

beefho67 commented 2 years ago

Hey team! Please add your planning poker estimate with ZenHub @kelvin-wong @solomondefi-dev