|
1 | | -## Local Development |
| 1 | +# How to setup the project for local development |
2 | 2 |
|
3 | | -### Start Development Environment |
| 3 | +## I. Requirements |
4 | 4 |
|
5 | | -`docker run --rm -p 35729:35729 -p 4000:4000 -v "$PWD":/usr/src/app -w /usr/src/app ruby:3.2.2 bash -c "bundle config set --local path '/usr/src/app/vendor' && bundle install && bundle exec jekyll serve --livereload --host=0.0.0.0"` |
| 5 | +- You need docker installed on your computer |
| 6 | + - Link to [Docker Engine](https://docs.docker.com/engine/install/) |
| 7 | + - Link to [Docker Desktop (optional)](https://docs.docker.com/get-docker/) |
| 8 | + |
| 9 | +## II. Run the local development |
| 10 | + |
| 11 | +### Install all dependencies |
| 12 | + |
| 13 | +We use **docker** to *prevent version* and *system differences*. So please, especially if you are a mac user, use the docker container. |
| 14 | + |
| 15 | +#### Run this in your console to update your dependencies |
| 16 | + |
| 17 | +```bash |
| 18 | +docker run --rm -v "$PWD":/usr/src/app -w /usr/src/app ruby:3.2.2 bash -c "bundle config set --local path '/usr/src/app/vendor' && bundle install" |
| 19 | +``` |
| 20 | + |
| 21 | +### Start the live preview of the page |
| 22 | + |
| 23 | +**Note:** The **live reload** of jekyll is not perfect. Therefore, **don't expect** it to work as intended. Sometimes, you need to <u>re-run the command</u> in order to see the **newest changes**. |
| 24 | + |
| 25 | +#### Run this in your console to start the local preview |
| 26 | + |
| 27 | +```bash |
| 28 | +docker run --rm -p 35729:35729 -p 4000:4000 -v "$PWD":/usr/src/app -w /usr/src/app ruby:3.2.2 bash -c "bundle config set --local path '/usr/src/app/vendor' && bundle exec jekyll serve --livereload --host=0.0.0.0" |
| 29 | +``` |
| 30 | + |
| 31 | +## III. Troubleshooting |
| 32 | + |
| 33 | +If the live preview fails and you don't know the cause, follow these steps: |
| 34 | + |
| 35 | +1. You installed the dependencies in the past |
| 36 | + |
| 37 | + Chances are that the dependencies are not compatible if you once installed the dependencies a long time ago. |
| 38 | + |
| 39 | + Steps to fix it: |
| 40 | + - delete `vendor` folder |
| 41 | + - delete `Gemfile.lock` folder |
| 42 | + - re-install dependencies |
| 43 | + |
| 44 | +2. Your ports are already used by an other program |
| 45 | + |
| 46 | + If you are running another program that requires either **port 4000** or **port 35729**, the preview will fail. |
| 47 | + |
| 48 | + Steps to fix it: |
| 49 | + - either close the program(s) that need(s) the port(s) |
| 50 | + - or specify another port |
| 51 | + |
| 52 | + If you want to specify another port, append one of the args to the bash script that the docker container will run: |
| 53 | + |
| 54 | + - `--port [YOUR PORT]` (the port where the page is accessible at) |
| 55 | + - `--livereload-port [YOUR PORT]` (the port where the live reload script is accessible at) |
| 56 | + |
| 57 | + → append the arg(s) to the bash command: |
| 58 | + |
| 59 | + ```bash |
| 60 | + ... && bundle exec jekyll serve --livereload --host=0.0.0.0 --port=[PORT] --livereload-port=[PORT] |
| 61 | + ``` |
| 62 | + |
| 63 | +3. You decided not to run it in the docker container |
| 64 | + |
| 65 | + If you did, then please run it in the container. |
| 66 | + |
| 67 | +4. Other causes |
| 68 | + |
| 69 | + If you tried every troubleshooting method and none of them worked: We are sorry, but you need to find the error by your own. |
0 commit comments