Skip to content

Commit

Permalink
Add a GitHub Actions workflow for building API docker images
Browse files Browse the repository at this point in the history
  • Loading branch information
jirkavrba committed Oct 5, 2024
1 parent 75febb3 commit 975b80a
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/build-api-docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Build API Docker image

on:
push:
paths:
- api/**
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

permissions:
contents: read
packages: write

steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21

- uses: docker/setup-buildx-action@v3
with:
install: true

- name: Login to container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build Docker image
working-directory: ./api
run: ./gradlew optimizedDockerBuild

- name: Push Docker image to container registry
run: docker push ghcr.io/jirkavrba/dubs-bot:latest
5 changes: 5 additions & 0 deletions api/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import com.bmuschko.gradle.docker.tasks.image.DockerBuildImage
import io.micronaut.gradle.docker.NativeImageDockerfile

plugins {
Expand Down Expand Up @@ -75,6 +76,10 @@ micronaut {
}
}

tasks.withType<DockerBuildImage> {
images = setOf("ghcr.io/jirkavrba/dubs-bot")
}

tasks.named<NativeImageDockerfile>("dockerfileNative") {
jdkVersion = "21"
}
Expand Down

0 comments on commit 975b80a

Please sign in to comment.