Repository navigation
update user dockerfile change mvn/jre distribution #9
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 Image CI | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| pull_request: | |
| branches: [ "main" ] | |
| env: | |
| REPOSITORY_NAME: find-trade-x | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v3 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| architecture: 'x64' | |
| - name: Run tests of user module | |
| working-directory: ./user | |
| run: mvn verify | |
| build-image: | |
| needs: test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Build Docker image (local tag) | |
| run: docker build -t "${{ env.REPOSITORY_NAME }}:latest" -f user/Dockerfile . | |
| - name: Save Docker image | |
| run: docker save "${{ env.REPOSITORY_NAME }}:latest" -o docker-image.tar | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: docker-image | |
| path: docker-image.tar | |
| retention-days: 1 | |
| publish: | |
| needs: build-image | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Configure AWS Credentials | |
| uses: aws-actions/configure-aws-credentials@v5.1.0 | |
| with: | |
| aws-region: us-east-1 | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| - name: Amazon ECR Login | |
| id: login-ecr | |
| uses: aws-actions/amazon-ecr-login@v2 | |
| - name: Download artifact | |
| uses: actions/download-artifact@v6 | |
| with: | |
| name: docker-image | |
| - name: Load Docker image | |
| run: docker load -i docker-image.tar | |
| - name: Push to Amazon ECR | |
| env: | |
| IMAGE_TAG: latest | |
| ECR_REPOSITORY: dev/${{ env.REPOSITORY_NAME }}-rep | |
| run: | | |
| docker tag "${{ env.REPOSITORY_NAME }}:${IMAGE_TAG}" "${{ steps.login-ecr.outputs.registry }}/${ECR_REPOSITORY}:${IMAGE_TAG}" | |
| docker push "${{ steps.login-ecr.outputs.registry }}/${ECR_REPOSITORY}:${IMAGE_TAG}" |