From ce0014776f5718882fb0ee8993da44d6925d5cce Mon Sep 17 00:00:00 2001 From: kush parsaniya Date: Tue, 27 Aug 2024 23:26:17 +0530 Subject: [PATCH 1/2] Add docker config for github action. --- .github/workflows/maven.yml | 25 ++++++++++++++++++++++++- Dockerfile | 10 ++++++++++ pom.xml | 1 + 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 Dockerfile diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index e0d8da8..3e0a2bf 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -38,4 +38,27 @@ jobs: REDIS_HOST: ${{ vars.REDIS_HOST }} REDIS_USER: ${{ vars.REDIS_USER }} REDIS_PASS: ${{ vars.REDIS_PASS }} - REDIS_PORT: ${{ vars.REDIS_PORT }} \ No newline at end of file + REDIS_PORT: ${{ vars.REDIS_PORT }} + + - name: login to docker registry + uses: docker/login-action@v3 + with: + username: ${{secrets.DOCKERHUB_USERNAME}} + password: ${{secrets.DOCKERHUB_TOKEN}} + + - name: build and push docker image to registry + uses: docker/build-push-action@v5 + env: + POSTGRES_HOST: ${{ vars.POSTGRES_HOST }} + POSTGRES_NAME: ${{ vars.POSTGRES_NAME }} + POSTGRES_PASS: ${{ vars.POSTGRES_PASS }} + POSTGRES_PORT: ${{ vars.POSTGRES_PORT }} + POSTGRES_USER: ${{ vars.POSTGRES_USER }} + REDIS_HOST: ${{ vars.REDIS_HOST }} + REDIS_USER: ${{ vars.REDIS_USER }} + REDIS_PASS: ${{ vars.REDIS_PASS }} + REDIS_PORT: ${{ vars.REDIS_PORT }} + with: + context: Dockerfile + push: true + tags: kushparsaniya/spotify-youtube-sync-github-action:latest \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2caaf98 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +# Use an official OpenJDK 21 runtime as a parent image +FROM eclipse-temurin:21-jdk + +ADD target/spotify-youtube-sync-github-action.war spotify-youtube-sync-github-action.war + +# Make port 8080 available to the world outside this container +EXPOSE 8080 + +# Run the WAR file using Tomcat +ENTRYPOINT ["java", "-jar", "/spotify-youtube-sync-github-action.war"] \ No newline at end of file diff --git a/pom.xml b/pom.xml index 4c36b39..0efb9b0 100644 --- a/pom.xml +++ b/pom.xml @@ -95,6 +95,7 @@ + spotify-youtube-sync-github-action org.graalvm.buildtools From b5c8a9e894e8ee82ba8202a6fc2353d2d518a751 Mon Sep 17 00:00:00 2001 From: kush parsaniya Date: Tue, 27 Aug 2024 23:27:51 +0530 Subject: [PATCH 2/2] remove env variables from docker steps ion maven.yml. --- .github/workflows/maven.yml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 3e0a2bf..78450da 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -48,16 +48,6 @@ jobs: - name: build and push docker image to registry uses: docker/build-push-action@v5 - env: - POSTGRES_HOST: ${{ vars.POSTGRES_HOST }} - POSTGRES_NAME: ${{ vars.POSTGRES_NAME }} - POSTGRES_PASS: ${{ vars.POSTGRES_PASS }} - POSTGRES_PORT: ${{ vars.POSTGRES_PORT }} - POSTGRES_USER: ${{ vars.POSTGRES_USER }} - REDIS_HOST: ${{ vars.REDIS_HOST }} - REDIS_USER: ${{ vars.REDIS_USER }} - REDIS_PASS: ${{ vars.REDIS_PASS }} - REDIS_PORT: ${{ vars.REDIS_PORT }} with: context: Dockerfile push: true