Skip to content

Commit

Permalink
feat(JAQPOT-101): dockerize and publish to dockerhub
Browse files Browse the repository at this point in the history
  • Loading branch information
alarv committed May 30, 2024
1 parent f46b4cf commit dd48102
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 1 deletion.
55 changes: 55 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

# GitHub recommends pinning actions to a commit SHA.
# To get a newer version, you will need to update the SHA.
# You can also reference a tag or branch, but the action may change without warning.

name: Publish Docker image

on:
release:
types: [ published ]
push:
branches:
- feat/JAQPOT-101/dockerize-and-publish-to-dockerhub

jobs:
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: upcintua/jaqpot-test

- name: Setup Gradle
uses: gradle/gradle-build-action@v3

- name: Update version in build.gradle.kts
run: >-
sed -i "s/{{VERSION_PLACEHOLDER}}/${{ steps.meta.outputs.tags }}/g" build.gradle.kts
- name: Build docker image
run: ./gradlew bootBuildImage

- name: Log in to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and push Docker image
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
12 changes: 11 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.springframework.boot.gradle.tasks.bundling.BootBuildImage

plugins {
val kotlinVersion = "1.9.24"

Expand All @@ -14,7 +16,7 @@ plugins {
}

group = "org.jaqpot"
version = "0.0.1-SNAPSHOT"
version = "{{VERSION_PLACEHOLDER}}"

java {
sourceCompatibility = JavaVersion.VERSION_21
Expand Down Expand Up @@ -44,6 +46,9 @@ dependencies {
testImplementation("org.springframework.security:spring-security-test")
testImplementation("org.springframework.boot:spring-boot-testcontainers")

// spring boot gradle plugin for dockerizing the app
implementation("org.springframework.boot:spring-boot-gradle-plugin:3.3.0")

// logger
implementation("org.slf4j:slf4j-api:2.0.13")
implementation("io.github.oshai:kotlin-logging-jvm:6.0.9")
Expand Down Expand Up @@ -112,6 +117,11 @@ openApiGenerate {
)
}

// Dockerize
tasks.named<BootBuildImage>("bootBuildImage") {
imageName = "upcintua/jaqpot-api"
}

sourceSets {
main {
kotlin {
Expand Down

0 comments on commit dd48102

Please sign in to comment.