jekyll-docker
jekyll-docker copied to clipboard
"remove intermediate images" deletes build results
I'm using the jekyll/jekyll
image as a build stage in a multistage Dockerfile. When I use it like this, I'm running in an error:
# Jekyll build
#
FROM jekyll/jekyll:3.8.6 as builder
ENV TZ=Europe/Berlin \
JEKYLL_ENV=production
RUN apk --no-cache add imagemagick
WORKDIR /srv/jekyll
COPY Gemfile* /srv/jekyll/
RUN bundle update
COPY _config.yml /srv/jekyll
COPY source /srv/jekyll/source
RUN jekyll build
# nginx runtime
#
FROM nginx:alpine
RUN rm -rf /usr/share/nginx/html/*
COPY --from=builder /srv/jekyll/_site/ /usr/share/nginx/html
The last RUN
statement of jekyll will eventuall build the site and write it into /srv/jekyll/_site
but afterwards the Docker log reads this image has been removed as intermediate. The subsequent COPY
in the Nginx layer doesn't find the files.
However, if I create a separate directory (say: /site
) along with appropriate permissions, things go well. This will work:
# Jekyll build
#
FROM jekyll/jekyll:3.8.6 as builder
ENV TZ=Europe/Berlin \
JEKYLL_ENV=production
RUN apk --no-cache add imagemagick
RUN mkdir /site; \
chown -R jekyll:jekyll /site
WORKDIR /site
COPY Gemfile* /site/
RUN bundle update
COPY _config.yml /site
COPY source /site/source
RUN jekyll build
# nginx runtime
#
FROM nginx:alpine
RUN rm -rf /usr/share/nginx/html/*
COPY --from=builder /site/_site/ /usr/share/nginx/html
I suspect this is because /srv/jekyll
is declared as a volume, but I'm not sure. It does limit the usability of the image. Or am I using it wrong?
I have the same problem. Webrick cannot be produced. How to add a server that can be produced. Is there an example of using dockerfile