From 6c574f49d66058a3f4003b3115e7aab47e0d4105 Mon Sep 17 00:00:00 2001 From: zechs Date: Fri, 21 Jun 2024 18:15:47 +0530 Subject: [PATCH] refactored --- .github/workflows/build-publish.yml | 17 ++- Dockerfile | 12 +- pom.xml | 107 +++++++++--------- .../ZPlexApiApplication.java | 2 +- 4 files changed, 75 insertions(+), 63 deletions(-) rename src/main/java/zechs/zplex/{api => zplex_api}/ZPlexApiApplication.java (90%) diff --git a/.github/workflows/build-publish.yml b/.github/workflows/build-publish.yml index 74bb861..b87a5f6 100644 --- a/.github/workflows/build-publish.yml +++ b/.github/workflows/build-publish.yml @@ -31,14 +31,19 @@ jobs: - name: Build with Maven run: mvn clean package - - name: Build Docker image - run: docker build -t zplex-api . + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - - name: Log in to Docker Hub - uses: docker/login-action@v2 + - name: Log-in to registry + uses: docker/login-action@v3 with: + registry: https://index.docker.io/v1/ username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - - name: Push Docker image - run: docker push zplex-api:latest \ No newline at end of file + - name: Build and push container image to registry + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: index.docker.io/${{ secrets.DOCKER_USERNAME }}/zplex-api:${{ github.sha }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index b49af18..f22cffe 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,14 @@ -FROM openjdk:21-jdk-alpine +FROM ubuntu:20.04 ENV TZ=Asia/Kolkata WORKDIR /app -COPY target/*.jar /app/zplex-api.jar +RUN apt-get update && \ +apt-get install -y -q openjdk-21-jdk tzdata && \ +ln -sf /usr/share/zoneinfo/${TZ} /etc/localtime && \ +echo "${TZ}" > /etc/timezone && \ +apt-get clean && \ +rm -rf /var/lib/apt/lists/* -CMD ["java", "-jar", "/app/zplex-api.jar --server.port=${PORT}"] +COPY target/zplex-api*.jar /app/zplex-api.jar +CMD ["java", "-jar", "/app/zplex-api.jar", "--server.port=${PORT}"] diff --git a/pom.xml b/pom.xml index 0eba751..6adfc4f 100644 --- a/pom.xml +++ b/pom.xml @@ -1,59 +1,60 @@ - 4.0.0 - - org.springframework.boot - spring-boot-starter-parent - 3.2.3 - - - zechs.zplex - api - 0.0.1-SNAPSHOT - zplex-api - REST API for ZPlex - - 21 - - - - org.springframework.boot - spring-boot-starter-jdbc - - - org.springframework.boot - spring-boot-starter-security - - - org.springframework.boot - spring-boot-starter-web - + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 3.2.3 + + + zechs.zplex + zplex-api + 1.0.0 + zplex-api + REST API for ZPlex + + 21 + + + + org.springframework.boot + spring-boot-starter-jdbc + + + org.springframework.boot + spring-boot-starter-security + + + org.springframework.boot + spring-boot-starter-web + - - org.postgresql - postgresql - runtime - - - org.springframework.boot - spring-boot-starter-test - test - - - org.springframework.security - spring-security-test - test - - + + org.postgresql + postgresql + runtime + + + org.springframework.boot + spring-boot-starter-test + test + + + org.springframework.security + spring-security-test + test + + - - - - org.springframework.boot - spring-boot-maven-plugin - - - + + ${project.artifactId}-${project.version} + + + org.springframework.boot + spring-boot-maven-plugin + + + diff --git a/src/main/java/zechs/zplex/api/ZPlexApiApplication.java b/src/main/java/zechs/zplex/zplex_api/ZPlexApiApplication.java similarity index 90% rename from src/main/java/zechs/zplex/api/ZPlexApiApplication.java rename to src/main/java/zechs/zplex/zplex_api/ZPlexApiApplication.java index cb6621c..5ca8693 100644 --- a/src/main/java/zechs/zplex/api/ZPlexApiApplication.java +++ b/src/main/java/zechs/zplex/zplex_api/ZPlexApiApplication.java @@ -1,4 +1,4 @@ -package zechs.zplex.api; +package zechs.zplex.zplex_api; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;