Launch https://api.skia.org server for doxygen docs.
Bug: skia:
Change-Id: Ic77007039837ee8ecae5a7bc2cf684caefb06fa2
Reviewed-on: https://skia-review.googlesource.com/c/buildbot/+/199247
Reviewed-by: Ravi Mistry <rmistry@google.com>
Commit-Queue: Joe Gregorio <jcgregorio@google.com>
diff --git a/api/Makefile b/api/Makefile
new file mode 100644
index 0000000..8c87941
--- /dev/null
+++ b/api/Makefile
@@ -0,0 +1,15 @@
+.PHONY: build docs release push
+build:
+ go install ./go/api
+
+docs:
+ cd ${SKIA}/tools/doxygen; doxygen ./Doxyfile
+
+release:
+ CGO_ENABLED=0 GOOS=linux go install -a ./go/api
+ ./build_docker_release
+
+push: release skia-public
+ pushk api
+
+include ../make/clusters.mk
diff --git a/api/README.md b/api/README.md
new file mode 100644
index 0000000..c90c769
--- /dev/null
+++ b/api/README.md
@@ -0,0 +1,7 @@
+api.skia.org
+============
+
+This application serves the Doxygen documentation for the Skia library.
+
+You must set the SKIA environment variable to point at a local
+checkout of the Skia library to build a release.
diff --git a/api/api/Dockerfile b/api/api/Dockerfile
new file mode 100644
index 0000000..a7c49f2
--- /dev/null
+++ b/api/api/Dockerfile
@@ -0,0 +1,10 @@
+FROM gcr.io/skia-public/basealpine:3.8
+
+USER root
+
+COPY . /
+
+USER skia
+
+ENTRYPOINT ["/usr/local/bin/api"]
+CMD ["--logtostderr", "--resources_dir=/usr/local/share/api/docs/"]
diff --git a/api/build_docker_release b/api/build_docker_release
new file mode 100755
index 0000000..113b5e4
--- /dev/null
+++ b/api/build_docker_release
@@ -0,0 +1,15 @@
+#!/bin/bash
+APPNAME=api
+
+set -x -e
+
+# Copy files into the right locations in ${ROOT}.
+copy_release_files()
+{
+INSTALL="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 /tmp/doxygen/html && find . -type f -exec ${INSTALL} "{}" "${ROOT}/usr/local/share/${APPNAME}/docs/{}" \;)
+}
+
+source ../bash/docker_build.sh
diff --git a/api/go/api/main.go b/api/go/api/main.go
new file mode 100644
index 0000000..84ef917
--- /dev/null
+++ b/api/go/api/main.go
@@ -0,0 +1,39 @@
+package main
+
+import (
+ "flag"
+ "net/http"
+
+ "github.com/gorilla/mux"
+ "go.skia.org/infra/go/common"
+ "go.skia.org/infra/go/httputils"
+ "go.skia.org/infra/go/sklog"
+)
+
+// flags
+var (
+ local = flag.Bool("local", false, "Running locally if true. As opposed to in production.")
+ port = flag.String("port", ":8000", "HTTP service address (e.g., ':8000')")
+ promPort = flag.String("prom_port", ":20000", "Metrics service address (e.g., ':10110')")
+ resourcesDir = flag.String("resources_dir", "", "The directory to find templates, JS, and CSS files. If blank the current directory will be used.")
+)
+
+func main() {
+ common.InitWithMust(
+ "api",
+ common.PrometheusOpt(promPort),
+ common.MetricsLoggingOpt(),
+ )
+
+ r := mux.NewRouter()
+ r.PathPrefix("/").Handler(http.HandlerFunc(httputils.MakeResourceHandler(*resourcesDir)))
+
+ h := httputils.LoggingGzipRequestResponse(r)
+ if !*local {
+ h = httputils.HealthzAndHTTPS(h)
+ }
+
+ http.Handle("/", h)
+ sklog.Infoln("Ready to serve.")
+ sklog.Fatal(http.ListenAndServe(*port, nil))
+}
diff --git a/skfe/sys/skia_org_nginx b/skfe/sys/skia_org_nginx
index 688d028..641a77c 100644
--- a/skfe/sys/skia_org_nginx
+++ b/skfe/sys/skia_org_nginx
@@ -1611,3 +1611,23 @@
}
}
+##### api.skia.org ###########################
+server {
+ listen 443;
+ server_name api.skia.org;
+
+ ssl on;
+
+ access_log /var/log/nginx/api.access.log;
+ error_log /var/log/nginx/api.error.log error;
+
+ location / {
+ proxy_pass https://35.201.76.220;
+ proxy_set_header Host $host;
+ }
+}
+server {
+ listen 80;
+ server_name api.skia.org;
+ return 301 https://api.skia.org$request_uri;
+}