From 17eff1c5004ad1d84d2369414fc02d1e20c7da0c Mon Sep 17 00:00:00 2001 From: Nicolas Le Cam Date: Sun, 9 Jun 2019 00:35:17 +0200 Subject: [PATCH 1/2] allow running commands inside the container use the same technique as the one in the official Node.js image --- Dockerfile | 5 ++++- README.adoc | 33 ++------------------------------- docker-entrypoint.sh | 8 ++++++++ 3 files changed, 14 insertions(+), 32 deletions(-) create mode 100755 docker-entrypoint.sh diff --git a/Dockerfile b/Dockerfile index dae4540..e431257 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,4 +15,7 @@ RUN yarn global add --ignore-optional --silent @antora/cli@latest @antora/site-g WORKDIR /antora -ENTRYPOINT [ "antora" ] +COPY docker-entrypoint.sh /usr/local/bin/ +ENTRYPOINT ["docker-entrypoint.sh"] + +CMD ["antora"] diff --git a/README.adoc b/README.adoc index de2b41a..e3a7403 100644 --- a/README.adoc +++ b/README.adoc @@ -65,41 +65,12 @@ You can fix this problem by setting the cache dir explicitly when running Antora antora/antora --stacktrace --cache-dir=./.cache site.yml ==== -If you want to shell into the container, set the `--entrypoint` option as follows: +If you want to shell into the container, use the following command: - $ docker run --entrypoint ash --privileged -v `pwd`:/antora --rm -it antora/antora + $ docker run --privileged -v `pwd`:/antora --rm -it antora/antora ash This command allows you to use the `antora` command inside the running container (but still generate files to the local filesystem). -[#gitlab-ci-image] -=== Use the image in GitLab CI - -If you attempt to use this image as the base image in GitLab CI, you'll likely encounter the following error message (just after the `Skipping Git submodules setup` line in the log): - - error: unknown option `-c' - -This happens because this image defines the `antora` command as the default entrypoint rather than a shell command. -In order to use this image as the base image in GitLab CI, you'll need to override the entrypoint to be a shell command as GitLab CI expects. - -To override the entrypoint in a way that's compatible with GitLab CI, define the image in `.gitlab-ci.yml` as follows: - -[source,yaml] ----- -image: - name: antora/antora - entrypoint: [/bin/sh, -c] ----- - -Now you'll be able to invoke the `antora` command from a script clause in `.gitlab-ci.yml` as follows: - -[source,yaml] ----- - script: - - antora site.yml ----- - -This is similar to how we shelled into the container by passing the `--entrypoint` option in the previous section. - [#extend-image] === Use as a Base Image diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100755 index 0000000..b670d13 --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,8 @@ +#!/bin/sh +set -e + +if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ]; then + set -- antora "$@" +fi + +exec "$@" -- GitLab From 8db95f069937acb2087837fc64a574c819d43169 Mon Sep 17 00:00:00 2001 From: Dan Allen Date: Sun, 25 Aug 2019 17:03:47 -0600 Subject: [PATCH 2/2] revise entrypoint change * add comments to entrypoint script * use more concise checks to determine if command was specified * restore GitLab CI section in README, but clarify the images works without modification * revise comments in README --- Dockerfile | 1 + README.adoc | 31 +++++++++++++++++++++++++++---- docker-entrypoint.sh | 5 ++++- 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index e431257..1ebf0e3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,6 +16,7 @@ RUN yarn global add --ignore-optional --silent @antora/cli@latest @antora/site-g WORKDIR /antora COPY docker-entrypoint.sh /usr/local/bin/ + ENTRYPOINT ["docker-entrypoint.sh"] CMD ["antora"] diff --git a/README.adoc b/README.adoc index e3a7403..35e783b 100644 --- a/README.adoc +++ b/README.adoc @@ -1,4 +1,4 @@ -= Docker Image for Antora += Docker Image for Antora :uri-antora: https://antora.org :uri-asciidoctor: https://asciidoctor.org :uri-license: https://www.mozilla.org/en-US/MPL/2.0/ @@ -32,7 +32,8 @@ If you want to help improve this image, you should learn how to <