aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Makefile
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2020-05-06 15:44:59 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2020-05-06 16:21:53 +0300
commitb05b07345084c415e6da431a5e247ac9afa09065 (patch)
tree8e1b98cef39de780e07fd0108e8f3aebdfd39d04 /Makefile
parentset up GitHub Actions (diff)
downloadjekyll-docker-b05b07345084c415e6da431a5e247ac9afa09065.tar.gz
jekyll-docker-b05b07345084c415e6da431a5e247ac9afa09065.zip
fix GitHub action tests
That's a messy commit, but it required a lot of changes to get everything right. * Docker: create user jekyll with UID/GID that match the user that built the image (for seamless writes to /project). * Docker: run the container by the current user for the same purpose. * Docker: add an ENTRYPOINT to drop root privileges & check if the running user is the same as the one who built the image. * Jekyll: use --drafts. * Makefile: add docker/logs. As a side note, Docker + non-root users + bind mounts are a pain, I even wrote a blog post to make sense of it all: https://egor-tensin.github.io/blog/2020/05/06/docker-bind-mounts.html
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile24
1 files changed, 18 insertions, 6 deletions
diff --git a/Makefile b/Makefile
index df15d22..fe2a34f 100644
--- a/Makefile
+++ b/Makefile
@@ -56,17 +56,21 @@ chruby/uninstall:
chruby/clean:
rm -rf -- '$(chruby_archive)' '$(chruby_dir)'
-define chruby_profile_d
+define chruby_source
if [ -n "$$BASH_VERSION" ] || [ -n "$$ZSH_VERSION" ]; then
[ -r '$(chruby_sh)' ] && source '$(chruby_sh)'
[ -r '$(auto_sh)' ] && source '$(auto_sh)'
fi
endef
-export chruby_profile_d
+export chruby_source
+
+.PHONY: chruby/.bashrc
+chruby/.bashrc:
+ echo "$$chruby_source" >> ~/.bashrc
.PHONY: chruby/profile.d
chruby/profile.d:
- echo "$$chruby_profile_d" > /etc/profile.d/chruby.sh
+ echo "$$chruby_source" > /etc/profile.d/chruby.sh
.PHONY: chruby/profile.d/clean
chruby/profile.d/clean:
@@ -97,11 +101,15 @@ deps/update: dependencies/update
.PHONY: jekyll/build
jekyll/build:
- $(jekyll) build --config _config.yml,_config_dev.yml
+ $(jekyll) build --drafts --config _config.yml,_config_dev.yml
.PHONY: jekyll/serve
jekyll/serve:
- $(jekyll) serve --host 0.0.0.0 --config _config.yml,_config_dev.yml
+ $(jekyll) serve --drafts --config _config.yml,_config_dev.yml --host 0.0.0.0
+
+JEKYLL_UID ?= $(shell id -u)
+JEKYLL_GID ?= $(shell id -g)
+export JEKYLL_UID JEKYLL_GID
# Not an absolute path, cause you know, Windows (more specifically, Cygwin +
# native Windows docker-compose).
@@ -109,12 +117,16 @@ docker_compose := cd -- '$(makefile_dir)' && docker-compose --env-file ./.env
.PHONY: docker/build
docker/build:
- $(docker_compose) build --force-rm
+ $(docker_compose) build --force-rm --build-arg 'JEKYLL_UID=$(JEKYLL_UID)' --build-arg 'JEKYLL_GID=$(JEKYLL_GID)'
.PHONY: docker/up
docker/up:
$(docker_compose) up -d project
+.PHONY: docker/logs
+docker/logs:
+ $(docker_compose) logs
+
.PHONY: docker/down
docker/down:
$(docker_compose) down -v