Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Docker #1488

Merged
merged 9 commits into from May 4, 2024
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Expand Up @@ -45,3 +45,9 @@ jobs:
- name: Run tests
shell: bash
run: npm test

- name: Check Docker support
shell: bash
run: |
docker --version
make build
23 changes: 23 additions & 0 deletions Dockerfile
@@ -0,0 +1,23 @@
# Use the official Jekyll image as the base
FROM jekyll/jekyll:3.7
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason, I try to build the docker image and it gives me a segmentation fault:

 => ERROR [5/6] RUN bundle install --no-cache && rm Gemfile.lock                                                                         0.6s
------
 > [5/6] RUN bundle install --no-cache && rm Gemfile.lock:
#5 0.602 Segmentation fault
------
process "/bin/sh -c bundle install --no-cache && rm Gemfile.lock" did not complete successfully: exit code: 139
make: *** [build] Error 1

However, using this docker version solves the problem

Suggested change
FROM jekyll/jekyll:3.7
FROM jekyll/jekyll:4.2.2

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am getting some issues with this change. Did you change anything else?

Screenshot from 2024-04-24 14-23-34

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I only changed the version and this is my docker log

2024-04-25 08:16:21 Bundler 2.3.25 is running, but your lockfile was generated with 1.17.2. Installing Bundler 1.17.2 and restarting using that version.
2024-04-25 08:16:23 Fetching gem metadata from https://rubygems.org/.
2024-04-25 08:16:23 Fetching bundler 1.17.2
2024-04-25 08:16:23 Installing bundler 1.17.2
2024-04-25 08:16:28 Fetching gem metadata from https://rubygems.org/.........
2024-04-25 08:16:28 Using concurrent-ruby 1.2.3
2024-04-25 08:16:28 Using i18n 1.14.4
2024-04-25 08:16:28 Using minitest 5.22.3
2024-04-25 08:16:28 Using tzinfo 2.0.6
2024-04-25 08:16:28 Fetching zeitwerk 2.6.13
2024-04-25 08:16:29 Installing zeitwerk 2.6.13
2024-04-25 08:16:29 Fetching activesupport 6.1.7.7
2024-04-25 08:16:30 Installing activesupport 6.1.7.7
2024-04-25 08:16:30 Using public_suffix 5.0.5
2024-04-25 08:16:30 Using addressable 2.8.6
2024-04-25 08:16:30 Using base64 0.2.0
2024-04-25 08:16:30 Using bundler 1.17.2
2024-04-25 08:16:30 Using coffee-script-source 1.12.2
2024-04-25 08:16:30 Using execjs 2.9.1
2024-04-25 08:16:30 Using coffee-script 2.4.1
2024-04-25 08:16:30 Using colorator 1.1.0
2024-04-25 08:16:30 Using commonmarker 0.23.10
2024-04-25 08:16:30 Using unf_ext 0.0.9.1
2024-04-25 08:16:30 Using unf 0.1.4
2024-04-25 08:16:30 Using simpleidn 0.2.1
2024-04-25 08:16:30 Fetching dnsruby 1.72.0
2024-04-25 08:16:30 Installing dnsruby 1.72.0
2024-04-25 08:16:30 Using eventmachine 1.2.7
2024-04-25 08:16:30 Using http_parser.rb 0.8.0
2024-04-25 08:16:30 Using em-websocket 0.5.3
2024-04-25 08:16:30 Using ffi 1.16.3
2024-04-25 08:16:30 Using ethon 0.16.0
2024-04-25 08:16:30 Fetching faraday-net_http 3.0.2
2024-04-25 08:16:30 Installing faraday-net_http 3.0.2
2024-04-25 08:16:30 Using ruby2_keywords 0.0.5
2024-04-25 08:16:30 Fetching faraday 2.8.1
2024-04-25 08:16:31 Installing faraday 2.8.1
2024-04-25 08:16:31 Using forwardable-extended 2.6.0
2024-04-25 08:16:31 Using gemoji 4.1.0
2024-04-25 08:16:31 Using sawyer 0.9.2
2024-04-25 08:16:31 Using octokit 4.25.1
2024-04-25 08:16:31 Using typhoeus 1.4.1
2024-04-25 08:16:31 Using github-pages-health-check 1.18.2
2024-04-25 08:16:31 Using rb-fsevent 0.11.2
2024-04-25 08:16:31 Using rb-inotify 0.10.1
2024-04-25 08:16:31 Using sass-listen 4.0.0
2024-04-25 08:16:31 Using sass 3.7.4
2024-04-25 08:16:31 Using jekyll-sass-converter 1.5.2
2024-04-25 08:16:31 Using listen 3.9.0
2024-04-25 08:16:31 Using jekyll-watch 2.2.1
2024-04-25 08:16:31 Using rexml 3.2.6
2024-04-25 08:16:31 Using kramdown 2.4.0
2024-04-25 08:16:31 Using liquid 4.0.4
2024-04-25 08:16:31 Using mercenary 0.3.6
2024-04-25 08:16:31 Using pathutil 0.16.2
2024-04-25 08:16:31 Using rouge 3.30.0
2024-04-25 08:16:31 Using safe_yaml 1.0.5
2024-04-25 08:16:31 Using jekyll 3.9.5
2024-04-25 08:16:31 Using jekyll-avatar 0.8.0
2024-04-25 08:16:31 Using jekyll-coffeescript 1.2.2
2024-04-25 08:16:31 Using jekyll-commonmark 1.4.0
2024-04-25 08:16:31 Using jekyll-commonmark-ghpages 0.4.0
2024-04-25 08:16:31 Using jekyll-default-layout 0.1.5
2024-04-25 08:16:31 Using jekyll-feed 0.17.0
2024-04-25 08:16:31 Using jekyll-gist 1.5.0
2024-04-25 08:16:31 Using jekyll-github-metadata 2.16.1
2024-04-25 08:16:31 Using jekyll-include-cache 0.2.1
2024-04-25 08:16:31 Fetching mini_portile2 2.8.5
2024-04-25 08:16:31 Installing mini_portile2 2.8.5
2024-04-25 08:16:31 Using racc 1.7.3
2024-04-25 08:16:31 Fetching nokogiri 1.13.10 (x86_64-linux)
2024-04-25 08:16:33 Installing nokogiri 1.13.10 (x86_64-linux)
2024-04-25 08:16:34 Using html-pipeline 2.14.3
2024-04-25 08:16:34 Using jekyll-mentions 1.6.0
2024-04-25 08:16:34 Using jekyll-optional-front-matter 0.3.2
2024-04-25 08:16:34 Using jekyll-paginate 1.1.0
2024-04-25 08:16:34 Using jekyll-readme-index 0.3.0
2024-04-25 08:16:34 Using jekyll-redirect-from 0.16.0
2024-04-25 08:16:34 Using jekyll-relative-links 0.6.1
2024-04-25 08:16:34 Using rubyzip 2.3.2
2024-04-25 08:16:34 Using jekyll-remote-theme 0.4.3
2024-04-25 08:16:34 Using jekyll-seo-tag 2.8.0
2024-04-25 08:16:34 Using jekyll-sitemap 1.4.0
2024-04-25 08:16:34 Using jekyll-swiss 1.0.0
2024-04-25 08:16:34 Using jekyll-theme-architect 0.2.0
2024-04-25 08:16:34 Using jekyll-theme-cayman 0.2.0
2024-04-25 08:16:34 Using jekyll-theme-dinky 0.2.0
2024-04-25 08:16:34 Using jekyll-theme-hacker 0.2.0
2024-04-25 08:16:34 Using jekyll-theme-leap-day 0.2.0
2024-04-25 08:16:34 Using jekyll-theme-merlot 0.2.0
2024-04-25 08:16:34 Using jekyll-theme-midnight 0.2.0
2024-04-25 08:16:34 Using jekyll-theme-minimal 0.2.0
2024-04-25 08:16:34 Using jekyll-theme-modernist 0.2.0
2024-04-25 08:16:34 Using jekyll-theme-primer 0.6.0
2024-04-25 08:16:34 Using jekyll-theme-slate 0.2.0
2024-04-25 08:16:34 Using jekyll-theme-tactile 0.2.0
2024-04-25 08:16:34 Using jekyll-theme-time-machine 0.2.0
2024-04-25 08:16:34 Using jekyll-titles-from-headings 0.5.3
2024-04-25 08:16:34 Using jemoji 0.13.0
2024-04-25 08:16:34 Using kramdown-parser-gfm 1.1.0
2024-04-25 08:16:34 Using minima 2.5.1
2024-04-25 08:16:34 Using unicode-display_width 1.8.0
2024-04-25 08:16:34 Using terminal-table 1.8.0
2024-04-25 08:16:34 Using github-pages 231
2024-04-25 08:16:34 Using webrick 1.8.1
2024-04-25 08:16:34 Bundle complete! 3 Gemfile dependencies, 93 gems now installed.
2024-04-25 08:16:34 Use `bundle info [gemname]` to see where a bundled gem is installed.
2024-04-25 08:16:35 Cleaning all the gems on your system is dangerous! If you're sure you want to
2024-04-25 08:16:35 remove every system gem not in this bundle, run `bundle clean --force`.
2024-04-25 08:16:35 ruby 3.1.1p18 (2022-02-18 revision 53f5fc4236) [x86_64-linux-musl]
2024-04-25 08:16:38 Configuration file: /usr/src/app/_config.yml
2024-04-25 08:16:39             Source: /usr/src/app
2024-04-25 08:16:39        Destination: /usr/src/app/_site
2024-04-25 08:16:39  Incremental build: disabled. Enable with --incremental
2024-04-25 08:16:39       Generating... 
2024-04-25 08:16:59                     done in 19.929 seconds.
2024-04-25 08:16:59  Auto-regeneration: enabled for '/usr/src/app'
2024-04-25 08:17:00 LiveReload address: http://0.0.0.0:35729
2024-04-25 08:17:00     Server address: http://0.0.0.0:4000
2024-04-25 08:17:00   Server running... press ctrl-c to stop.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

taking a later docker imag version is necessary for ruby support after I snapped to the gh-pages deps in #1512

It works, maybe nuke your Gemfile.lock before running


# Set the working directory
WORKDIR /usr/src/app

# Change the permissions of the working directory
RUN chmod 777 /usr/src/app

# Copy the Gemfile into the image
COPY Gemfile ./

# Install the gems and delete the Gemfile.lock
RUN bundle install --no-cache && rm Gemfile.lock

# Copy the rest of the project into the image
COPY . .

# Expose the port Jekyll will run on
EXPOSE 4000

# The default command to run Jekyll
CMD ["jekyll", "serve", "--host", "0.0.0.0", "--livereload"]
27 changes: 27 additions & 0 deletions Makefile
@@ -0,0 +1,27 @@
GREEN := \033[1;32m
BLUE := \033[1;34m
RESET := \033[0m

# The directory of this file
DIR := $(shell echo $(shell cd "$(shell dirname "${BASH_SOURCE[0]}" )" && pwd ))

# This will output the help for each task
# thanks to https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
.PHONY: help

help: ## This help
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "${GREEN}%-30s${RESET} %s\n", $$1, $$2}' $(MAKEFILE_LIST)

.DEFAULT_GOAL := help

serve: ## Local server
@echo "${BLUE}Servering website in localhost:4000${RESET}"
docker run -p 4000:4000 -v $(DIR):/usr/src/app expressjs.com

build: ## Build site
@echo "${BLUE}Building site...${RESET}"
docker build -t expressjs.com .

clean: ## Clean up
@echo "${BLUE}Clean up...${RESET}"
docker rmi expressjs.com
10 changes: 10 additions & 0 deletions README.md
Expand Up @@ -35,6 +35,16 @@ To preview the website locally:

Then, load <http://localhost:4000> in your browser.

## Local Setup using Docker

>[!TIP]
> You can run `make help` to obtain detailed information on how to use our make commands.

0. Ensure that you have Docker and Make installed.
1. Run `make build` to build the project.
2. Run `make serve` to serve the project, this include live reloading so any change will be reflected (it can take a while, check the logs).
3. Run `make clean` to remove the docker images and resources generated.
UlisesGascon marked this conversation as resolved.
Show resolved Hide resolved

## Formatting

Jekyll uses a variant of Markdown known as [Kramdown](https://kramdown.gettalong.org/quickref.html).
Expand Down