Skip to content

Commit 98a29cf

Browse files
committed
Infer whether we need to publish Docker website port
Previously, users needed to explicitly specify and commandline parameter in order to correctly serve the website locally. This change inspects the task graph to see whether serving will be performed and automatically adds the port publishing.
1 parent 738f796 commit 98a29cf

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

website/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ run website tests.
3737

3838
The following command is used to build and serve the website locally.
3939

40-
$ ./gradlew -PpublishJekyllPort :beam-website:serveWebsite
40+
$ ./gradlew :beam-website:serveWebsite
4141

4242
Any changes made locally will trigger a rebuild of the website.
4343

website/build.gradle

+8-5
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,15 @@ task createDockerContainer(type: Exec) {
6464
ext.containerId = {
6565
return standardOutput.toString().trim()
6666
}
67-
def extraOptions = ''
68-
if (project.hasProperty('publishJekyllPort')) {
69-
extraOptions = '-p 127.0.0.1:4000:4000'
67+
gradle.taskGraph.whenReady {
68+
def extraOptions = ''
69+
if (gradle.taskGraph.hasTask(":${project.name}:serveWebsite")) {
70+
// Publish port 4000 where Jekyll serves website from
71+
extraOptions = '--publish 127.0.0.1:4000:4000'
72+
}
73+
commandLine '/bin/bash', '-c',
74+
"docker create -v $project.rootDir:$dockerWorkDir -u \$(id -u):\$(id -g) $extraOptions $dockerImageTag"
7075
}
71-
commandLine '/bin/bash', '-c',
72-
"docker create -v $project.rootDir:$dockerWorkDir -u \$(id -u):\$(id -g) $extraOptions $dockerImageTag"
7376
}
7477

7578
task startDockerContainer(type: Exec) {

0 commit comments

Comments
 (0)