Skip to content

Commit

Permalink
feat: docker ci and empty tests
Browse files Browse the repository at this point in the history
  • Loading branch information
farneser committed Nov 26, 2023
1 parent 3772798 commit 4089cf5
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 5 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -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 }}
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
9 changes: 9 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
<testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/application-dev.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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=* * * * * *


Original file line number Diff line number Diff line change
@@ -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)
}

}
}
19 changes: 19 additions & 0 deletions src/test/resources/application.properties
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 4089cf5

Please sign in to comment.