# 2023-11-12 ## LINKS: ## ## https://github.com/Artanicus/simple-jekyll/ ## ## HOWTO: ## debug image with local bash session: ## ## sudo docker run -it --entrypoint bash zogg/jekyll:latest ## # -------------------------------------------------- # Intermediary Build # -------------------------------------------------- FROM ruby:alpine as build # Arguments from Docker build ARG TARGETPLATFORM ARG TARGETOS ARG TARGETARCH ARG BUILDPLATFORM ARG BUILDOS ARG BUILDARCH ARG BUILDVARIANT ARG CONCURRENCY # Define Ruby & Jekyll version (to use) ARG JEKYLL_VERSION=4.3.2 ENV RUBY_MAJOR 3.2 ENV RUBY_VERSION 3.2.2 # If we want to use Snapshot release # set to 1 to use snapshot, otherwise set to 0 # snapshot version is 'x_y' and not 'x.y' ENV RUBY_SNAPSHOT 1 ENV RUBY_SH_VERSION 3_2 ENV RUBY_VERSION 3.2.snapshot # If you want to stay 'stable', comment the 3 lines above # # Jekyll ENV ENV LANG C.UTF-8 ENV BUNDLE_SILENCE_ROOT_WARNING 1 ENV GEM_HOME /usr/local/bundle ENV GEM_PATH /usr/local/bundle ENV GEM_BIN /usr/local/bundle/bin ENV BUNDLE_HOME /usr/local/bundle ENV BUNDLE_APP_CONFIG /usr/local/bundle ENV BUNDLE_BIN /usr/local/bundle/bin ENV JEKYLL_VAR_DIR /var/jekyll ENV JEKYLL_DATA_DIR /srv/jekyll ENV JEKYLL_BIN /usr/jekyll/bin ENV JEKYLL_ENV development ENV RUBYOPT -W0 ENV PATH /usr/local/bundle/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin # ### ############################## ### Prepare system ### ############################## CMD ["/bin/sh"] RUN set -eux \ && mkdir -p /usr/local/etc \ && { echo 'install: --no-document'; echo 'update: --no-document'; } >> /usr/local/etc/gemrc RUN set -eux \ && apk add --no-cache \ bzip2 \ ca-certificates \ gmp-dev \ libffi-dev \ procps \ yaml-dev \ zlib-dev RUN set -eux \ && apk add --no-cache --virtual \ .ruby-builddeps \ autoconf \ bison \ bzip2 \ bzip2-dev \ ca-certificates \ coreutils \ dpkg-dev \ dpkg \ g++ \ gcc \ gdbm-dev \ glib-dev \ libc-dev \ libffi-dev \ libxml2-dev \ libxslt-dev \ linux-headers \ make \ ncurses-dev \ openssl \ openssl-dev \ patch \ procps \ readline-dev \ ruby \ tar \ xz \ yaml-dev \ zlib-dev # Install patched Ruby COPY files/ruby.sh /tmp/ RUN chmod +x /tmp/ruby.sh && /bin/sh /tmp/ruby.sh # Display Ruby/Gem/bundle versions RUN [ "$(command -v ruby)" = '/usr/local/bin/ruby' ]; ruby --version \ && gem --version \ && bundle --version # Packages needed build & to get needed gems built RUN apk --no-cache add \ zlib-dev \ libffi-dev \ build-base \ libxml2-dev \ imagemagick-dev \ readline-dev \ libxslt-dev \ libffi-dev \ yaml-dev \ zlib-dev \ vips-dev \ vips-tools \ sqlite-dev \ cmake \ linux-headers \ openjdk8-jre \ less \ zlib \ libxml2 \ readline \ libxslt \ libffi \ git \ nodejs \ tzdata \ shadow \ bash \ su-exec \ npm \ libressl \ yarn \ \ build-base \ vips \ vips-heif \ vips-jxl \ vips-magick \ vips-poppler \ vips-tools \ musl \ exiftool \ libgsf \ gobject-introspection \ jpegoptim \ oxipng \ libjpeg \ libexif \ librsvg \ cgif \ libarchive \ libspng \ libimagequant \ highway \ libwebp \ openjpeg \ libjxl \ libheif \ imagemagick \ imagemagick-libs \ libmagic \ file \ file-dev RUN mkdir -p $GEM_HOME \ && chmod 777 $GEM_HOME CMD ["irb"] ### ############################## # Define environement variables ENV LANG en_US.UTF-8 ENV LANGUAGE en_US:en ENV TZ UTC ENV LC_ALL en_US.UTF-8 ENV LAN en_US.UTF-8 ENV LANGUAGE en_US # Upgrade packages RUN apk update \ && apk upgrade --available # Explicitly default to 1000:1000 ENV JEKYLL_UID 1000 ENV JEKYLL_GID 1000 # Create Jekyll user/group & setup directories RUN addgroup -Sg $JEKYLL_UID jekyll \ && adduser -Su $JEKYLL_GID -G jekyll jekyll \ && mkdir -p $JEKYLL_VAR_DIR && chown -R jekyll:jekyll $JEKYLL_VAR_DIR \ && mkdir -p $JEKYLL_DATA_DIR && chown -R jekyll:jekyll $JEKYLL_DATA_DIR \ && chown -R jekyll:jekyll $BUNDLE_HOME # Update gems RUN echo "gem: --no-ri --no-rdoc" > ~/.gemrc \ && bundle config set --local system 'true' \ && gem update --system # Install requested Gems RUN gem install \ bundler \ rake \ jekyll:$JEKYLL_VERSION \ -- \ --use-system-libraries \ --install-dir $GEM_HOME \ --bindir $GEM_BIN \ && gem update --system # Add Docker entry point COPY files/entrypoint.sh /usr/jekyll/bin/entrypoint RUN chmod +x /usr/jekyll/bin/entrypoint # Create Gem Bundle Cache RUN mkdir -p /usr/gem/cache/bundle \ && chown -R jekyll:jekyll /usr/gem/cache/bundle # -------------------------------------------------- # Final Docker Image # -------------------------------------------------- FROM ruby:alpine # Redo versions from build ENV JEKYLL_VERSION 4.3.2 ENV RUBY_MAJOR 3.2 ENV RUBY_VERSION 3.2.2 ENV RUBY_VERSION 3.2.snapshot # Redo settings from build ENV JEKYLL_DOCKER_TAG $JEKYLL_VERSION ENV BUNDLE_SILENCE_ROOT_WARNING 1 ENV GEM_HOME /usr/local/bundle ENV GEM_PATH /usr/local/bundle ENV GEM_BIN /usr/local/bundle/bin ENV BUNDLE_HOME /usr/local/bundle ENV BUNDLE_APP_CONFIG /usr/local/bundle ENV BUNDLE_BIN /usr/local/bundle/bin ENV JEKYLL_VAR_DIR /var/jekyll ENV JEKYLL_DATA_DIR /srv/jekyll ENV JEKYLL_BIN /usr/jekyll/bin ENV JEKYLL_ENV development ENV RUBYOPT -W0 ENV PATH /usr/local/bundle/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin ENV LANG en_US.UTF-8 ENV LANGUAGE en_US:en ENV TZ UTC ENV LC_ALL en_US.UTF-8 ENV LAN en_US.UTF-8 ENV LANGUAGE en_US ENV JEKYLL_UID 1000 ENV JEKYLL_GID 1000 # Copy files from the build stage COPY --from=build /usr/local /usr/local/ COPY --from=build /var/jekyll /var/jekyll/ COPY --from=build /srv/jekyll /srv/jekyll/ COPY --from=build /usr/jekyll /usr/jekyll/ # Redo packages installation RUN apk --no-cache add \ bzip2 \ ca-certificates \ procps \ bison \ coreutils \ dpkg \ g++ \ gcc \ make \ openssl \ patch \ ruby \ tar \ xz \ vips-tools \ cmake \ linux-headers \ openjdk8-jre \ less \ zlib \ libxml2 \ readline \ libxslt \ libffi \ git \ nodejs \ tzdata \ shadow \ bash \ su-exec \ npm \ libressl \ yarn \ git \ \ build-base \ vips \ vips-heif \ vips-jxl \ vips-magick \ vips-poppler \ vips-tools \ musl \ exiftool \ libgsf \ gobject-introspection \ jpegoptim \ oxipng \ libjpeg \ libexif \ librsvg \ cgif \ libarchive \ libspng \ libimagequant \ highway \ libwebp \ openjpeg \ libjxl \ libheif \ imagemagick \ imagemagick-libs \ libmagic \ file \ file-dev # Redo Jekyll user/group creation RUN addgroup -Sg $JEKYLL_UID jekyll \ && adduser -Su $JEKYLL_GID -G jekyll jekyll # Add Git Safe Directory RUN git config --global --add safe.directory /srv/jekyll # Disable Watchtower image check LABEL com.centurylinklabs.watchtower.enable false # Enable DIUN image check LABEL diun.enable true # Define author's informations LABEL org.opencontainers.image.title "Jekyll Special Edition" LABEL author "Olivier Le Bris" LABEL maintainer "tech@zogg.fr" LABEL org.opencontainers.image.source "https://zogg.fr" LABEL org.opencontainers.image.licenses MIT # Setup necessary context USER jekyll WORKDIR /srv/jekyll VOLUME /srv/jekyll EXPOSE 35729 EXPOSE 4000 # Run entrypoint CMD ["jekyll", "--help"] ENTRYPOINT ["/usr/jekyll/bin/entrypoint"]