Skip to content

Commit 86d7e78

Browse files
committed
Add a Docker-based setup.
I can't run Ruby 2.7.x on my machine anymore. Docker was the only solution I found. It may help others getting started to contribute to this website as well. The setup is basically copied from that of `scala-lang.org`, but with an additional setup of Node.js.
1 parent 7632d04 commit 86d7e78

File tree

3 files changed

+60
-3
lines changed

3 files changed

+60
-3
lines changed

Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM ruby:2.7.5
2+
3+
RUN apt install -y curl
4+
RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash -
5+
RUN apt install -y nodejs
6+
7+
RUN gem install bundler:2.3.10
8+
9+
WORKDIR /srv/jekyll
10+
11+
COPY Gemfile .
12+
COPY Gemfile.lock .
13+
14+
RUN echo -n "bundle version: " && bundle --version
15+
RUN chmod u+s /bin/chown
16+
RUN bundle install

README.md

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,35 @@ The key to contributing is being able to edit and
1212
preview your content. [Your pull requests are welcome](https://github.com/scala-js/scala-js-website/compare)!
1313

1414
## Set up
15+
16+
### With Docker
17+
18+
You need to have [Docker Engine](https://docs.docker.com/engine/) and [Docker Compose](https://docs.docker.com/compose/) installed on your machine.
19+
Under Mac OS (Intel or Apple silicon), instead of installing [Docker Desktop](https://docs.docker.com/desktop/) you can also use [HomeBrew](https://brew.sh/) with [Colima](https://github.com/abiosoft/colima): `brew install colima docker docker-compose`.
20+
UID and GID environment variables are needed to avoid docker from writing files as root in your directory.
21+
22+
```
23+
env UID="$(id -u)" GID="$(id -g)" docker-compose up
24+
```
25+
26+
On Linux you may have to prefix that command with `sudo`, depending on your Docker setup.
27+
28+
The generated site is available at `http://localhost:4000`.
29+
30+
When the website dependencies change (the content of the `Gemfile`), you have to re-build the Docker image:
31+
32+
```
33+
env UID="$(id -u)" GID="$(id -g)" docker-compose up --build
34+
```
35+
36+
If you have problems with the Docker image or want to force the rebuild of the Docker image:
37+
38+
```
39+
env UID="$(id -u)" GID="$(id -g)" docker-compose build --no-cache
40+
```
41+
42+
### Manually with Ruby tooling
43+
1544
As this website is built with [Jekyll](http://jekyllrb.com/),
1645
we will need to set up some Ruby tooling.
1746

@@ -22,7 +51,7 @@ $ rvm use 2.7.5 --install
2251

2352
# Set up Bundler, a Ruby package manager
2453
# It downloads dependencies specified in a Gemfile
25-
# but into a local path unlike gem
54+
# but into a local path unlike gem
2655
$ gem install bundler
2756
# and if this fails, try installing libffi first (distro-specific):
2857
# sudo apt install libffi-dev
@@ -34,8 +63,9 @@ $ bundle install
3463
$ bundle exec jekyll build
3564
```
3665

37-
## Editing live
38-
This is what you would do after initial installation:
66+
#### Editing live
67+
68+
This is what you would do after the initial installation:
3969
```bash
4070
$ bundle exec jekyll serve --watch
4171
```

docker-compose.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: '2'
2+
3+
services:
4+
jekyll:
5+
user: "${UID}:${GID}"
6+
build: .
7+
command: sh -c "chown $UID / && echo NODE && node -v && bundle exec jekyll serve --incremental --host=0.0.0.0 "
8+
ports:
9+
- '4000:4000'
10+
volumes:
11+
- .:/srv/jekyll

0 commit comments

Comments
 (0)