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

Docker support #50

Merged
merged 6 commits into from
Dec 14, 2022
Merged
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
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build/
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# syntax=docker/dockerfile:1.4

#
# Build Stage
#

FROM gradle:6-jdk8 as builder

COPY --link . /app/gaiden
WORKDIR /app/gaiden
RUN --mount=type=cache,target=/home/gradle/.gradle,sharing=private \
gradle --no-daemon install

#
# Runtime Stage
#

FROM openjdk:8-alpine

COPY --link --from=builder /app/gaiden/build/install/gaiden /usr/local/gaiden
ENV PATH=/usr/local/gaiden/bin:${PATH} \
GAIDEN_WATCH_PORT=8080 \
GAIDEN_OUTPUT_DIR=build
WORKDIR /app
EXPOSE 8080
ENTRYPOINT ["gaiden"]
6 changes: 6 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,9 @@ apply from: "gradle/distribution.gradle"
apply from: "gradle/sample.gradle"
apply from: "gradle/sdkman.gradle"
apply from: "gradle/doc.gradle"

task buildDockerImage(type: Exec) {
group "build"
description "Build docker image."
commandLine "docker build -t kobo/gaiden:latest -t kobo/gaiden:${project.version} .".split(' ')
}
Binary file modified doc/gaiden-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 12 additions & 3 deletions gaiden-core/src/main/groovy/gaiden/GaidenConfig.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class GaidenConfig {
Path sourceDirectory = defaultProjectDirectory

/** The path of directory to be outputted a document */
Path outputDirectory = defaultProjectDirectory.resolve(DEFAULT_BUILD_DIRECTORY)
Path outputDirectory = defaultProjectDirectory.resolve(System.getenv("GAIDEN_OUTPUT_DIR") ?: DEFAULT_BUILD_DIRECTORY)

/** The base name of a zipped archive of HTML files */
String distFileName = DEFAULT_DIST_FILE_NAME
Expand Down Expand Up @@ -109,14 +109,13 @@ class GaidenConfig {

boolean readmeToIndex = true


List<String> assetTypes = ["jpg", "jpeg", "png", "gif"]

Map<String, Filter> filters = [:] as LinkedHashMap

SortedMap<String, Extension> extensions = new TreeMap<>()

int watchPort = 0
int watchPort = Integer.parseInt(System.getenv("GAIDEN_WATCH_PORT") ?: "0")

Path getApplicationInitialProjectTemplateDirectory() {
applicationDirectory.resolve(PROJECT_TEMPLATE_DIRECTORY)
Expand Down Expand Up @@ -193,6 +192,9 @@ class GaidenConfig {
}

void setOutputDirectoryPath(String outputDirectoryPath) {
if (System.getenv("GAIDEN_OUTPUT_DIR")) {
return // just ignored
}
outputDirectory = projectDirectory.resolve(outputDirectoryPath)
}

Expand All @@ -212,6 +214,13 @@ class GaidenConfig {
})
}

void setWatchPort(int watchPort) {
if (System.getenv("GAIDEN_WATCH_PORT")) {
return // just ignored
}
this.watchPort = watchPort
}

@PostConstruct
void initialize() {
loadExtensions(extensionsDirectory)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class WatchCommand extends AbstractCommand {
void execute(CommandLine commandLine) {
server = new EmbeddedHttpServer(gaidenConfig.watchPort, gaidenConfig.outputDirectory)
server.start()
println getMessage("command.watch.server.message", [server.port])

// At first, normally build a documentation.
build()
Expand Down
1 change: 1 addition & 0 deletions gaiden-core/src/main/resources/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ command.install.theme.overwrite.confirmation.message=Overwrite existing file {0}
command.install.theme.overwrite.invalid.answer.error=Must be one of [y/n/a]
command.install.theme.success.message=Installed the theme at {0}
command.wrapper.success.message=Installed wrapper files
command.watch.server.message=Web server is available at http://127.0.0.1:{0,number,#}/
command.watch.start.message=Watching {0}...
command.watch.found.message=Found {1} {0}
command.watch.rebuild.message=Rebuilding...
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading