summaryrefslogtreecommitdiff
path: root/misc/docker
diff options
context:
space:
mode:
authorRasmus Andersson <rasmus@notion.se>2019-01-06 03:20:22 +0300
committerRasmus Andersson <rasmus@notion.se>2019-01-06 03:20:22 +0300
commit4ded41f4a37133a7e73156619cfb0fd8de767143 (patch)
treef3a1fe221ac925db7513108be81705c5661aca0a /misc/docker
parentc6c99df95877077207f1f78f572734490d56f404 (diff)
downloadinter-4ded41f4a37133a7e73156619cfb0fd8de767143.tar.xz
Adds docker toolchain for a simpler build setup
Diffstat (limited to 'misc/docker')
-rw-r--r--misc/docker/Dockerfile37
-rwxr-xr-xmisc/docker/build.sh48
2 files changed, 85 insertions, 0 deletions
diff --git a/misc/docker/Dockerfile b/misc/docker/Dockerfile
new file mode 100644
index 000000000..34ffed119
--- /dev/null
+++ b/misc/docker/Dockerfile
@@ -0,0 +1,37 @@
+FROM python:3.7-stretch
+
+RUN apt-get -qq update \
+ && apt-get install -y -qq --no-install-recommends \
+ git curl unzip build-essential ca-certificates ttfautohint \
+ && pip install virtualenv
+
+RUN mkdir /inter
+WORKDIR /inter
+
+COPY . /inter/
+RUN rm Dockerfile
+
+RUN ln -s /host/src src \
+ && ln -s /host/version.txt . \
+ && ln -s /host/githash.txt . \
+ && ln -s /host/Makefile . \
+ && ./init.sh \
+ && rm -rf build/fonts \
+ && mkdir -p /host/build/fonts \
+ && ln -s /host/build/fonts build/fonts
+
+RUN rm init.sh && ln -s /host/init.sh . \
+ && echo "source /inter/init.sh" >> "$HOME/.bashrc" \
+ && echo "alias l='ls -lAF'" >> "$HOME/.bashrc" \
+ && echo 'export PS1="\[\e[33;1m\]\u@\w\[\e[0m\]\\\$ "' >> "$HOME/.bashrc"
+
+# cleanup
+RUN apt-get -y autoremove \
+ && apt-get clean \
+ && rm -rf /var/lib/apt/lists/*
+
+ENV PATH=/inter/build/venv/bin:$PATH
+
+VOLUME /host
+
+CMD "/bin/bash"
diff --git a/misc/docker/build.sh b/misc/docker/build.sh
new file mode 100755
index 000000000..39313dc5b
--- /dev/null
+++ b/misc/docker/build.sh
@@ -0,0 +1,48 @@
+#!/bin/bash -e
+#
+# Builds the docker image
+#
+
+cd "$(dirname "$0")"
+DOCKER_DIR=$(pwd)
+cd ../..
+ROOT_DIR=$(pwd)
+
+IMAGE_NAME=rsms/inter-ui-build
+BUILD_DIR=$ROOT_DIR/build/docker
+
+# setup build dir
+mkdir -p "$BUILD_DIR/misc/tools"
+
+# copy files to build dir
+echo "Syncing build dir"
+cp -a \
+ init.sh \
+ requirements.txt \
+ "$DOCKER_DIR/Dockerfile" \
+ "$BUILD_DIR/" &
+rsync -v -acC --delete --filter="- *.pyc" --filter="- /*/" \
+ "misc/tools/" \
+ "$BUILD_DIR/misc/tools/" &
+rsync -v -acC --delete \
+ misc/fontbuild \
+ misc/fonttools-3.34.2-psCharStrings.patch \
+ misc/ttf2woff \
+ "$BUILD_DIR/misc/"
+wait
+
+# update githash.txt
+git rev-parse --short HEAD > githash.txt
+
+pushd "$BUILD_DIR" >/dev/null
+
+# build the image
+echo "Building image. This might take a while..."
+# docker build -f Dockerfile -t $IMAGE_NAME --squash .
+docker build -f Dockerfile -t $IMAGE_NAME .
+
+echo "You can push the image to Docker hub:"
+echo " docker push $IMAGE_NAME:latest"
+echo ""
+echo "Run interactively:"
+echo " docker run --rm -it -v \"$ROOT_DIR:/host\" $IMAGE_NAME:latest"