File tree Expand file tree Collapse file tree 11 files changed +726
-0
lines changed Expand file tree Collapse file tree 11 files changed +726
-0
lines changed Original file line number Diff line number Diff line change
1
+ bin /*
2
+ cluster /*
Original file line number Diff line number Diff line change
1
+ bin /*
2
+ cluster /*
Original file line number Diff line number Diff line change
1
+ FROM ubuntu:xenial
2
+
3
+ # install build + test dependencies
4
+ RUN apt-get update && \
5
+ apt-get install --yes --no-install-recommends \
6
+ ca-certificates \
7
+ curl \
8
+ fuse \
9
+ g++ \
10
+ gcc \
11
+ git \
12
+ iproute2 \
13
+ iputils-ping \
14
+ less \
15
+ libc6-dev \
16
+ make \
17
+ pkg-config \
18
+ && \
19
+ apt-get clean
20
+
21
+ # install Go
22
+ ENV GO_VERSION 1.8.1
23
+ RUN curl -fSLo golang.tar.gz "https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz" && \
24
+ tar -xzf golang.tar.gz -C /usr/local && \
25
+ rm golang.tar.gz
26
+ ENV GOPATH /go
27
+ ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH
28
+
29
+ # install docker CLI
30
+ RUN curl -fSLo docker.tar.gz https://get.docker.com/builds/Linux/x86_64/docker-17.04.0-ce.tgz && \
31
+ tar -xzf docker.tar.gz -C /usr/local/bin --strip-components=1 docker/docker && \
32
+ rm docker.tar.gz
33
+
34
+ # install jq
35
+ RUN curl -fSLo /usr/local/bin/jq https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64 && \
36
+ chmod +x /usr/local/bin/jq
37
+
38
+ # install govendor
39
+ RUN go get -u github.com/kardianos/govendor
40
+
41
+ # add custom bashrc
42
+ ADD bashrc /root/.bashrc
Original file line number Diff line number Diff line change
1
+ .PHONY : build cluster test
2
+
3
+ default : build
4
+
5
+ build :
6
+ go build -o bin/swarm github.com/ethereum/go-ethereum/cmd/swarm
7
+ go build -o bin/geth github.com/ethereum/go-ethereum/cmd/geth
8
+ go build -o bin/bootnode github.com/ethereum/go-ethereum/cmd/bootnode
9
+
10
+ cluster : build
11
+ scripts/boot-cluster.sh
12
+
13
+ test :
14
+ go test -v github.com/ethereum/go-ethereum/swarm/...
Original file line number Diff line number Diff line change
1
+ Swarm development environment
2
+ =============================
3
+
4
+ The Swarm development environment is a Linux bash shell which can be run in a
5
+ Docker container and provides a predictable build and test environment.
6
+
7
+ ### Start the Docker container
8
+
9
+ Run the ` run.sh ` script to build the Docker image and run it, you will then be
10
+ at a bash prompt inside the ` swarm/dev ` directory.
11
+
12
+ ### Build binaries
13
+
14
+ Run ` make ` to build the ` swarm ` , ` geth ` and ` bootnode ` binaries into the
15
+ ` swarm/dev/bin ` directory.
16
+
17
+ ### Boot a cluster
18
+
19
+ Run ` make cluster ` to start a 3 node Swarm cluster, or run
20
+ ` scripts/boot-cluster.sh --size N ` to boot a cluster of size N.
Original file line number Diff line number Diff line change
1
+ export ROOT=" ${GOPATH} /src/github.com/ethereum/go-ethereum"
2
+ export PATH=" ${ROOT} /swarm/dev/bin:${PATH} "
3
+
4
+ cd " ${ROOT} /swarm/dev"
5
+
6
+ cat << WELCOME
7
+
8
+ =============================================
9
+
10
+ Welcome to the swarm development environment.
11
+
12
+ - Run 'make' to build the swarm, geth and bootnode binaries
13
+ - Run 'make test' to run the swarm unit tests
14
+ - Run 'make cluster' to start a swarm cluster
15
+ - Run 'exit' to exit the development environment
16
+
17
+ See the 'scripts' directory for some useful scripts.
18
+
19
+ =============================================
20
+
21
+ WELCOME
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+ #
3
+ # A script to build and run the Swarm development environment using Docker.
4
+
5
+ set -e
6
+
7
+ ROOT=" $( cd " $( dirname " $0 " ) /../.." && pwd) "
8
+
9
+ # DEFAULT_NAME is the default name for the Docker image and container
10
+ DEFAULT_NAME=" swarm-dev"
11
+
12
+ usage () {
13
+ cat >&2 << USAGE
14
+ usage: $0 [options]
15
+
16
+ Build and run the Swarm development environment.
17
+
18
+ Depends on Docker being installed locally.
19
+
20
+ OPTIONS:
21
+ -n, --name NAME Docker image and container name [default: ${DEFAULT_NAME} ]
22
+ -d, --docker-args ARGS Custom args to pass to 'docker run' (e.g. '-p 8000:8000' to expose a port)
23
+ -h, --help Show this message
24
+ USAGE
25
+ }
26
+
27
+ main () {
28
+ local name=" ${DEFAULT_NAME} "
29
+ local docker_args=" "
30
+ parse_args " $@ "
31
+ build_image
32
+ run_image
33
+ }
34
+
35
+ parse_args () {
36
+ while true ; do
37
+ case " $1 " in
38
+ -h | --help)
39
+ usage
40
+ exit 0
41
+ ;;
42
+ -n | --name)
43
+ if [[ -z " $2 " ]]; then
44
+ echo " ERROR: --name flag requires an argument" >&2
45
+ exit 1
46
+ fi
47
+ name=" $2 "
48
+ shift 2
49
+ ;;
50
+ -d | --docker-args)
51
+ if [[ -z " $2 " ]]; then
52
+ echo " ERROR: --docker-args flag requires an argument" >&2
53
+ exit 1
54
+ fi
55
+ docker_args=" $2 "
56
+ shift 2
57
+ ;;
58
+ * )
59
+ break
60
+ ;;
61
+ esac
62
+ done
63
+
64
+ if [[ $# -ne 0 ]]; then
65
+ usage
66
+ echo " ERROR: invalid arguments" >&2
67
+ exit 1
68
+ fi
69
+ }
70
+
71
+ build_image () {
72
+ docker build --tag " ${name} " " ${ROOT} /swarm/dev"
73
+ }
74
+
75
+ run_image () {
76
+ exec docker run \
77
+ --privileged \
78
+ --interactive \
79
+ --tty \
80
+ --rm \
81
+ --hostname " ${name} " \
82
+ --name " ${name} " \
83
+ --volume " ${ROOT} :/go/src/github.com/ethereum/go-ethereum" \
84
+ --volume " /var/run/docker.sock:/var/run/docker.sock" \
85
+ ${docker_args} \
86
+ " ${name} " \
87
+ /bin/bash
88
+ }
89
+
90
+ main " $@ "
You can’t perform that action at this time.
0 commit comments