Skip to content

Commit

Permalink
Merge pull request #681 from jonbullock/change/add-dockerfile
Browse files Browse the repository at this point in the history
Added Dockerfile and updated README
  • Loading branch information
jonbullock authored May 12, 2021
2 parents c4e174e + 4e787e3 commit 93685f1
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/build
/jbake-dist/build
.gradle
36 changes: 36 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
FROM gradle:6.8-jdk11 as builder

LABEL maintainer="https://jbake.org/community/team.html"

ENV JBAKE_HOME=/opt/jbake

RUN mkdir -p ${JBAKE_HOME}
COPY . /usr/src/jbake

RUN set -o errexit -o nounset \
&& echo "Building JBake" \
&& cd /usr/src/jbake \
&& gradle --no-daemon installDist \
&& cp -r jbake-dist/build/install/jbake/* $JBAKE_HOME \
&& rm -r ~/.gradle /usr/src/jbake

FROM adoptopenjdk/openjdk11:alpine-jre

ENV JBAKE_USER=jbake
ENV JBAKE_HOME=/opt/jbake
ENV PATH ${JBAKE_HOME}/bin:$PATH

RUN adduser -D -u 1000 -g "" ${JBAKE_USER} ${JBAKE_USER}

USER ${JBAKE_USER}

COPY --from=builder /opt/jbake /opt/jbake

WORKDIR /mnt/site

VOLUME ["/mnt/site"]

ENTRYPOINT ["jbake"]
CMD ["-b"]

EXPOSE 8820
37 changes: 37 additions & 0 deletions README.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,43 @@ Talk to other users of JBake on the forum:

* http://groups.google.com/group/jbake-user[Forum]

== Docker Image

The image uses the official https://hub.docker.com/r/adoptopenjdk/openjdk11/[adoptopenjdk/openjdk11:alpine] image
for building a distribution of JBake and
https://hub.docker.com/r/adoptopenjdk/openjdk11/[adoptopenjdk/openjdk11:alpine-jre] for runtime.

=== Build

To build the Docker image:

----
$ docker build -t jbake/jbake:latest .
----

=== Usage

To execute JBake via Docker run this from project directory:

----
$ docker run --rm -u jbake -v "$PWD":/mnt/site jbake/jbake:latest
----

This command will execute using the jbake user to avoid running as root and will mount the current working directory as `/mnt/site`
in the Docker container where JBake is expecting your project files to be. By default the Docker image will execute a bake `-b` only.

If you want to bake and serve your project using the Docker image then you'll need to override the default command:

----
$ docker run --rm -u jbake -v "$PWD":/mnt/site -p 8820:8820 jbake/jbake:latest -b -s
----

This command will also expose port 8820 from the container, you'll also need to set the following option in your `jbake.properties` file:

----
server.hostname=0.0.0.0
----

== Build System

The project uses http://gradle.org[Gradle] 4.9+ as the build system.
Expand Down

0 comments on commit 93685f1

Please sign in to comment.