Skip to content

Commit c0bc95c

Browse files
authored
Add Reload to Docker (Automatic Reload of Changes to _config.yaml) (alshedivat#1702)
- alshedivat#1640
1 parent dc3289d commit c0bc95c

8 files changed

+31
-36
lines changed

Dockerfile

+5-2
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@ RUN apt-get update -y && apt-get install -y --no-install-recommends \
99
ruby-full \
1010
build-essential \
1111
zlib1g-dev \
12-
jupyter-nbconvert && \
12+
jupyter-nbconvert \
13+
inotify-tools procps && \
1314
apt-get clean && rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/*
1415

16+
1517
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && \
1618
locale-gen
1719

20+
1821
ENV LANG=en_US.UTF-8 \
1922
LANGUAGE=en_US:en \
2023
LC_ALL=en_US.UTF-8 \
@@ -33,4 +36,4 @@ RUN bundle install --no-cache
3336
# && rm -rf /var/lib/gems/3.1.0/cache
3437
EXPOSE 8080
3538

36-
CMD ["/bin/bash", "-c", "rm -f Gemfile.lock && exec jekyll serve --watch --port=8080 --host=0.0.0.0 --livereload --verbose --trace"]
39+
CMD ["./bin/entry_point.sh"]

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -227,12 +227,12 @@ You need to take the following steps to get `al-folio` up and running on your lo
227227
- Finally, run the following command that will pull the latest pre-built image from DockerHub and will run your website.
228228

229229
```bash
230-
$ docker-compose up
230+
$ docker compose up
231231
```
232232

233233
Note that when you run it for the first time, it will download a docker image of size 400MB or so.
234234

235-
Now, feel free to customize the theme however you like (don't forget to change the name!). After you are done, you can use the same command (`docker-compose up`) to render the webpage with all you changes. Also, make sure to commit your final changes.
235+
Now, feel free to customize the theme however you like (don't forget to change the name!). After you are done, you can use the same command (`docker compose up`) to render the webpage with all you changes. Also, make sure to commit your final changes.
236236

237237
> To change port number, you can edit `docker-compose.yml` file.
238238
@@ -243,7 +243,7 @@ Now, feel free to customize the theme however you like (don't forget to change t
243243
Build and run a new docker image using:
244244

245245
```bash
246-
$ docker-compose -f docker-local.yml up
246+
$ docker compose up --build
247247
```
248248

249249
> If you want to update jekyll, install new ruby packages, etc., all you have to do is build the image again using `--force-recreate` argument at the end of previous command! It will download ruby and jekyll and install all ruby packages again from scratch.

bin/docker_build_image.sh

-5
This file was deleted.

bin/docker_run.sh

-8
This file was deleted.

bin/dockerhub_run.sh

-8
This file was deleted.

bin/entry_point.sh

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
CONFIG_FILE=_config.yml
4+
5+
/bin/bash -c "rm -f Gemfile.lock && exec jekyll serve --watch --port=8080 --host=0.0.0.0 --livereload --verbose --trace --force_polling"&
6+
7+
while true; do
8+
9+
inotifywait -q -e modify,move,create,delete $CONFIG_FILE
10+
11+
if [ $? -eq 0 ]; then
12+
13+
echo "Change detected to $CONFIG_FILE, restarting Jekyll"
14+
15+
jekyll_pid=$(pgrep -f jekyll)
16+
kill -KILL $jekyll_pid
17+
18+
/bin/bash -c "rm -f Gemfile.lock && exec jekyll serve --watch --port=8080 --host=0.0.0.0 --livereload --verbose --trace --force_polling"&
19+
20+
fi
21+
22+
done

docker-compose.yml

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ version: "3"
33
services:
44
jekyll:
55
image: amirpourmand/al-folio
6+
build: .
67
ports:
78
- 8080:8080
89
volumes:

docker-local.yml

-10
This file was deleted.

0 commit comments

Comments
 (0)