Skip to content

Commit

Permalink
Add Reload to Docker (Automatic Reload of Changes to _config.yaml) (a…
Browse files Browse the repository at this point in the history
  • Loading branch information
pourmand1376 committed Oct 7, 2023
1 parent ac9bbae commit adc55d6
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 36 deletions.
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ RUN apt-get update -y && apt-get install -y --no-install-recommends \
ruby-full \
build-essential \
zlib1g-dev \
jupyter-nbconvert && \
jupyter-nbconvert \
inotify-tools procps && \
apt-get clean && rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/*


RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && \
locale-gen


ENV LANG=en_US.UTF-8 \
LANGUAGE=en_US:en \
LC_ALL=en_US.UTF-8 \
Expand All @@ -33,4 +36,4 @@ RUN bundle install --no-cache
# && rm -rf /var/lib/gems/3.1.0/cache
EXPOSE 8080

CMD ["/bin/bash", "-c", "rm -f Gemfile.lock && exec jekyll serve --watch --port=8080 --host=0.0.0.0 --livereload --verbose --trace"]
CMD ["./bin/entry_point.sh"]
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,12 @@ You need to take the following steps to get `al-folio` up and running on your lo
- Finally, run the following command that will pull the latest pre-built image from DockerHub and will run your website.

```bash
$ docker-compose up
$ docker compose up
```

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

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.
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.

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

```bash
$ docker-compose -f docker-local.yml up
$ docker compose up --build
```

> 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.
Expand Down
5 changes: 0 additions & 5 deletions bin/docker_build_image.sh

This file was deleted.

8 changes: 0 additions & 8 deletions bin/docker_run.sh

This file was deleted.

8 changes: 0 additions & 8 deletions bin/dockerhub_run.sh

This file was deleted.

22 changes: 22 additions & 0 deletions bin/entry_point.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

CONFIG_FILE=_config.yml

/bin/bash -c "rm -f Gemfile.lock && exec jekyll serve --watch --port=8080 --host=0.0.0.0 --livereload --verbose --trace --force_polling"&

while true; do

inotifywait -q -e modify,move,create,delete $CONFIG_FILE

if [ $? -eq 0 ]; then

echo "Change detected to $CONFIG_FILE, restarting Jekyll"

jekyll_pid=$(pgrep -f jekyll)
kill -KILL $jekyll_pid

/bin/bash -c "rm -f Gemfile.lock && exec jekyll serve --watch --port=8080 --host=0.0.0.0 --livereload --verbose --trace --force_polling"&

fi

done
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ version: "3"
services:
jekyll:
image: amirpourmand/al-folio
build: .
ports:
- 8080:8080
volumes:
Expand Down
10 changes: 0 additions & 10 deletions docker-local.yml

This file was deleted.

0 comments on commit adc55d6

Please sign in to comment.