www: Only rebuild docker image when neccessary
Change-Id: If2738b750b5d9b01d1388432ef897b71de56cbc8
diff --git a/Dockerfile b/Dockerfile
index 0fd42f4..e0560b0 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,12 +1,7 @@
FROM debian:testing
-ARG baseurl
-ENV full_baseurl=/$baseurl
ENV COMPOSER_ALLOW_SUPERUSER=1
-WORKDIR /src
-ADD . /src
-
# Install mysql
RUN apt-get -y update
RUN apt-get -y install mariadb-server
@@ -20,8 +15,5 @@
&& php -r "unlink('composer-setup.php');" \
&& mv composer.phar /usr/local/bin/composer
-RUN composer install
-
-
VOLUME /src
-ENTRYPOINT service mariadb start && mysql < build/leaf_ota.sql && bin/console -e prod stenope:build --base-url=/$full_baseurl ./build/static && chmod a+rw -R build
+ENTRYPOINT ["/bin/bash", "/src/preview.sh"]
diff --git a/preview.sh b/preview.sh
new file mode 100755
index 0000000..4b4358b
--- /dev/null
+++ b/preview.sh
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+set -e
+
+cd /src
+
+# Install dependencies
+composer install
+
+# Set up db
+service mariadb start
+mysql < build/leaf_ota.sql
+
+# Generate preview
+BASEURL="$(cat ./build/gerrit_change.txt)"
+bin/console -e prod stenope:build --base-url=/$BASEURL ./build/static && chmod a+rw -R .