diff --git a/.github/workflows/docker-build.yaml b/.github/workflows/docker-build.yaml new file mode 100644 index 0000000..11901da --- /dev/null +++ b/.github/workflows/docker-build.yaml @@ -0,0 +1,57 @@ +name: Build and Push Docker Image (Testing) +on: + push: + branches: ['test-worflow-for-image'] + workflow_dispatch: +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + - name: Cache Maven packages + uses: actions/cache@v2 + with: + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2 + + - name: Set up Maven settings.xml + run: | + mkdir -p ~/.m2 + echo " + + + github-webank + ${{ github.actor }} + ${{ secrets.WEBANK_ACCESS_TOKEN }} + + + " > ~/.m2/settings.xml + + - name: Build JAR + run: mvn -f online-banking-app/pom.xml clean package -DskipTests + + - name: Verify JAR File Exists + run: ls -l ./online-banking-app/target/online-banking-app-0.1-SNAPSHOT.jar + + - name: Log in to GHCR + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.WEBANK_ACCESS_TOKEN}} + + - name: Build Docker image + run: | + docker build -t ghcr.io/adorsys-gis/webank-online-banking:latest . + + - name: Push Docker image to GHCR + run: | + docker push ghcr.io/adorsys-gis/webank-online-banking:latest \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e3e6e85 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +# Run stage +FROM openjdk:17-jdk-slim + +WORKDIR /webank-OnlineBanking + +# py the JAR file from the online-banking-app module +COPY ./online-banking-app/target/online-banking-app-0.1-SNAPSHOT.jar /webank-OnlineBanking/online-banking-app-0.1-SNAPSHOT.jar + +# Expose the port your app runs on +EXPOSE 8080 + +# Run the application +CMD ["java", "-jar", "/webank-OnlineBanking/online-banking-app-0.1-SNAPSHOT.jar"] \ No newline at end of file diff --git a/online-banking-app/.gitignore b/online-banking-app/.gitignore index ee6e957..c6e5549 100644 --- a/online-banking-app/.gitignore +++ b/online-banking-app/.gitignore @@ -30,4 +30,4 @@ build/ !**/src/test/**/build/ ### VS Code ### -.vscode/ +.vscode/ \ No newline at end of file diff --git a/test.txt b/test.txt new file mode 100644 index 0000000..faf291b --- /dev/null +++ b/test.txt @@ -0,0 +1,2 @@ +Testing workflow trigger +Testing workflow trigger