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

Make running jekyll less irritating #8

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.git
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ Gemfile
Gemfile.lock
node_modules
package.json
vendor
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM fedora:latest
RUN dnf --setopt=deltarpm=0 --verbose install -y passwd sudo vim-enhanced less redhat-rpm-config \
@development-tools gcc-c++ autoconf automake libtool zlib-devel \
rubygem-bundler ruby-devel kernel-headers
WORKDIR /weldr.io/

# Run as user passed in with --env LOCAL_UID=`id -u`
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
14 changes: 14 additions & 0 deletions StyleGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@

Notes for weldrists writing for weldr.io.

## Testing locally using containers

This will build a container, install the needed fedora packages and mount the current directory as
your user id (so that you can edit from within the container without making everything owned by root).

sudo docker build -t weldr/jekyll .
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
bundle install --binstubs=/tmp/bin/ --deployment
bundle exec /tmp/bin/jekyll serve --host=0.0.0.0 --incremental

...then just open http://localhost:4000/ and you're off. On subsequent runs you can reuse the container with:

sudo docker start -i jekyll

## Testing locally

See README.md as well, but here's the quick version:
Expand Down
1 change: 1 addition & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,6 @@ exclude:
- README.md
- CNAME
- StyleGuide.md
- vendor

theme: jekyll-theme-hacker
18 changes: 18 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

# Setup a user account from environment:
# LOCAL_USERNAME
# LOCAL_UID
USERNAME=${LOCAL_USERNAME:-user}
USER_ID=${LOCAL_UID:-1000}

if [ "$USERNAME" == "root" ]; then
echo "Running as root"
exec "$@"
else
echo "Running with $USERNAME:$USER_ID"
useradd -u "$USER_ID" -G wheel -m "$USERNAME"
# Remove user password, allows sudo use
passwd -d "$USERNAME"
exec sudo -u "$USERNAME" "$@"
fi