Skip to content

Commit 53c07a0

Browse files
authored
Add development Dockerfile (#229)
* Add development dockerfile * Add to readme
1 parent baf6dcd commit 53c07a0

File tree

2 files changed

+71
-1
lines changed

2 files changed

+71
-1
lines changed

Dockerfile

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# This Dockerfile builds an ruby environment for jekyll that empowers
2+
# making updates to the website without requiring the dev
3+
# to maintain a local ruby development environment.
4+
5+
FROM ruby:3.2.2-slim-bullseye AS base
6+
7+
RUN apt update && apt install -y --no-install-recommends \
8+
build-essential \
9+
git \
10+
curl \
11+
&& rm -rf /var/lib/apt/lists/*
12+
13+
WORKDIR /mnt/workdir
14+
15+
# Copy over the Gemfiles so that all build dependencies are installed
16+
# during the docker build. At runtime, these will be available to Jekyll
17+
# from the mounted directory. But that's not available during the
18+
# docker build, so we need to copy them in to pre-install the Gems
19+
20+
COPY Gemfile Gemfile.lock ./
21+
22+
# Gems will be installed under GEM_HOME which is set by the ruby image.
23+
# See https://hub.docker.com/_/ruby for details.
24+
25+
RUN gem update --system \
26+
&& bundle install \
27+
&& gem cleanup
28+
29+
ENV HOST=0.0.0.0
30+
ENV PORT=4000
31+
32+
EXPOSE $PORT
33+
34+
# Configure the default command to build from the mounted repository.
35+
CMD bundle exec jekyll serve -H $HOST -P $PORT

README.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,45 @@ Changes pushed to our `main` branch will automatically trigger [Jekyll] to
7272
build our site from that branch and push the result to our `asf-site`
7373
branch, where they will be served on [our production site][production].
7474

75+
## Testing using Docker environment
76+
77+
A containerized development environment can be built using the local
78+
Dockerfile. You can build it with the following command:
79+
80+
```bash
81+
docker build -t fluo-site-dev .
82+
```
83+
84+
This action will produce a `fluo-site-dev` image, with all the website's build
85+
prerequisites preinstalled. When a container is run from this image, it
86+
will perform a `jekyll serve` command with the polling option enabled,
87+
so that changes you make locally will be immediately reflected after
88+
reloading the page in your browser.
89+
90+
When you run a container using the `fluo-site-dev` image, your current working
91+
directory will be mounted, so that any changes made by the build inside
92+
the container will be reflected in your local workspace. This is done with
93+
the `-v` flag. To run the container, execute the following command:
94+
95+
```bash
96+
docker run -it -v "$PWD":/mnt/workdir -p 4000:4000 fluo-site-dev
97+
```
98+
99+
While this container is running, you will be able to review the rendered website
100+
in your local browser at the address printed in the shell ([http://0.0.0.0:4000/](http://0.0.0.0:4000/)).
101+
102+
Appending `/bin/bash` to the end of the docker command above will provide shell access. This is useful for adding new
103+
gems, or modifying the Gemfile.lock for updating existing dependencies.
104+
When using shell access, the local directory must be mounted to ensure
105+
the Gemfile and Gemfile.lock updates are reflected in your local
106+
environment so you can create a commit and submit a PR.
107+
108+
You may need to manually delete the `_site` or `.jekyll-cache` directories if
109+
they already exist and are causing issues with the build.
110+
75111
[Jekyll]: https://jekyllrb.com/
76112
[production]: https://fluo.apache.org
77113
[ti]: https://github.com/apache/fluo-website/workflows/CI/badge.svg
78114
[tl]: https://github.com/apache/fluo-website/actions
79115
[li]: http://img.shields.io/badge/license-ASL-blue.svg
80116
[ll]: https://github.com/apache/fluo-website/blob/main/LICENSE
81-

0 commit comments

Comments
 (0)