Skip to content

Commit

Permalink
Rework master workflow for the multi-project build
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita Pavlovskiy committed Aug 19, 2023
1 parent 6184a51 commit 98591f6
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 6 deletions.
28 changes: 26 additions & 2 deletions .github/workflows/master_merge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
path: /home/runner/.gradle
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- run: ./gradlew test jacocoTestReport sonar
- run: ./gradlew api:test api:jacocoTestReport api:sonar
env:
GITHUB_TOKEN: ${{ github.token }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
Expand All @@ -82,7 +82,31 @@ jobs:
nikitades/carres-api:${{ github.sha }}
cache-from: type=gha,scope=api
cache-to: type=gha,mode=max,scope=api
context: apps/api
file: apps/backend/api.Dockerfile
platforms: linux/arm64

build-tgn-image:
runs-on: ubuntu-latest
needs: test-api
timeout-minutes: 15
steps:
- uses: actions/checkout@v3
- uses: docker/setup-buildx-action@v2
with:
platforms: linux/arm64
- uses: docker/login-action@v2
with:
username: nikitades
password: ${{ secrets.DOCKERHUB_TOKEN }}
- uses: docker/build-push-action@v3
with:
push: true
tags: |
nikitades/carres-api:latest
nikitades/carres-api:${{ github.sha }}
cache-from: type=gha,scope=api
cache-to: type=gha,mode=max,scope=api
file: apps/backend/api.Dockerfile
platforms: linux/arm64

build-website-image:
Expand Down
31 changes: 31 additions & 0 deletions apps/backend/api.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM eclipse-temurin:20 as install-gradle

WORKDIR /app

COPY gradlew settings.gradle /app/
COPY gradle/ /app/gradle/

RUN /app/gradlew wrapper

FROM eclipse-temurin:20 as builder

WORKDIR /app

COPY . /app/
COPY --from=install-gradle /app/.gradle/ /app/.gradle/
COPY --from=install-gradle /root/.gradle /root/.gradle

RUN /app/gradlew api:bootJar

FROM eclipse-temurin:20 as runner

WORKDIR /app

COPY --from=builder /app/.gradle /app/
COPY --from=builder /app/api/build/libs/carres-*.jar /app/carres.jar

EXPOSE 8080/tcp

HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=2 CMD curl -f http://localhost:8080/actuator/health || exit 1

CMD ["java", "-jar", "/app/carres.jar"]
4 changes: 2 additions & 2 deletions apps/backend/api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM eclipse-temurin:20 as install-gradle

WORKDIR /app

COPY gradlew settings.gradle.kts /app/
COPY gradlew /app/
COPY gradle/ /app/gradle/

RUN /app/gradlew wrapper
Expand All @@ -22,7 +22,7 @@ FROM eclipse-temurin:20 as runner
WORKDIR /app

COPY --from=builder /app/.gradle /app/
COPY --from=builder /app/build/libs/carres-0.0.1-SNAPSHOT.jar /app/carres.jar
COPY --from=builder /app/build/libs/carres-*.jar /app/carres.jar

EXPOSE 8080/tcp

Expand Down
2 changes: 1 addition & 1 deletion apps/backend/api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ plugins {
}

group = 'com.nikitades'
version = '0.0.1-SNAPSHOT'
version = '0.0.2'

java {
toolchain {
Expand Down
11 changes: 11 additions & 0 deletions apps/backend/tg-notifier/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
bin
build
.vscode
.gradle
README.md
.editorconfig
.gitignore
Dockerfile
gradlew.bat
.idea
.fleet
2 changes: 1 addition & 1 deletion apps/backend/tg-notifier/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

group = 'com.nikitades.carres'
version = '0.0.1-SNAPSHOT'
version = '0.0.1'

java {
sourceCompatibility = '20'
Expand Down
31 changes: 31 additions & 0 deletions apps/backend/tgn.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM eclipse-temurin:20 as install-gradle

WORKDIR /app

COPY gradlew settings.gradle /app/
COPY gradle/ /app/gradle/

RUN /app/gradlew wrapper

FROM eclipse-temurin:20 as builder

WORKDIR /app

COPY . /app/
COPY --from=install-gradle /app/.gradle/ /app/.gradle/
COPY --from=install-gradle /root/.gradle /root/.gradle

RUN /app/gradlew tg-notifier:bootJar

FROM eclipse-temurin:20 as runner

WORKDIR /app

COPY --from=builder /app/.gradle /app/
COPY --from=builder /app/tg-notifier/build/libs/carres-*.jar /app/carres.jar

EXPOSE 8080/tcp

HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=2 CMD curl -f http://localhost:8080/actuator/health || exit 1

CMD ["java", "-jar", "/app/carres.jar"]

0 comments on commit 98591f6

Please sign in to comment.