Add Docker Container Images for beacon-chain and client (#314)

* Add docker container images for beacon-chain and client

* Add docker section to README
This commit is contained in:
Preston Van Loon 2018-07-22 13:31:43 -04:00 committed by GitHub
parent 3abfb77b87
commit 48b047fd61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 87 additions and 0 deletions

View File

@ -52,6 +52,12 @@ matrix:
install: true # Skip install go packages.
script:
# Ensure everything builds
- |
bazel \
--bazelrc=.travis-bazelrc \
build \
//...
# Run all tests.
- |
bazel \

View File

@ -139,6 +139,33 @@ bazel run //client -- \
Omitting the `--actor` flag will launch a simple observer service attached to the sharding client that is able to listen to changes happening throughout the sharded Ethereum network on shard 0.
## Running via Docker
To run the client within a docker container, use the `//client:image` target.
```text
bazel run //client:image
INFO: Build options have changed, discarding analysis cache.
INFO: Analysed target //client:image (306 packages loaded).
INFO: Found 1 target...
Target //client:image up-to-date:
bazel-bin/client/image-layer.tar
INFO: Elapsed time: 8.568s, Critical Path: 0.22s
INFO: 0 processes.
INFO: Build completed successfully, 1 total action
INFO: Build completed successfully, 1 total action
37fd88e7190b: Loading layer 22.42MB/22.42MB
Loaded image ID: sha256:89b233de1a026eddeeff010fa1ef596ce791cb3f26488150aac72a91b80734c1
Tagging 89b233de1a026eddeeff010fa1ef596ce791cb3f26488150aac72a91b80734c1 as bazel/client:image
...
```
TODO: Add [container_push](https://github.com/bazelbuild/rules_docker/#container_push-1)
targets for the container images such that they can be pulled from GCR or
dockerhub.
# Making Changes
## Rebuilding the Sharding Manager Contract Bindings

View File

@ -12,6 +12,13 @@ http_archive(
sha256 = "bc653d3e058964a5a26dcad02b6c72d7d63e6bb88d94704990b908a1445b8758",
)
http_archive(
name = "io_bazel_rules_docker",
sha256 = "6dede2c65ce86289969b907f343a1382d33c14fbce5e30dd17bb59bb55bb6593",
strip_prefix = "rules_docker-0.4.0",
urls = ["https://github.com/bazelbuild/rules_docker/archive/v0.4.0.tar.gz"],
)
load("@io_bazel_rules_go//go:def.bzl", "go_rules_dependencies", "go_register_toolchains")
go_rules_dependencies()
@ -22,6 +29,15 @@ load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies", "go_repository")
gazelle_dependencies()
load(
"@io_bazel_rules_docker//go:image.bzl",
_go_image_repos = "repositories",
)
_go_image_repos()
# External dependencies
go_repository(
name = "com_github_ethereum_go_ethereum",
importpath = "github.com/ethereum/go-ethereum",

View File

@ -1,4 +1,5 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
load("@io_bazel_rules_docker//go:image.bzl", "go_image")
go_library(
name = "go_default_library",
@ -16,6 +17,24 @@ go_library(
],
)
go_image(
name = "image",
srcs = ["main.go"],
goarch = "amd64",
goos = "linux",
importpath = "github.com/prysmaticlabs/prysm/beacon-chain",
static = "on",
deps = [
"//beacon-chain/node:go_default_library",
"//beacon-chain/utils:go_default_library",
"//shared/cmd:go_default_library",
"//shared/debug:go_default_library",
"@com_github_sirupsen_logrus//:go_default_library",
"@com_github_urfave_cli//:go_default_library",
"@com_github_x_cray_logrus_prefixed_formatter//:go_default_library",
],
)
go_binary(
name = "beacon-chain",
embed = [":go_default_library"],

View File

@ -1,4 +1,5 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
load("@io_bazel_rules_docker//go:image.bzl", "go_image")
go_library(
name = "go_default_library",
@ -16,6 +17,24 @@ go_library(
],
)
go_image(
name = "image",
srcs = ["main.go"],
goarch = "amd64",
goos = "linux",
importpath = "github.com/prysmaticlabs/prysm/client",
static = "on",
deps = [
"//client/node:go_default_library",
"//client/utils:go_default_library",
"//shared/cmd:go_default_library",
"//shared/debug:go_default_library",
"@com_github_sirupsen_logrus//:go_default_library",
"@com_github_urfave_cli//:go_default_library",
"@com_github_x_cray_logrus_prefixed_formatter//:go_default_library",
],
)
go_binary(
name = "client",
embed = [":go_default_library"],