Skip to content

Commit

Permalink
Restrict container image pushes to main branch and streamline deploym…
Browse files Browse the repository at this point in the history
…ent workflows (#193)

### Summary & Motivation


Implement guards in both `application.yml` and `_publish-container.yml`
to ensure container images are pushed exclusively from the main branch.

Remove the redundant success check for the staging job in production
deployment, streamlining the workflow.

Simplify the creation of a non-root user in the Dockerfile by omitting
the creation of a nonroot group.

### Checklist

- [x] I have added a Label to the pull-request
- [x] I have added tests, and done manual regression tests
- [x] I have updated the documentation, if necessary
  • Loading branch information
tjementum authored Oct 31, 2023
2 parents e560130 + 79bbf79 commit c7f502f
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/_deploy-container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
production-west-europe-deploy:
name: Production
if: github.ref == 'refs/heads/main' && needs.staging-west-europe-deploy.result == 'success'
if: github.ref == 'refs/heads/main'
needs: staging-west-europe-deploy
runs-on: ubuntu-latest
environment: "production" ## Force a manual approval
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/_publish-container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ on:
jobs:
publish-container-image:
name: Publish Container
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- name: Checkout code
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ jobs:

account-management-api-publish:
name: Account Management API Publish
if: github.ref == 'refs/heads/main'
needs: [build]
uses: ./.github/workflows/_publish-container.yml
secrets: inherit
Expand Down
2 changes: 1 addition & 1 deletion application/account-management/Api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ RUN apk add --no-cache icu-libs
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false

# Create non-root user
RUN addgroup -S nonroot && adduser -S nonroot -G nonroot
RUN adduser -S nonroot
USER nonroot

# Expose port 8443 (non-root user can't use ports below 1024)
Expand Down

0 comments on commit c7f502f

Please sign in to comment.