-
Notifications
You must be signed in to change notification settings - Fork 507
contrib: add a Dockerfile to run the website locally #1184
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
base: master
Are you sure you want to change the base?
Conversation
(This is based on the CI config) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 9f7a431
PR adds dockerfile (based on ci) and edited readme in contrib with instruction so that the bitcoincore.org website can be run locally for easy testing of changes.
This is a valuable addition and makes testing the changes locally easier without installing all the dependencies on the base machine.
- code reviewed ✅
- followed instructions to run it locally ✅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 9f7a431
Dockerfile is nice and tidy, and works well in testing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK, but I think incrementally building the site at runtime makes more sense than doing it at build time (see suggestion).
curl \ | ||
jekyll \ | ||
make \ | ||
ruby \ | ||
ruby-html-proofer \ | ||
ruby-jekyll-redirect-from \ | ||
ruby-kramdown-parser-gfm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make
seems to be the only dependency we actually need here? All the others are duplicates: ruby
is already provided by the base image, and the others are installed by bundle/specified by Gemfile.
RUN gem install bundler \ | ||
&& bundle install | ||
|
||
RUN make build |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think building the website inside the image is ideal. It makes more sense to me to generate the website at runtime, in incremental mode. Keeps the image small, and the container more functional?
# Default Jekyll port | ||
EXPOSE 4000 | ||
|
||
CMD ["bundle", "exec", "jekyll", "server", "--host", "0.0.0.0", "--future"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're duplicating Makefile
commands anyway, I think it might make sense to avoid the make
dependency entirely?
Suggested diff that combines all my suggestions:
git diff on 9f7a431
diff --git a/contrib/devtools/Dockerfile b/contrib/devtools/Dockerfile
index f4e3897..9ed076a 100644
--- a/contrib/devtools/Dockerfile
+++ b/contrib/devtools/Dockerfile
@@ -4,26 +4,14 @@ ENV NOKOGIRI_USE_SYSTEM_LIBRARIES=true
ENV JEKYLL_ENV=production
ENV RUBYOPT="-KU -E utf-8:utf-8"
-RUN apt update \
- && apt install -y \
- curl \
- jekyll \
- make \
- ruby \
- ruby-html-proofer \
- ruby-jekyll-redirect-from \
- ruby-kramdown-parser-gfm
-
WORKDIR /site
-COPY . .
+COPY Gemfile* ./
RUN gem install bundler \
&& bundle install
-RUN make build
-
# Default Jekyll port
EXPOSE 4000
-CMD ["bundle", "exec", "jekyll", "server", "--host", "0.0.0.0", "--future"]
+CMD ["bundle", "exec", "jekyll", "serve", "--future", "--drafts", "--unpublished", "--incremental", "--strict_front_matter", "--host", "0.0.0.0"]
Or if we want to keep using make
(e.g. also allowing the user to run docker run -it --rm -v "$PWD":/site -p 4000:4000 corewebsite make test
, might be useful to add to the readme):
git diff on 9f7a431
diff --git a/Makefile b/Makefile
index 75b80c2..7e8c096 100644
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@ all: build test
preview:
bundle exec jekyll clean
- bundle exec jekyll serve --future --drafts --unpublished --incremental --strict_front_matter
+ bundle exec jekyll serve --future --drafts --unpublished --incremental --strict_front_matter --host 0.0.0.0
build:
bundle exec jekyll clean
diff --git a/contrib/devtools/Dockerfile b/contrib/devtools/Dockerfile
index f4e3897..eb38463 100644
--- a/contrib/devtools/Dockerfile
+++ b/contrib/devtools/Dockerfile
@@ -4,26 +4,19 @@ ENV NOKOGIRI_USE_SYSTEM_LIBRARIES=true
ENV JEKYLL_ENV=production
ENV RUBYOPT="-KU -E utf-8:utf-8"
-RUN apt update \
- && apt install -y \
- curl \
- jekyll \
+RUN apt-get update \
+ && apt-get install -y \
make \
- ruby \
- ruby-html-proofer \
- ruby-jekyll-redirect-from \
- ruby-kramdown-parser-gfm
+ && rm -rf /var/lib/apt/lists/*
WORKDIR /site
-COPY . .
+COPY Gemfile* ./
RUN gem install bundler \
&& bundle install
-RUN make build
-
# Default Jekyll port
EXPOSE 4000
-CMD ["bundle", "exec", "jekyll", "server", "--host", "0.0.0.0", "--future"]
+CMD ["make", "preview"]
It was useful to me, so i cleaned it up and PR'd it in case others do not have a full Ruby toolchain installed, but do have Docker.