1
1
import io.github.simulatan.gradle.plugin.buildinfo.configuration.BuildInfoExtension
2
2
import io.github.simulatan.gradle.plugin.buildinfo.configuration.PropertiesOutputLocation
3
+ import org.eclipse.jgit.api.Git
3
4
import org.jetbrains.gradle.ext.Application
4
5
import org.jetbrains.gradle.ext.runConfigurations
5
6
import org.jetbrains.gradle.ext.settings
@@ -134,7 +135,7 @@ jib {
134
135
image = " eclipse-temurin:21-jre-alpine"
135
136
}
136
137
to {
137
- val allTags = project.properties[" snoty.docker.tags" ]?.toString()?.split(" " )?.toSet()
138
+ val allTags = project.properties[" me. snoty.docker.tags" ]?.toString()?.trim ()?.split(" " )?.toSet()
138
139
? : setOf (version.toString())
139
140
image = " ghcr.io/snotyme/snoty-backend:${allTags.first()} "
140
141
// workaround for the TERRIBLE design decisions of the JIB developers to
@@ -148,6 +149,30 @@ jib {
148
149
creationTime = " USE_CURRENT_TIMESTAMP"
149
150
appRoot = " /app"
150
151
workingDirectory = " /app"
152
+ ports = listOf (" 8080" )
153
+ val (ghaRunId, ghaRunNumber) =
154
+ project.properties[" me.snoty.github.run" ]?.toString()?.split(" :" ) ? : listOf (null , null )
155
+ labels = mapOf (
156
+ " org.opencontainers.image.title" to " snoty-backend" ,
157
+ " org.opencontainers.image.description" to " Backend for the snoty project" ,
158
+ " org.opencontainers.image.url" to " https://github.com/SnotyMe/snoty-backend/pkgs/container/snoty-backend" ,
159
+ * Git .open(project.rootDir).use { git ->
160
+ val headRef = git.repository.resolve(" HEAD" ).name
161
+ arrayOf(
162
+ " org.opencontainers.image.revision" to headRef,
163
+ // source to https version of the git repository
164
+ " org.opencontainers.image.source" to git.repository.config.getString(" remote" , " origin" , " url" )
165
+ .replace(" :" , " /" )
166
+ .replace(" git@" , " https://" )
167
+ .replace(" .git" , " " )
168
+ + " /tree/$headRef "
169
+ )
170
+ },
171
+ * if (ghaRunId != null && ghaRunNumber != null ) arrayOf(
172
+ " com.github.actions.run.id" to ghaRunId,
173
+ " com.github.actions.run.number" to ghaRunNumber
174
+ ) else arrayOf()
175
+ )
151
176
}
152
177
}
153
178
0 commit comments