[bazel] Add skia_app_container macro.

This macro provides a convenient way to pack a Bazel-built app inside a Docker container based on gcr.io/skia-public/basealpine. It also generates a target to upload the resulting container to GCR.

Usage (see the skia_app_container docstring for more):

    # Built the app container and load it into Docker:
    $ bazel run //myapp:myapp_container

    # Debug the container:
    $ docker run -it --entrypoint /bin/sh bazel/myapp:myapp_container

    # Push the container to GCR:
    $ bazel run //myapp:push_myapp_container

Today, we build app containers by writing a Dockerfile, and a release.sh script that sources //bash/docker_build.sh to populate the container with any necessary files and upload it to GCR.

This macro is a functionally equivalent, Bazel-native alternative to the Dockerfile + release.sh combo. Its main advantage is that it pulls Bazel-built assets via their Bazel labels, instead of their (often clunky) paths under //_bazel_bin.

Examples showing the two approaches to build the same container:

 - Dockerfile + release script: https://skia-review.googlesource.com/c/buildbot/+/418840.
 - skia_app_container: https://skia-review.googlesource.com/c/buildbot/+/419137.

Skia Infrastructure engineers are free to use either approach as we migrate our apps to Bazel. That said, this macro can be easily extended to support things like setting environment variables and running arbitrary commands inside the container, which should support virtually all our use cases.

Bug: skia:11111
Change-Id: I25aed677d526828f6d11ea2483969748a1a6205b
Reviewed-on: https://skia-review.googlesource.com/c/buildbot/+/419136
Reviewed-by: Joe Gregorio <jcgregorio@google.com>
Commit-Queue: Leandro Lovisolo <lovisolo@google.com>
3 files changed
tree: af1859f67eb06667ddae695e51b488643eb3688e
  1. am/
  2. android_ingest/
  3. android_stats/
  4. api/
  5. autoroll/
  6. bash/
  7. bazel/
  8. blamer/
  9. bugs-central/
  10. codereview-watcher/
  11. comments/
  12. contestk/
  13. cq_watcher/
  14. ct/
  15. datahopper/
  16. debugger-app/
  17. demos/
  18. docker/
  19. docker_pushes_watcher/
  20. docs/
  21. docsyserver/
  22. dot/
  23. ds/
  24. external/
  25. fiddlek/
  26. firestore/
  27. get_service_account/
  28. git_cookie_authdaemon/
  29. gitsync/
  30. go/
  31. gold-client/
  32. golden/
  33. hashtag/
  34. html-template-minifier/
  35. infra/
  36. infra-sk/
  37. jsdoc/
  38. jsfiddle/
  39. k8s-checker/
  40. kube/
  41. leasing/
  42. licenses/
  43. machine/
  44. make/
  45. modules/
  46. named-fiddles/
  47. new_element/
  48. particles/
  49. perdiff/
  50. perf/
  51. periodic-trigger/
  52. power/
  53. proberk/
  54. promk/
  55. pulld/
  56. puppeteer-tests/
  57. push/
  58. scrap/
  59. scripts/
  60. shaders/
  61. sk/
  62. sk8s/
  63. skbug/
  64. skfe/
  65. skolo/
  66. skottie/
  67. status/
  68. switchboard/
  69. task_driver/
  70. task_scheduler/
  71. tools/
  72. tree_status/
  73. trybot_updater/
  74. velero/
  75. .bazelignore
  76. .bazelrc
  77. .eslintrc.js
  78. .gitattributes
  79. .gitignore
  80. .mocharc.json
  81. BUILD.bazel
  82. build_infra_prod.sh
  83. cipd.ensure
  84. codereview.settings
  85. DATASTORE.md
  86. DEPS
  87. elements-sk-scss.bzl
  88. go.mod
  89. go.sum
  90. go_repositories.bzl
  91. launch.md
  92. LICENSE
  93. Makefile
  94. package-lock.json
  95. package.json
  96. PRESUBMIT.py
  97. PRIVACY_POLICY.md
  98. README.md
  99. run_unittests
  100. run_unittests.go
  101. STYLEGUIDE.md
  102. tools.go
  103. tsconfig.json
  104. whitespace.txt
  105. WORKSPACE
README.md

Skia-Buildbot Repository

This repo contains infrastructure code for Skia.

Getting the Source Code

The main source code repository is a Git repository hosted at https://skia.googlesource.com/buildbot.git. It is possible to check out this repository directly with git clone or via go get.

Using git clone allows you to work in whatever directory you want. You will still need to set GOPATH in order to build some apps (recommended to put this in a cache dir). E.g.:

$ cd ${WORKDIR}
$ git clone https://skia.googlesource.com/buildbot.git
$ export GOPATH=${HOME}/.cache/gopath/$(basename ${WORKDIR})
$ mkdir $GOPATH
$ cd buildbot

Using go get will fetch the repository into your GOPATH directory along with all the Go dependencies. You will need to set GOPATH and GO111MODULE=on. E.g.:

$ export GOPATH=${WORKDIR}
$ export GO111MODULE=on
$ go get -u -t go.skia.org/infra/...
$ cd ${GOPATH}/src/go.skia.org/infra/

Note: go.skia.org is a custom import path and will only work if used like the examples here.

Install Node.js (not as root) and add the bin dir to your path. Optionally run npm install npm -g, as suggested by the npm getting started doc.

Install other dependencies:

$ sudo apt-get install python-django
$ go get -u github.com/kisielk/errcheck \
  golang.org/x/tools/cmd/goimports \
  go.chromium.org/luci/client/cmd/isolate

Build ~everything:

$ make all

Generated Code

Some code is generated using go generate with external binaries. First, install the version of protoc referenced in the asset creation script and ensure it is on your PATH before other versions of protoc.

Install the necessary go packages:

$ go get -u \
  github.com/golang/protobuf/protoc-gen-go \
  golang.org/x/tools/cmd/stringer \
  google.golang.org/grpc \

Get mockery and add it to your PATH.

To generate code run in this directory:

$ go generate ./...

Running unit tests

Install Cloud SDK.

Use this command to run the presubmit tests:

$ ./run_unittests --small