added docker build workflows #1
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Docker Build (Local) | |
| on: | |
| push: | |
| branches: [ '*' ] | |
| pull_request: | |
| branches: [ '*' ] | |
| env: | |
| DOCKER_BUILDKIT: 1 | |
| COMPOSE_DOCKER_CLI_BUILD: 1 | |
| COMPOSE_FILE: ./docker-compose.yml | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| images: ${{ steps.save-images.outputs.images }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Pull MongoDB | |
| run: docker pull mongo:4.4.15 | |
| - name: Build API | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: ${{ env.COMPOSE_FILE }} | |
| target: api | |
| load: true | |
| tags: ezbids-api:test | |
| - name: Build Handler | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: ${{ env.COMPOSE_FILE }} | |
| target: handler | |
| load: true | |
| tags: ezbids-handler:test | |
| - name: Build UI | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: ${{ env.COMPOSE_FILE }} | |
| target: ui | |
| load: true | |
| tags: ezbids-ui:test | |
| - name: Save images | |
| id: save-images | |
| run: | | |
| # Save images to tar files | |
| docker save mongo:4.4.15 > mongo.tar | |
| docker save ezbids-api:test > api.tar | |
| docker save ezbids-handler:test > handler.tar | |
| docker save ezbids-ui:test > ui.tar | |
| # Upload as artifacts | |
| echo "images=mongo.tar,api.tar,handler.tar,ui.tar" >> $GITHUB_OUTPUT | |
| - name: Upload images | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: docker-images-local | |
| path: | | |
| mongo.tar | |
| api.tar | |
| handler.tar | |
| ui.tar | |
| retention-days: 1 | |
| - name: Clean up | |
| run: docker system prune -f |