Conversation
| runs-on: ubuntu-latest | ||
| outputs: | ||
| matrix: ${{ steps.set-matrix.outputs.matrix }} | ||
| steps: | ||
| - uses: actions/checkout@v4.0.0 | ||
| with: | ||
| fetch-depth: 0 | ||
| - name: Discover apps (directories with pyproject.toml) | ||
| id: set-matrix | ||
| shell: bash | ||
| run: | | ||
| set -eo pipefail | ||
| mapfile -t files < <(git ls-files -- '**/pyproject.toml' 'pyproject.toml' | sed 's|^./||' || true) | ||
| if [ ${#files[@]} -eq 0 ]; then | ||
| echo 'matrix=[]' >> "$GITHUB_OUTPUT" | ||
| exit 0 | ||
| fi | ||
| json="[" | ||
| for f in "${files[@]}"; do | ||
| dir=$(dirname "$f") | ||
| if [ "$dir" = "." ]; then | ||
| name="root" | ||
| path="." | ||
| else | ||
| name=$(basename "$dir") | ||
| path="$dir" | ||
| fi | ||
| json="$json{\"name\":\"$name\",\"path\":\"$path\"}," | ||
| done | ||
| json="${json%,}" | ||
| json="$json]" | ||
| echo "matrix=$json" >> "$GITHUB_OUTPUT" | ||
| - name: Show discovered apps | ||
| run: echo '${{ steps.set-matrix.outputs.matrix }}' | ||
| build: |
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium
| runs-on: ubuntu-latest | ||
| needs: discover-apps | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| app: ${{ fromJson(needs.discover-apps.outputs.matrix) }} | ||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }} | ||
| timeout-minutes: 20 # Increased from 10 to handle multi-platform builds | ||
| steps: | ||
| - uses: actions/checkout@v4.0.0 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Get branch name | ||
| run: echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT | ||
| id: get_branch | ||
|
|
||
| - run: echo "REPOSITORY_NAME=`echo "$GITHUB_REPOSITORY" | awk -F / '{print $2}' | sed -e "s/:refs//"`" >> $GITHUB_ENV | ||
| shell: bash | ||
|
|
||
| - name: Get version tag | ||
| run: echo "version=$(echo `git ls-remote https://${{ secrets.ORG_PAT_GITHUB }}@github.com/atlanhq/${REPOSITORY_NAME}.git ${{ steps.get_branch.outputs.branch }} | awk '{ print $1}' | cut -c1-7`)abcd" >> $GITHUB_OUTPUT | ||
| id: get_version | ||
|
|
||
| - name: Lowercase branch name | ||
| run: echo "lowercase_branch=$(echo '${{ steps.get_branch.outputs.branch }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT | ||
| id: get_lowercase_branch | ||
|
|
||
| - name: Set up Buildx | ||
| id: buildx | ||
| uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0 https://github.com/docker/setup-buildx-action/releases/tag/v3.10.0 | ||
|
|
||
| - name: Login to GitHub Registry | ||
| uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0 https://github.com/docker/login-action/releases/tag/v3.4.0 | ||
| with: | ||
| registry: ghcr.io | ||
| username: $GITHUB_ACTOR | ||
| password: ${{ secrets.ORG_PAT_GITHUB }} | ||
|
|
||
| - name: Build and push docker image to GHCR | ||
| id: ghcr_docker_build | ||
| uses: docker/build-push-action@1dc73863535b631f98b2378be8619f83b136f4a0 # v6.17.0 https://github.com/docker/build-push-action/releases/tag/v6.17.0 | ||
| with: | ||
| context: . | ||
| file: ./Dockerfile | ||
| push: true | ||
| platforms: linux/amd64,linux/arm64 | ||
| tags: | | ||
| ghcr.io/atlanhq/${{ github.event.repository.name }}-${{ matrix.app.name }}-${{ steps.get_lowercase_branch.outputs.lowercase_branch }}:latest | ||
| ghcr.io/atlanhq/${{ github.event.repository.name }}-${{ matrix.app.name }}-${{ steps.get_lowercase_branch.outputs.lowercase_branch }}:${{ steps.get_version.outputs.version }} | ||
| build-args: | | ||
| ACCESS_TOKEN_USR=$GITHUB_ACTOR | ||
| ACCESS_TOKEN_PWD=${{ secrets.ORG_PAT_GITHUB }} | ||
| APP_PATH=${{ matrix.app.path }} | ||
| env: | ||
| DOCKER_CLIENT_TIMEOUT: 600 # Increased timeout | ||
| COMPOSE_HTTP_TIMEOUT: 600 | ||
|
|
||
| # Add Docker Hub login | ||
| - name: Login to Docker Hub | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| username: atlanhq | ||
| password: ${{ secrets.DOCKER_HUB_PAT_RW }} | ||
|
|
||
| - name: Build and push docker image to Docker Hub | ||
| id: docker_build | ||
| uses: docker/build-push-action@1dc73863535b631f98b2378be8619f83b136f4a0 # v6.17.0 https://github.com/docker/build-push-action/releases/tag/v6.17.0 | ||
| with: | ||
| context: . | ||
| file: ./Dockerfile | ||
| push: true | ||
| platforms: linux/amd64,linux/arm64 | ||
| tags: | | ||
| registry-1.docker.io/atlanhq/${{ github.event.repository.name }}-${{ matrix.app.name }}:${{ steps.get_branch.outputs.branch }}-${{ steps.get_version.outputs.version }} | ||
| registry-1.docker.io/atlanhq/${{ github.event.repository.name }}-${{ matrix.app.name }}:${{ steps.get_branch.outputs.branch }}-latest | ||
| build-args: | | ||
| ACCESS_TOKEN_USR=$GITHUB_ACTOR | ||
| ACCESS_TOKEN_PWD=${{ secrets.ORG_PAT_GITHUB }} | ||
| APP_PATH=${{ matrix.app.path }} | ||
| env: | ||
| DOCKER_CLIENT_TIMEOUT: 300 | ||
| COMPOSE_HTTP_TIMEOUT: 300 |
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium
There was a problem hiding this comment.
Pull Request Overview
This PR implements Docker image building for individual apps by modifying the Dockerfile to accept a build argument for specifying which app directory to build, and adding a GitHub Actions workflow that discovers all apps with pyproject.toml files and builds separate Docker images for each.
- Dockerfile now accepts an
APP_PATHbuild argument to specify which app directory to build - Added GitHub Actions workflow to automatically discover apps and build Docker images for each
- Made DAPR app ID configurable via environment variable
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| Dockerfile | Modified to accept APP_PATH build argument and copy files from specific app directories |
| .github/workflows/build-image.yaml | New workflow for discovering apps and building Docker images with matrix strategy |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
|
||
| # Add Docker Hub login | ||
| - name: Login to Docker Hub | ||
| uses: docker/login-action@v3 |
There was a problem hiding this comment.
This action uses a non-pinned version tag 'v3' while other Docker actions in the same workflow use pinned SHA hashes. For consistency and security, consider using a pinned SHA hash like the other actions.
| uses: docker/login-action@v3 | |
| uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0 https://github.com/docker/login-action/releases/tag/v3.4.0 |
|
|
||
| # Install dependencies first (better caching) | ||
| COPY --chown=appuser:appuser pyproject.toml uv.lock README.md ./ | ||
| COPY --chown=appuser:appuser ${APP_PATH}/pyproject.toml ${APP_PATH}/uv.lock ./ |
There was a problem hiding this comment.
The COPY command will fail if uv.lock doesn't exist in the APP_PATH directory. Consider making uv.lock optional or ensuring it exists in all app directories.
| COPY --chown=appuser:appuser ${APP_PATH}/pyproject.toml ${APP_PATH}/uv.lock ./ | |
| COPY --chown=appuser:appuser ${APP_PATH}/pyproject.toml ./ | |
| RUN [ -f "${APP_PATH}/uv.lock" ] && cp "${APP_PATH}/uv.lock" ./uv.lock || true && \ | |
| chown appuser:appuser ./uv.lock 2>/dev/null || true |
| matrix: | ||
| app: ${{ fromJson(needs.discover-apps.outputs.matrix) }} | ||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} |
There was a problem hiding this comment.
The concurrency group should include the matrix app name to prevent different app builds from canceling each other. Consider changing to: group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.app.name }}
| group: ${{ github.workflow }}-${{ github.ref }} | |
| group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.app.name }} |
📦 Trivy Vulnerability Scan Results
Report Summary
Scan Result Details✅ No vulnerabilities found during the scan for |
📦 Trivy Secret Scan Results
Report Summary
Scan Result Details✅ No secrets found during the scan for |
There was a problem hiding this comment.
@AtMrun be careful with this command, the apps have been upgraded to Dapr 1.16.0 recently so we can't change this line
No description provided.