Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

push images to GitHub Container Registry #2555

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ jobs:
DEFAULT_NODE_VERSION: "18"

steps:
- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v4

- name: About env
run: |
echo "Env"
Expand Down
43 changes: 19 additions & 24 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import com.github.spotbugs.snom.SpotBugsTask
import io.zucchini.build.docker.DockerExtension
import io.zucchini.build.docker.DockerPlugin
import io.zucchini.build.node.NodePlugin
import io.zucchini.build.node.YarnTask
Expand Down Expand Up @@ -47,22 +48,6 @@ allprojects {
mavenCentral()
}

ext.getDockerTags = {
List<String> dockerTags = []

// Branch slug, without special characters
String branchName = project.grgit.branch.current().name
String branchSlug = branchName.replace('/', '-')

// If the Git branch is the master branch, then the Docker image will be tagged "latest"
dockerTags << "branch-${branchSlug}"
if (branchName == 'master') {
dockerTags << 'latest'
}

return dockerTags
}

// Plugins to use with the java plugin

afterEvaluate {
Expand Down Expand Up @@ -125,6 +110,23 @@ allprojects {

}

// Shared Docker config
DockerExtension dockerExtension = project.getExtensions().findByType(DockerExtension.class)
if (dockerExtension) {
dockerExtension.repositories << (project.properties['docker.baseRepository'] as String)
dockerExtension.repositories << (project.properties['docker.publishRepository'] as String)

// If the Git branch is the master branch, then the Docker image will be tagged "latest"
String branchName = project.grgit.branch.current().name
if (branchName == 'master') {
dockerExtension.tags << 'latest'
} else {
// Branch slug, without special characters
String branchSlug = branchName.replace('/', '-')
dockerExtension.tags << "branch-${branchSlug}"
}
}

// Shared Java compiler config
project.tasks.withType(JavaCompile) {
options.release = 17
Expand Down Expand Up @@ -299,7 +301,6 @@ project("${rootProject.name}-app") {

docker {
name = rootProject.name
tags += project.getDockerTags()
}

task copyLibraries(type: Sync) {
Expand Down Expand Up @@ -407,13 +408,7 @@ project("${rootProject.name}-example-features") {
}


project("${rootProject.name}-mongo") {

docker {
tags += project.getDockerTags()
}

}
project("${rootProject.name}-mongo")


project("${rootProject.name}-e2e-tests") {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.zucchini.build.docker

import groovy.transform.PackageScope
import org.gradle.api.Project
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.Optional
Expand All @@ -17,7 +16,6 @@ class DockerComposeExtension {
}

void environment(String name, String value) {
System.stdout.println("Adding ${name} with value ${value}");
env.put(name, value)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,26 @@ class DockerExtension {

String name

String repository
@Input
@Optional
List<String> repositories = []

@Input
@Optional
List<String> tags = []

DockerExtension(Project project) {
repository = project.properties['docker.baseRepository']
name = project.name
tags << (project.version as String)
}

void tag(String tag) {
tags << tag
}

@PackageScope
List<String> getFullTags() {
String fullName = repository == null ? name : "${repository}/${name}"
return tags.collect { "${fullName}:${it}" }
return repositories
.collect { repository ->
tags.collect { tag -> "$repository/${name}:$tag" }
}
.flatten()
}

}
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ version: "3"
services:

mongo:
image: "pgentile/zucchini-ui-mongo:${ZUCCHINI_VERSION:-latest}"
image: "ghcr.io/pgentile/zucchini-ui-mongo:${ZUCCHINI_VERSION:-latest}"
ports:
- "27017:27017"
networks:
- mongo

zucchini-ui:
image: "pgentile/zucchini-ui:${ZUCCHINI_VERSION:-latest}"
image: "ghcr.io/pgentile/zucchini-ui:${ZUCCHINI_VERSION:-latest}"
ports:
- "8080:8080"
- "8081:8081"
Expand Down
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
version = 0.0.6-SNAPSHOT

docker.baseRepository = pgentile
docker.baseRepository = ghcr.io/pgentile
docker.publishRepository = pgentile
6 changes: 3 additions & 3 deletions zucchini-ui-frontend/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3427,9 +3427,9 @@ dns-equal@^1.0.0:
integrity sha1-s55/HabrCnW6nBcySzR1PEfgZU0=

dns-packet@^5.2.2:
version "5.3.1"
resolved "https://registry.yarnpkg.com/dns-packet/-/dns-packet-5.3.1.tgz#eb94413789daec0f0ebe2fcc230bdc9d7c91b43d"
integrity sha512-spBwIj0TK0Ey3666GwIdWVfUpLyubpU53BTCu8iPn4r4oXd9O14Hjg3EHw3ts2oed77/SeckunUYCyRlSngqHw==
version "5.4.0"
resolved "https://registry.yarnpkg.com/dns-packet/-/dns-packet-5.4.0.tgz#1f88477cf9f27e78a213fb6d118ae38e759a879b"
integrity sha512-EgqGeaBB8hLiHLZtp/IbaDQTL8pZ0+IvwzSHA6d7VyMDM+B9hgddEMa9xjK5oYnw0ci0JQ6g2XCD7/f6cafU6g==
dependencies:
"@leichtgewicht/ip-codec" "^2.0.1"

Expand Down