[particles] Add docker container and release script

Bug: skia:
Change-Id: If8e369027bc6df8bc178b752f8bc26012d581365
Reviewed-on: https://skia-review.googlesource.com/c/buildbot/+/199255
Reviewed-by: Kevin Lubick <kjlubick@google.com>
diff --git a/particles/Makefile b/particles/Makefile
index 5913b41..0c3115a 100644
--- a/particles/Makefile
+++ b/particles/Makefile
@@ -6,6 +6,14 @@
 	npx webpack --mode=production
 	./build_release
 
+release_ci: release_ci_fixed
+	echo "using a fixed canvaskit"
+
+release_ci_fixed: app wasm_libs_fixed
+	npx webpack --mode=production
+	CGO_ENABLED=0 GOOS=linux go install -a ./go/particles
+	./build_release
+
 serve: app
 	npx webpack-dev-server --mode=development --watch --watch-poll 100
 
@@ -35,7 +43,11 @@
 	rm -rf build
 	mkdir -p build/canvaskit
 	cp node_modules/canvaskit-wasm/bin/* build/canvaskit
-	echo "export const SKIA_VERSION = '0.4.2';" > build/version.js
+	echo "export const SKIA_VERSION = '0.5.0';" > build/version.js
 
-.PHONY: serve watch app release wasm_libs_fixed wasm_libs_tot get_latest_skia push
+push: release skia-public
+	pushk particles
 
+.PHONY: serve watch app release release_ci wasm_libs_fixed wasm_libs_tot get_latest_skia push
+
+include ../make/clusters.mk
\ No newline at end of file
diff --git a/particles/build_release b/particles/build_release
new file mode 100755
index 0000000..27060eb
--- /dev/null
+++ b/particles/build_release
@@ -0,0 +1,15 @@
+#!/bin/bash
+APPNAME=particles
+
+set -x -e
+
+# Copy files into the right locations in ${ROOT}.
+copy_release_files()
+{
+INSTALL="install -D --verbose --backup=none"
+INSTALL_DIR="install -d --verbose --backup=none"
+${INSTALL} --mode=644 -T ${APPNAME}/Dockerfile    ${ROOT}/Dockerfile
+${INSTALL} --mode=755 -T ${GOPATH}/bin/${APPNAME} ${ROOT}/usr/local/bin/${APPNAME}
+(cd ./dist/ && find . -type f -exec ${INSTALL} "{}" "${ROOT}/usr/local/share/${APPNAME}/{}" \;)
+}
+source ../bash/docker_build.sh
diff --git a/particles/create-particles-sa.sh b/particles/create-particles-sa.sh
new file mode 100755
index 0000000..84413ea
--- /dev/null
+++ b/particles/create-particles-sa.sh
@@ -0,0 +1,16 @@
+#/bin/bash
+# Creates the service account that has read-write access to the particles bucket.
+
+set -e -x
+
+source ../kube/config.sh
+source ../bash/ramdisk.sh
+
+# New service account we will create.
+SA_NAME=skia-particles
+cd /tmp/ramdisk
+gcloud iam service-accounts create "${SA_NAME}" --display-name="Read-write access to GCS for particles server."
+gcloud beta iam service-accounts keys create ${SA_NAME}.json --iam-account="${SA_NAME}@${PROJECT_SUBDOMAIN}.iam.gserviceaccount.com"
+gsutil acl ch -u "${SA_NAME}@${PROJECT_SUBDOMAIN}.iam.gserviceaccount.com:W" gs://skparticles-renderer
+kubectl create secret generic "${SA_NAME}" --from-file=key.json=${SA_NAME}.json
+cd -
diff --git a/particles/particles/Dockerfile b/particles/particles/Dockerfile
new file mode 100644
index 0000000..726fe28
--- /dev/null
+++ b/particles/particles/Dockerfile
@@ -0,0 +1,8 @@
+FROM gcr.io/skia-public/basealpine:3.8
+
+COPY . /
+
+USER skia
+
+ENTRYPOINT ["/usr/local/bin/particles"]
+CMD ["--logtostderr", "--resources_dir=/usr/local/share/particles"]
diff --git a/skfe/sys/skia_org_nginx b/skfe/sys/skia_org_nginx
index 641a77c..b4afebe 100644
--- a/skfe/sys/skia_org_nginx
+++ b/skfe/sys/skia_org_nginx
@@ -1631,3 +1631,24 @@
     server_name api.skia.org;
     return 301 https://api.skia.org$request_uri;
 }
+
+#####   particles.skia.org   ###########################
+server {
+    listen      443;
+    server_name particles.skia.org;
+
+    ssl on;
+
+    access_log /var/log/nginx/particles.access.log;
+    error_log /var/log/nginx/particles.error.log error;
+
+    location / {
+        proxy_pass https://35.201.76.220;
+        proxy_set_header Host $host;
+    }
+}
+server {
+    listen      80;
+    server_name particles.skia.org;
+    return 301 https://particles.skia.org$request_uri;
+}
diff --git a/skottie/Makefile b/skottie/Makefile
index 1434ed3..072264a 100644
--- a/skottie/Makefile
+++ b/skottie/Makefile
@@ -12,7 +12,7 @@
 	./build_release
 
 release_ci: release_ci_fixed
-	echo "using a fixed skottie"
+	echo "using a fixed canvaskit"
 
 release_ci_tot: app
 	# Assumes the cloud builder environment mounts the wasm outputs to /OUT
diff --git a/skottie/build_release b/skottie/build_release
index 81b2140..b9fdeda 100755
--- a/skottie/build_release
+++ b/skottie/build_release
@@ -10,10 +10,6 @@
 INSTALL_DIR="install -d --verbose --backup=none"
 ${INSTALL} --mode=644 -T ${APPNAME}/Dockerfile    ${ROOT}/Dockerfile
 ${INSTALL} --mode=755 -T ${GOPATH}/bin/${APPNAME} ${ROOT}/usr/local/bin/${APPNAME}
-${INSTALL_DIR} --mode=755                         ${ROOT}/usr/local/share/${APPNAME}
-${INSTALL_DIR} --mode=755                         ${ROOT}/usr/local/share/${APPNAME}/img
-${INSTALL} --mode=644 ./dist/img/*                ${ROOT}/usr/local/share/${APPNAME}/img
-# install fails if there's a directory it ignores (e.g. dist/img) so we ignore the return value
-${INSTALL} --mode=644 ./dist/*                    ${ROOT}/usr/local/share/${APPNAME} || true
+(cd ./dist/ && find . -type f -exec ${INSTALL} "{}" "${ROOT}/usr/local/share/${APPNAME}/{}" \;)
 }
 source ../bash/docker_build.sh
diff --git a/skottie/create-skottie-internal-sa.sh b/skottie/create-skottie-internal-sa.sh
index 4cc0ca6..73cde0c 100755
--- a/skottie/create-skottie-internal-sa.sh
+++ b/skottie/create-skottie-internal-sa.sh
@@ -12,5 +12,6 @@
 cd /tmp/ramdisk
 gcloud iam service-accounts create "${SA_NAME}" --display-name="Read-write access to GCS for skottie-internal server."
 gcloud beta iam service-accounts keys create ${SA_NAME}.json --iam-account="${SA_NAME}@${PROJECT_SUBDOMAIN}.iam.gserviceaccount.com"
+gsutil acl ch -u "${SA_NAME}@${PROJECT_SUBDOMAIN}.iam.gserviceaccount.com:W" gs://skottie-renderer-internal
 kubectl create secret generic "${SA_NAME}" --from-file=key.json=${SA_NAME}.json
 cd -
diff --git a/skottie/create-skottie-sa.sh b/skottie/create-skottie-sa.sh
index ac76911..35cc82b 100644
--- a/skottie/create-skottie-sa.sh
+++ b/skottie/create-skottie-sa.sh
@@ -11,5 +11,6 @@
 cd /tmp/ramdisk
 gcloud iam service-accounts create "${SA_NAME}" --display-name="Read-write access to GCS for skottie server."
 gcloud beta iam service-accounts keys create ${SA_NAME}.json --iam-account="${SA_NAME}@${PROJECT_SUBDOMAIN}.iam.gserviceaccount.com"
+gsutil acl ch -u "${SA_NAME}@${PROJECT_SUBDOMAIN}.iam.gserviceaccount.com:W" gs://skottie-renderer
 kubectl create secret generic "${SA_NAME}" --from-file=key.json=${SA_NAME}.json
 cd -