aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2020-05-04 23:14:00 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2020-05-04 23:14:00 +0300
commit51e4faca24073cee7558aa66e37428dcffcfbc10 (patch)
treebf9796ed8a71193a72a6d415229e39f9ce5822f4
downloadjekyll-docker-51e4faca24073cee7558aa66e37428dcffcfbc10.tar.gz
jekyll-docker-51e4faca24073cee7558aa66e37428dcffcfbc10.zip
initial commit
Diffstat (limited to '')
-rw-r--r--.gitattributes1
-rw-r--r--.gitignore3
-rw-r--r--Dockerfile41
-rw-r--r--Makefile118
-rw-r--r--docker-compose.yml10
5 files changed, 173 insertions, 0 deletions
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..176a458
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1 @@
+* text=auto
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..0aea6ec
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+*.tar.gz
+/chruby-*/
+/ruby-install-*/
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..1f56c22
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,41 @@
+FROM debian:buster-slim
+
+SHELL ["/bin/bash", "-c"]
+
+ENV DEBIAN_FRONTEND=noninteractive
+
+RUN apt update -yq && \
+ apt install -yq --no-install-recommends \
+ build-essential \
+ ca-certificates wget \
+ sudo
+
+# Creating regular user 'developer':
+ARG USER=developer
+RUN addgroup "$USER" && \
+ adduser --disabled-password --gecos "" --ingroup "$USER" --home "/home/$USER" "$USER" && \
+ addgroup "$USER" sudo && \
+ echo -e '%sudo ALL=(ALL) NOPASSWD:ALL\nDefaults env_keep += "HOME"' >> /etc/sudoers
+
+USER "$USER"
+ENV src_dir="/home/$USER/src"
+RUN mkdir -p -- "$src_dir/docker"
+WORKDIR "$src_dir/docker"
+
+ENV PATH="/home/$USER/.local/bin:$PATH"
+
+COPY ["docker/Makefile", "./"]
+RUN sudo make ruby-install && \
+ sudo make ruby-install/clean && \
+ make ruby && \
+ sudo make chruby && \
+ sudo make chruby/profile.d && \
+ sudo make chruby/clean && \
+ make bundler
+
+COPY ["Gemfile", "Gemfile.lock", "../"]
+RUN make dependencies
+
+COPY [".", "../"]
+RUN sudo chown -R "$USER:$USER" ../
+CMD make jekyll/serve
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..06d725c
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,118 @@
+SHELL := bash
+.SHELLFLAGS := -e -o pipefail -c
+.DEFAULT_GOAL := jekyll/serve
+.DELETE_ON_ERROR:
+.SUFFIXES:
+
+makefile_dir := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
+project_dir := $(dir $(makefile_dir))/..
+
+PREFIX ?= $(HOME)/.local
+
+chruby_version ?= 0.3.9
+chruby_url := https://github.com/postmodern/chruby/archive/v$(chruby_version).tar.gz
+chruby_archive := $(makefile_dir)/chruby-$(chruby_version).tar.gz
+chruby_dir := $(makefile_dir)/chruby-$(chruby_version)
+
+chruby_sh := $(PREFIX)/share/chruby/chruby.sh
+auto_sh := $(PREFIX)/share/chruby/auto.sh
+
+ruby_install_version ?= 0.7.0
+ruby_install_url := https://github.com/postmodern/ruby-install/archive/v$(ruby_install_version).tar.gz
+ruby_install_archive := $(makefile_dir)/ruby-install-$(ruby_install_version).tar.gz
+ruby_install_dir := $(makefile_dir)/ruby-install-$(ruby_install_version)
+
+ruby_version ?= 2.6.5
+
+.PHONY: chruby
+chruby:
+ wget -O '$(chruby_archive)' '$(chruby_url)'
+ tar -xzvf '$(chruby_archive)' -C '$(makefile_dir)'
+ cd -- '$(chruby_dir)' && $(MAKE) install 'PREFIX=$(PREFIX)'
+
+.PHONY: chruby/uninstall
+chruby/uninstall:
+ cd -- '$(chruby_dir)' && $(MAKE) uninstall 'PREFIX=$(PREFIX)'
+
+.PHONY: chruby/clean
+chruby/clean:
+ rm -rf -- '$(chruby_archive)' '$(chruby_dir)'
+
+define chruby_profile_d
+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
+
+.PHONY: chruby/profile.d
+chruby/profile.d:
+ echo "$$chruby_profile_d" > /etc/profile.d/chruby.sh
+
+.PHONY: chruby/profile.d/clean
+chruby/profile.d/clean:
+ rm -f -- /etc/profile.d/chruby.sh
+
+.PHONY: ruby-install
+ruby-install:
+ wget -O '$(ruby_install_archive)' '$(ruby_install_url)'
+ tar -xzvf '$(ruby_install_archive)' -C '$(makefile_dir)'
+ cd -- '$(ruby_install_dir)' && make install 'PREFIX=$(PREFIX)'
+
+.PHONY: ruby-install/uninstall
+ruby-install/uninstall:
+ cd -- '$(ruby_install_dir)' && make uninstall 'PREFIX=$(PREFIX)'
+
+.PHONY: ruby-install/clean
+ruby-install/clean:
+ rm -rf -- '$(ruby_install_archive)' '$(ruby_install_dir)'
+
+.PHONY: ruby
+ruby:
+ ruby-install -j2 --cleanup ruby '$(ruby_version)'
+
+chruby := cd -- '$(project_dir)' && . '$(chruby_sh)' && chruby 'ruby-$(ruby_version)'
+
+.PHONY: bundler
+bundler:
+ $(chruby) && gem install --norc bundler
+
+.PHONY: dependencies
+dependencies:
+ $(chruby) && bundle install --jobs=2 --retry=3
+
+.PHONY: deps
+deps: dependencies
+
+jekyll := $(chruby) && bundle exec jekyll
+
+.PHONY: jekyll/build
+jekyll/build:
+ $(jekyll) build --config _config.yml,_config_dev.yml
+
+.PHONY: jekyll/serve
+jekyll/serve:
+ $(jekyll) serve --host 0.0.0.0 --config _config.yml,_config_dev.yml
+
+docker_compose := cd -- '$(makefile_dir)' && docker-compose
+
+.PHONY: docker/build
+docker/build:
+ $(docker_compose) build --force-rm
+
+.PHONY: docker/up
+docker/up:
+ $(docker_compose) up -d
+
+.PHONY: docker/down
+docker/down:
+ $(docker_compose) down -v
+
+.PHONY: docker/shell
+docker/shell:
+ $(docker_compose) exec serve bash --login
+
+.PHONY: docker/clean
+docker/clean:
+ docker system prune -a -f --volumes
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 0000000..1600e0d
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,10 @@
+version: '3'
+services:
+ serve:
+ build:
+ context: ..
+ dockerfile: docker/Dockerfile
+ ports:
+ - 4000:4000
+ volumes:
+ - ../:/home/developer/src