Skip to content

Commit ea46a56

Browse files
committed
Make running jekyll less irritating
Every time I need to edit the blog and view it locally something in the ruby/jekyll stack has changed enough that it doesn't work. So make a Dockerfile and some instructions to make setting up the environment more reliable. And separate from the host.
1 parent 659c364 commit ea46a56

File tree

4 files changed

+42
-0
lines changed

4 files changed

+42
-0
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.git

Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM fedora:latest
2+
RUN dnf --setopt=deltarpm=0 --verbose install -y passwd sudo vim-enhanced less redhat-rpm-config \
3+
@development-tools gcc-c++ autoconf automake libtool zlib-devel \
4+
rubygem-bundler ruby-devel kernel-headers
5+
WORKDIR /weldr.io/
6+
7+
# Run as user passed in with --env LOCAL_UID=`id -u`
8+
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
9+
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]

StyleGuide.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
22

33
Notes for weldrists writing for weldr.io.
44

5+
## Testing locally using containers
6+
7+
This will build a container, install the needed fedora packages and mount the current directory as
8+
your user id (so that you can edit from within the container without making everything owned by root).
9+
10+
sudo docker build -t weldr/jekyll .
11+
sudo docker run -it --name=jekyll --security-opt="label=disable" -v "$PWD:/weldr.io/" --env LOCAL_UID=`id -u` -p 4000:4000 weldr/jekyll /usr/bin/bash
12+
bundle install --binstubs=/tmp/bin/
13+
bundle exec /tmp/bin/jekyll serve --host=0.0.0.0 --incremental
14+
15+
...then just open http://localhost:4000/ and you're off. On subsequent runs you can reuse the container with:
16+
17+
sudo docker start -i jekyll
18+
519
## Testing locally
620

721
See README.md as well, but here's the quick version:

entrypoint.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
# Setup a user account from environment:
4+
# LOCAL_USERNAME
5+
# LOCAL_UID
6+
USERNAME=${LOCAL_USERNAME:-user}
7+
USER_ID=${LOCAL_UID:-1000}
8+
9+
if [ "$USERNAME" == "root" ]; then
10+
echo "Running as root"
11+
exec "$@"
12+
else
13+
echo "Running with $USERNAME:$USER_ID"
14+
useradd -u "$USER_ID" -G wheel -m "$USERNAME"
15+
# Remove user password, allows sudo use
16+
passwd -d "$USERNAME"
17+
exec sudo -u "$USERNAME" "$@"
18+
fi

0 commit comments

Comments
 (0)