diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..00ace43 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,30 @@ +name: Docker Image build + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_SECRET }} + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ secrets.DOCKER_HUB_USERNAME }}/task-tracker-scheduler:latest, ${{ secrets.DOCKER_HUB_USERNAME }}/task-tracker-scheduler:0.1-BUILD${{ github.run_number }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0271a7b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,26 @@ +FROM maven:3.9.4 AS build + +LABEL authors="farneser" + +WORKDIR /app + +COPY pom.xml /app + +RUN mvn dependency:resolve + +COPY src /app/src + +ENV RABBITMQ_HOST ${RABBITMQ_HOST} +ENV RABBITMQ_PORT ${RABBITMQ_PORT} +ENV RABBITMQ_USERNAME ${RABBITMQ_USERNAME} +ENV RABBITMQ_PASSWORD ${RABBITMQ_PASSWORD} + +RUN mvn -f /app/pom.xml clean package + +FROM openjdk:17-jdk-slim as production + +COPY --from=build /app/target/task-tracker-email-sender*.jar /usr/local/lib/task-tracker-email-sender.jar + +EXPOSE ${SERVER_PORT} + +ENTRYPOINT ["java","-jar","/usr/local/lib/task-tracker-email-sender.jar"] \ No newline at end of file diff --git a/pom.xml b/pom.xml index a380d2f..b5ff228 100644 --- a/pom.xml +++ b/pom.xml @@ -71,6 +71,15 @@ ${project.basedir}/src/main/kotlin ${project.basedir}/src/test/kotlin + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 1.8 + 1.8 + + org.springframework.boot spring-boot-maven-plugin diff --git a/src/main/resources/application-dev.properties b/src/main/resources/application-dev.properties index 26ccfd7..6bbe3bd 100644 --- a/src/main/resources/application-dev.properties +++ b/src/main/resources/application-dev.properties @@ -13,5 +13,7 @@ spring.rabbitmq.port=5672 spring.rabbitmq.username=rabbitmq spring.rabbitmq.password=rabbitmq # scheduler -scheduler.cron=* * * * * // every minute +# every minute +scheduler.cron=* * * * * * + diff --git a/src/test/kotlin/dev/farneser/tasktrackerscheduler/TaskTrackerSchedulerApplicationTests.kt b/src/test/kotlin/dev/farneser/tasktracker/scheduler/TaskTrackerSchedulerApplicationTests.kt similarity index 59% rename from src/test/kotlin/dev/farneser/tasktrackerscheduler/TaskTrackerSchedulerApplicationTests.kt rename to src/test/kotlin/dev/farneser/tasktracker/scheduler/TaskTrackerSchedulerApplicationTests.kt index d97d666..1536eef 100644 --- a/src/test/kotlin/dev/farneser/tasktrackerscheduler/TaskTrackerSchedulerApplicationTests.kt +++ b/src/test/kotlin/dev/farneser/tasktracker/scheduler/TaskTrackerSchedulerApplicationTests.kt @@ -1,13 +1,14 @@ -package dev.farneser.tasktrackerscheduler +package dev.farneser.tasktracker.scheduler import org.junit.jupiter.api.Test import org.springframework.boot.test.context.SpringBootTest +import org.springframework.context.annotation.Profile +@Profile("test") @SpringBootTest class TaskTrackerSchedulerApplicationTests { - @Test fun contextLoads() { + assert(true) } - -} +} \ No newline at end of file diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties new file mode 100644 index 0000000..592fc33 --- /dev/null +++ b/src/test/resources/application.properties @@ -0,0 +1,19 @@ +# postgres +spring.datasource.url=jdbc:postgresql://localhost:5432/task-tracker +spring.datasource.username=postgres +spring.datasource.password=postgres +spring.datasource.driver-class-name=org.postgresql.Driver +# jpa +spring.jpa.show-sql=true +spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect +spring.jpa.hibernate.ddl-auto=none +# rabbitmq +spring.rabbitmq.host=localhost +spring.rabbitmq.port=5672 +spring.rabbitmq.username=rabbitmq +spring.rabbitmq.password=rabbitmq +# scheduler +# every minute +scheduler.cron=* * * * * * +# spring +spring.profiles.active=test \ No newline at end of file