From 78019eda50cfc1705213b5d499db040c0ff30df2 Mon Sep 17 00:00:00 2001 From: Amir Pourmand Date: Mon, 31 Oct 2022 18:57:43 +0330 Subject: [PATCH] Add Docker-compose file for windows compatibility (#875) This file makes it easier for windows users to use docker. (Closes #829) Previous to this commit, those who used Windows had to install Ubuntu inside windows (via WSL) and run our commands. Now they can run it by just typing `docker-compose up`. > The main problem was that `./bin/dockerhub_run.sh` command was written with `Bash` in mind and you had to change it a little bit to make it compatible with windows `Powershell`. We shouldn't have two scripts. This is why adding a `docker-compose.yml` file is necessary. --- README.md | 14 +++++++------- bin/docker_run.sh | 3 ++- bin/dockerhub_run.sh | 3 ++- docker-compose.yml | 12 ++++++++++++ docker-local.yml | 12 ++++++++++++ 5 files changed, 35 insertions(+), 9 deletions(-) create mode 100644 docker-compose.yml create mode 100644 docker-local.yml diff --git a/README.md b/README.md index 463d3b6844cc..f23b43754c6f 100644 --- a/README.md +++ b/README.md @@ -167,7 +167,7 @@ For a hands-on walkthrough of al-folio installation, check out [this cool video You need to take the following steps to get `al-folio` up and running in your local machine: -- First, [install docker](https://docs.docker.com/get-docker/) +- First, install [docker](https://docs.docker.com/get-docker/) and [docker-compose](https://docs.docker.com/compose/install/). - Then, clone this repository to your machine: ```bash @@ -178,12 +178,12 @@ $ cd Finally, run the following command that will pull a pre-built image from DockerHub and will run your website. ```bash -$ ./bin/dockerhub_run.sh +$ docker-compose up ``` Note that when you run it for the first time, it will download a docker image of size 300MB 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 (`bin/dockerhub_run.sh`) 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.
(click to expand) Build your own docker image (more advanced): @@ -193,18 +193,18 @@ First, download the necessary modules and install them into a docker image calle ```bash -$ ./bin/docker_build_image.sh +$ docker-compose -f docker-local.yml build ``` Run the website! ```bash -$ ./bin/docker_run.sh +$ docker-compose -f docker-local.yml up ``` -> To change port number, you can edit `docker_run.sh` file. +> To change port number, you can edit `docker-compose.yml` file. -> If you want to update jekyll, install new ruby packages, etc., all you have to do is build the image again using `docker_build_image.sh`! It will download ruby and jekyll and install all ruby packages again from scratch. +> If you want to update jekyll, install new ruby packages, etc., all you have to do is build the image again! It will download ruby and jekyll and install all ruby packages again from scratch.
diff --git a/bin/docker_run.sh b/bin/docker_run.sh index a59a44ba2383..9c3d3d8a0abb 100755 --- a/bin/docker_run.sh +++ b/bin/docker_run.sh @@ -4,4 +4,5 @@ if [ -f "$FILE" ]; then fi docker run --rm -v "$PWD:/srv/jekyll/" -p "8080:8080" \ -it al-folio:latest bundler \ - exec jekyll serve --watch --port=8080 --host=0.0.0.0 \ No newline at end of file + exec jekyll serve --watch --port=8080 --host=0.0.0.0 \ + --verbose --livereload \ No newline at end of file diff --git a/bin/dockerhub_run.sh b/bin/dockerhub_run.sh index 7054e9914f2e..ac6a14e9ef2f 100755 --- a/bin/dockerhub_run.sh +++ b/bin/dockerhub_run.sh @@ -4,4 +4,5 @@ if [ -f "$FILE" ]; then fi docker run --rm -v "$PWD:/srv/jekyll/" -p "8080:8080" \ -it amirpourmand/al-folio bundler \ - exec jekyll serve --watch --port=8080 --host=0.0.0.0 + exec jekyll serve --watch --port=8080 --host=0.0.0.0 \ + --verbose --livereload diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000000..260720135dee --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,12 @@ +version: "3" +# this file uses prebuilt image in dockerhub +services: + jekyll: + image: amirpourmand/al-folio + command: bash -c " + rm -f Gemfile.lock + && bundler exec jekyll serve --watch --port=8080 --host=0.0.0.0 --livereload --verbose" + ports: + - 8080:8080 + volumes: + - .:/srv/jekyll \ No newline at end of file diff --git a/docker-local.yml b/docker-local.yml new file mode 100644 index 000000000000..246bb2eadc9a --- /dev/null +++ b/docker-local.yml @@ -0,0 +1,12 @@ +version: "3" + +services: + jekyll_custom: + build: . + command: bash -c " + rm -f Gemfile.lock + && bundler exec jekyll serve --watch --port=8080 --host=0.0.0.0 --livereload --verbose" + ports: + - 8080:8080 + volumes: + - .:/srv/jekyll \ No newline at end of file