Post

Image Docker Jekyll

Cette image est directement compatible avec le thème Jejyll Chirpy.

Précisions

Afin de construire une image Docker fonctionnelle, j’ai du un peu dépiler les étapes de la construction de l’image officielle sur le hub.

Introduction

La dernière mise à jour de l’image Jekyll (hub Docker) datant d’un an maitenant, il a fallut que je construise une image à jour pour mes propres besoins.

Il est nécessaire d’avoir installé au préalable Docker.

Pour construire une image Docker compatible AMD64 vous aurez besoin de ces fichiers :

  • common-build-system.sh
  • build.sh
  • ruby.sh
  • Dockerfile
  • entrypoint.sh

Fichiers requis

common-build-system.sh

[Fichier]

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/bin/bash
doBuildSystem() {
	echo "v2023-09-01"
}

# Compute images informations
LOGFILE=cbslog.log
BASE=$OWNER/$NAME
LATEST=${BASE}:latest

# Cleanup log file
if [ -f $LOGFILE ]; then
    rm -rf $LOGFILE
    touch $LOGFILE
fi

# Display introduction
doIntro() {
	echo "Docker Image Build: $HOSTNAME"
	doBuildSystem
	echo
}

# Prepare for cross compile
doPrepareCrossCompile() {
    echo "> Prepare for cross compile"
    export DOCKER_DEFAULT_PLATFORM=$1
    export DOCKER_CLI_EXPERIMENTAL=enabled
}

# Cross-platform emulator collection distributed with Docker images
doBinFMT() {
    echo "> Perform cross-platform setup"
    docker run --privileged --rm tonistiigi/binfmt:latest --install all
}

# Add a Tag to image
doDockerTag() {
    TAG=$1
    echo "> Add [$TAG] tag to image for registry [$REGISTRY]"
    docker tag ${BASE} ${REGISTRY}/${BASE}:${TAG}
    if [ $? -eq 0 ]; then
        echo " * tag done!"
    else
        echo " * tag failed!"
    fi
}

# Push to registry
doRegistryPush() {
    echo "> Push [$BASE] image to [$REGISTRY]"
    docker image push --all-tags ${REGISTRY}/${BASE}
}

# Build Docker image
doBuild() {
    PLATFORM="${1:=linux/amd64}"
    IMAGE=$2
    CACHING=$3
    echo "> Build image: [$IMAGE] for [$PLATFORM] ($CACHING)"
    docker buildx build \
        $CACHING \
        --network host \
        --compress \
        --output=type=docker \
        --pull \
        --build-arg CONCURRENCY=$(nproc) \
        --platform=${PLATFORM} \
        -t "${IMAGE}" \
        . 2>&1
}
doBuildCache() {
    doBuild $1 $2 ""
}
doBuildNoCache() {
    doBuild $1 $2 "--no-cache"
}

# Perform 'failed' action
doFailed() {
    echo "* failed!"
    exit 1
}

# Perform 'done' action
doDone() {
    echo "* done."
}

if [ "$(id -u)" != "0" ]; then
    doIntro
    echo "This script must be run as root" 1>&2
    echo
    exit 1
fi

clear
cd $CWD || exit 1

# Show introduction
doIntro

doPerformAll() {
    # Perform cross-compile tasks
    doBinFMT
    if [ $? -ne 0 ]; then
        doFailed
    else
        doDone
    fi

    # Perform image build
    if [ $CACHE == true ]; then
        doBuildCache "${OS}" "$LATEST"
    else
        doBuildNoCache "${OS}" "$LATEST"
    fi
    if [ $? -ne 0 ]; then
        doFailed
    else
        doDone
    fi

    # Perform image tagging
    doDockerTag "latest"
    if [ $? -ne 0 ]; then
        doFailed
    else
        doDone
    fi

    # Perform push ro registry
    doRegistryPush
    if [ $? -ne 0 ]; then
        doFailed
    else
        doDone
    fi
}

doPerformAll | tee $LOGFILE
sync

echo "> Finished!"

exit 0

build.sh

[Fichier]

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/bash
# 2023-11-12

# Image informations
OWNER=zogg
NAME=jekyll
REGISTRY=registry.zogg.fr
OS="linux/amd64"
#CACHE=false
CACHE=true

# Build the image
HOSTNAME=$(hostname)
SELF=$(realpath $0)
SCRIPT=$(basename $SELF)
CWD=$(dirname $SELF)
cd $CWD
source ../_common/common-build-system.sh

files/ruby.sh

[Fichier]

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/sh
# 2023-11-12

set -eux

# Select Ruby from stable or snapshot
if [ "$RUBY_SNAPSHOT" == "1" ]; then
    RUBY_DL="https://cache.ruby-lang.org/pub/ruby/snapshot/snapshot-ruby_${RUBY_SH_VERSION}.tar.xz";
else
    RUBY_DL="https://cache.ruby-lang.org/pub/ruby/${RUBY_MAJOR%-rc}/ruby-${RUBY_VERSION}.tar.xz";
fi

# Uncompress source files
mkdir -p /usr/src/ruby
wget -O ruby.tar.xz $RUBY_DL
tar -xJf ruby.tar.xz -C /usr/src/ruby --strip-components=1
rm ruby.tar.xz
cd /usr/src/ruby

# Apply patch to sources
wget -O 'thread-stack-fix.patch' 'https://bugs.ruby-lang.org/attachments/download/7081/0001-thread_pthread.c-make-get_main_stack-portable-on-lin.patch'
echo '3ab628a51d92fdf0d2b5835e93564857aea73e0c1de00313864a94a6255cb645 *thread-stack-fix.patch' | sha256sum --check --strict
patch -p1 -i thread-stack-fix.patch
rm thread-stack-fix.patch
export ac_cv_func_isnan=yes ac_cv_func_isinf=yes
{ echo '#define ENABLE_PATH_CHECK 0'; echo; cat file.c; } > file.c.new
mv file.c.new file.c

# Compile
autoconf
gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"
./configure --build="$gnuArch" --disable-install-doc --enable-shared
make -j "$(nproc)"
make install

# Install
runDeps="$( scanelf --needed --nobanner --format '%n#p' --recursive /usr/local | tr ',' '\n' | sort -u | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' 	)"
apk add --no-network --virtual .ruby-rundeps $runDeps
apk del --no-network .ruby-builddeps

# Cleanup & check for sucessfull build
cd /
rm -r /usr/src/ruby
if apk --no-network list --installed | grep -v '^[.]ruby-rundeps' | grep -i ruby; then exit 1; 	fi

exit 0

files/entrypoint.sh

[Fichier]

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash
# 2023-11-12

[ "$DEBUG" = "true" ] && set -x
set -e

#
# Running rootless means that we force Jekyll to run
# entirely as 'root'. This is substituted by the container
# to the uid of the actual user.
#
if [ "$JEKYLL_ROOTLESS" ]; then
  JEKYLL_UID=0
  JEKYLL_GID=0
fi

: ${JEKYLL_UID:=$(id -u jekyll)}
: ${JEKYLL_GID:=$(id -g jekyll)}
export JEKYLL_UID
export JEKYLL_GID

#
# Users can customize our UID's to fit their own so that
#   we don't have to chown constantly.  Well it's not like
#   we do so much of it (anymore) it's slow, but we do
#   change permissions which can result in some bad
#   behavior on OS X.
#
if [ "$JEKYLL_UID" != "0" ] && [ "$JEKYLL_UID" != "$(id -u jekyll)" ]; then
  usermod  -o -u "$JEKYLL_UID" jekyll
  groupmod -o -g "$JEKYLL_GID" jekyll
  chown_args=""

  [ "$FULL_CHOWN" ] && chown_args="-R"
  for d in "$JEKYLL_DATA_DIR" "$JEKYLL_VAR_DIR"; do
    chown $chown_args jekyll:jekyll "$d"
  done
fi

#
# Make sure JEKYLL matches the UID/GID
# This will most likely end up as 1
#
if [ "$JEKYLL_ROOTLESS" ]; then
  usermod  -o -u $JEKYLL_UID jekyll
  groupmod -o -g $JEKYLL_GID jekyll
fi

exec "$@"

Dockerfile

[Fichier]

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
# 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"]

Point d’attention

Concernant le fichier principale Dockerfile , il est important de prendre en compte les points suivants :

Ces variables sont à ajuster en fonction de la version de Jekyll que vous souhaitez :

  • JEKYLL_VERSION
  • RUBY_MAJOR
  • RUBY_VERSION

Ces variables sont à commenter si vous préférer rester sur la version stable de Ruby :

  • RUBY_SNAPSHOT
  • RUBY_SH_VERSION
  • RUBY_VERSION

Procédure

Pour lancer la construction de l’image, il suffit de donner au script shell build.sh les droits d’exécution puis de le lancer :

Attention, cette étape de construction peut s’avérer longue selon la puissance de votre machine.

1
sudo chmod +x build.sh && sudo bash build.sh

Cela vous permet de générer l’image Docker

Utilisation

Voici un exemple de fichier docker-compose.yml qui vous permet d’utiliser l’image ainsi générée :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
version: "3.0"

#
# updated: 2023-11-08
# stack:   jekyll
#

networks:
  jekyll:
    name: jekyll
    driver: bridge
    enable_ipv6: true

services:

  jekyll:
    extends:
      file: ../_vm/common.yml
      service: x-common
    user: 0:0
    cap_add:
      - CHOWN
      - DAC_OVERRIDE
      - FOWNER
      - FSETID
      - SETGID
      - SETUID
      - NET_BIND_SERVICE
      - MKNOD
    container_name: jekyll
    hostname: jekyll
    image: zogg/jekyll:latest
    restart: always
    ports:
      - "${VM_PORT_JEKYLL}:4000"
      - "${VM_PORT_JEKYLLLIVERELOAD}:35729"
    expose:
      - "4000"
    networks:
      - jekyll
    healthcheck:
      test: wget --no-verbose --tries=1 --spider http://0.0.0.0:4000/ || exit 1
    environment:
      JEKYLL_UID: 1000
      JEKYLL_GID: 1000
      JEKYLL_ENV: production
    labels:
      com.stack.name: "jekyll"
      com.stack.service.name: "jekyll"
    #command: "bundle install"
    command: ["jekyll", "serve"]
    tmpfs:
      - /tmp:rw,noexec,nosuid,size=512M
    deploy:
      resources:
        limits:
          cpus: "8.0"
          memory: 1G
    volumes:
      - ./datas/jekyll:/srv/jekyll:rw
      - ./datas/_site:/srv/jekyll/_site:rw
      - ./datas/bundle:/usr/local/bundle:rw

Les points imporant à prendre en compte dans ce compose sont les suivants :

  • image : il s’agit du nom de l’image qu’on vient de générer
  • VM_PORT_JEKYLL : le port sur lequel le service Jekyll sera exposé
  • VM_PORT_JEKYLLLIVERELOAD : le port permettant le live reload de Jekyll en cas de modification (optionnel)

  • command : la première ligne sert à générer les fichiers du site, la seconde pour exécuter Jekyll afin d’ouvrir le site

  • /srv/jekyll : répertoire à monter contenant le contenu de Jekyll
  • /srv/jekyll/_site : répertoire contenant les fichiers générés pour l’affichage du site
  • /usr/local/bundle : répertoire contenant toutes les gem utilisées par le thème Jekyll choisit

Les autres parties sont spécifiques à mon utilisation des compose.

Pour que le site foncionne correctement, il est important d’ajouter dans le fichier _config.yml la partie -> host: 0.0.0.0

Bonus

Il convient de noter que la dernière image officielle de Jekyll fait 828.9 Mo et que l’image ainsi générée fait 789 Mo.

Nous avons donc là 40 Mo de gagnés sur l’image tout en bénéficiant d’une version enfin à jour !

Conclusion

Vous avez maintenant une image Docker compatible AMD64 à lancer sous Docker (ou avec Portainer :p).

Changelog

2023-11-12

  • Activation du cache pour Docker Buildx
  • Déport dans ruby.sh du code pour compiler Ruby
  • Suppression de l’installation des Gems
  • Ajout des paquets systèmes requis pour certaines Gems (jekyll-image, jekyll-webp, …)
Cet article est sous licence CC BY 4.0 par l'auteur.

© 2022- Olivier. Certains droits réservés.

Propulsé par τζ avec le thème Χ