aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin H. Johnson <robbat2@gentoo.org>2018-02-23 22:17:26 -0800
committerRobin H. Johnson <robbat2@gentoo.org>2018-02-23 22:17:26 -0800
commit733906ecdaaf034bf01f3d5f08c43dc18260fe38 (patch)
tree9365f704b2bfea0b6d9ab441bfe2c33877032f74
parentgitignore: root ignores to checkout root (diff)
downloadtyrian-theme-733906ecdaaf034bf01f3d5f08c43dc18260fe38.tar.gz
tyrian-theme-733906ecdaaf034bf01f3d5f08c43dc18260fe38.tar.bz2
tyrian-theme-733906ecdaaf034bf01f3d5f08c43dc18260fe38.zip
Docker: add way to build without polluting local system.
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
-rw-r--r--.gitignore3
-rw-r--r--Makefile35
-rw-r--r--docker/Dockerfile5
-rwxr-xr-xdocker/run.sh22
4 files changed, 65 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index 04f9328..810725f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,3 +5,6 @@
# Ignore these due to dynamic build process
/package-lock.json
/sources/css/tyrian/package-lock.json
+
+# ignore npm cache
+/npm-cacache
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..074e3ee
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,35 @@
+all: assets
+
+.PHONY: all assets docker-build docker-run
+
+TS = $(shell date -u +%Y%m%d-%H%M%S)
+TAG_TS = $(REPO):$(TS)
+TAG_LATEST = $(REPO):latest
+
+REPO = git.gentoo.org/sites/tyrian-theme
+PWD = $(shell pwd)
+CACHEDIR_EXT = $(PWD)/npm-cacache
+CACHEDIR_VOL = /root/.npm/_cacache/
+
+REPO_EXT = $(PWD)
+REPO_VOL = /repo
+
+assets: docker-run
+
+docker-build:
+ docker build \
+ -t $(TAG_LATEST) \
+ -t $(TAG_TS) \
+ docker/
+
+docker-run: docker-build
+ @mkdir -p $(CACHEDIR_EXT)
+ docker run \
+ --volume $(REPO_EXT):$(REPO_VOL) \
+ --volume $(CACHEDIR_EXT):$(CACHEDIR_VOL) \
+ $(REPO):latest
+
+docker-clean-images:
+ docker rmi $(shell docker images "git.gentoo.org/sites/tyrian-theme" --filter before=git.gentoo.org/sites/tyrian-theme:latest --format '{{.Repository}}:{{.Tag}}')
+docker-clean-container:
+ docker rm $(shell docker ps --filter "ancestor=git.gentoo.org/sites/tyrian-theme" -a -q --no-trunc)
diff --git a/docker/Dockerfile b/docker/Dockerfile
new file mode 100644
index 0000000..146af73
--- /dev/null
+++ b/docker/Dockerfile
@@ -0,0 +1,5 @@
+FROM node:alpine
+ENTRYPOINT ["/run.sh"]
+COPY /run.sh /run.sh
+RUN mkdir -p /repo
+VOLUME /repo
diff --git a/docker/run.sh b/docker/run.sh
new file mode 100755
index 0000000..b9c9a3f
--- /dev/null
+++ b/docker/run.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+# POSIX sh, not bash!
+die() {
+ set +x
+ echo "$*" 1>&2
+ exit 1
+}
+# export for debugging
+[ "$DEBUG" == "1" ] && set -x
+# go to volume
+cd /repo
+basedir=$PWD
+# create output directory:
+mkdir -p assets
+# install grunt
+npm install -g grunt-cli || die "FAIL:${PWD}: npm install -g grunt-cli"
+# setup
+for d in sources/css/bootstrap sources/css/tyrian . ; do
+ cd $basedir/$d && npm install || die "FAIL:${PWD}: npm install failed"
+done
+# do the build
+cd $basedir && grunt || die "FAIL:${PWD}: grunt"