Skip to content

Commit 47bf243

Browse files
committed
cleanup pull request before merge
1 parent a034fba commit 47bf243

File tree

4 files changed

+31
-29
lines changed

4 files changed

+31
-29
lines changed

examples/deployment/README.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,30 @@ Want to deploy/use the Trillian General Transparency project in the cloud? Here
1010
Both build and example deployment files are stored within this repo. For any of the below deployment methods, start here:
1111

1212
```shell
13-
git clone git@github.com:google/trillian.git
13+
git clone https://github.com/google/trillian.git/
1414
cd trillian
1515
```
1616

1717
## Local Deployments
1818

1919
**Run With Docker Compose**
2020

21-
For simple deployments running in a container is an easy way to get up and running with a local database. To use Docker to run and interact with Trillian, start here:
21+
For simple deployments, running in a container is an easy way to get up and running with a local database. To use Docker to run and interact with Trillian, start here:
2222

23-
Set a random password and bring up the services defined in the provided compose file. This includes a local mysql database database, a one-shot container to create the schema and the trillian server:
23+
Set a random password and bring up the services defined in the provided compose file. This includes a local MySQL database, a one-shot container to create the schema and the trillian server:
2424

2525
```shell
2626
# Set a random password
2727
export DB_PASSWORD="$(openssl rand -hex 16)"
2828

2929
# Bring up services defined in this compose file. This includes:
30-
# - local MySQL databse
31-
# - container to seed the database
30+
# - local MySQL database
31+
# - container to initialize the database
3232
# - the trillian server
3333
docker-compose -f examples/deployment/docker-compose.yml up
3434
```
3535

36-
Verify that your local installation by checking the metrics endpoint:
36+
Verify that your local installation is working by checking the metrics endpoint:
3737

3838
```shell
3939
curl localhost:8091/metrics
@@ -52,13 +52,14 @@ TODO
5252
With a pair of AWS keys [accessible to Terraform](https://www.terraform.io/docs/providers/aws/), this template deploys a simple Trillian setup in AWS using EC2 and RDS MySQL.
5353

5454
```shell
55+
cd examples/deployment/aws/
56+
5557
# Set a random password
5658
export TF_VAR_DB_PASSWORD="$(openssl rand -hex 16)"
57-
export TF_VAR_ingress_cidr="0.0.0.0/0"
58-
# Create Resources
59-
cd examples/deployment/aws/
59+
# Substitute this variable with a block you'll be accessing from
60+
export TF_VAR_WHITELIST_CIDR="0.0.0.0/0"
6061

61-
# Review and Apply Changes
62+
# Review and Create Resources
6263
terraform plan
6364
terraform apply
6465
```

examples/deployment/aws/terraform.tf

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
variable "ingress_cidr" {
1+
variable "WHITELIST_CIDR" {
22
description="Your IP block to whitelist access from"
33
}
44
variable "DB_PASSWORD" { }
@@ -40,7 +40,7 @@ resource "aws_security_group" "trillian_db" {
4040
from_port = 3306
4141
to_port = 3306
4242
protocol = "tcp"
43-
cidr_blocks = ["${var.ingress_cidr}"]
43+
cidr_blocks = ["${var.WHITELIST_CIDR}"]
4444
}
4545

4646
ingress {
@@ -89,13 +89,13 @@ resource "aws_security_group" "trillian" {
8989
from_port = 8090
9090
to_port = 8091
9191
protocol = "tcp"
92-
cidr_blocks = ["${var.ingress_cidr}"]
92+
cidr_blocks = ["${var.WHITELIST_CIDR}"]
9393
}
9494
ingress {
9595
from_port = 22
9696
to_port = 22
9797
protocol = "tcp"
98-
cidr_blocks = ["${var.ingress_cidr}"]
98+
cidr_blocks = ["${var.WHITELIST_CIDR}"]
9999
}
100100

101101
egress {
@@ -128,15 +128,11 @@ yum install -y git mysql
128128
curl -o /tmp/go.tar.gz https://storage.googleapis.com/golang/go1.8.3.linux-amd64.tar.gz
129129
tar -C /usr/local -xzf /tmp/go.tar.gz
130130
export PATH=$PATH:/usr/local/go/bin
131-
132131
mkdir -p /go
133132
export GOPATH=/go
134133
135134
# Install Trillian
136-
mkdir -p /go/src/github.com/google/trillian
137-
git clone https://github.com/google/trillian.git /go/src/github.com/google/trillian
138-
cd /go/src/github.com/google/trillian
139-
go get ./server/trillian_map_server
135+
go get github.com/google/trillian/server/trillian_log_server
140136
141137
# Setup the DB
142138
cd /go/src/github.com/google/trillian
@@ -149,8 +145,8 @@ export DB_DATABASE=test
149145
# Startup the Server
150146
RPC_PORT=8090
151147
HTTP_PORT=8091
152-
/go/bin/trillian_map_server \
153-
--mysql_uri="$DB_USER:$DB_PASSWORD@tcp($DB_HOST:3306)/$DB_DATABASE" \
148+
/go/bin/trillian_log_server \
149+
--mysql_uri="${DB_USER}:${DB_PASSWORD}@tcp(${DB_HOST})/${DB_DATABASE}" \
154150
--rpc_endpoint="$HOST:$RPC_PORT" \
155151
--http_endpoint="$HOST:$HTTP_PORT" \
156152
--alsologtostderr

examples/deployment/docker/db_client/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ RUN apt-get update && \
66
ADD . /go/src/github.com/google/trillian
77
WORKDIR /go/src/github.com/google/trillian
88

9-
RUN go get -v ./server/trillian_log_server
10-
119
ENV DB_USER=test \
1210
DB_PASSWORD=zaphod \
1311
DB_DATABASE=test
1412

13+
# This is used to wait for new MySQL deployments to become ready e.g.
14+
# ./wait-for-it.sh localhost:3306 -- mysql
1515
RUN ./examples/deployment/scripts/download-wait-for-it.sh
1616

1717
CMD [ 'mysql' ]

scripts/resetdb.sh

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ collect_vars() {
1414
# set unset environment variables to defaults
1515
[ -z ${DB_USER+x} ] && DB_USER="root"
1616
[ -z ${DB_NAME+x} ] && DB_NAME="test"
17-
# format reused supplied environment variables
17+
# set defaults
1818
FLAGS=""
19-
[ -z ${DB_PASSWORD+x} ] || FLAGS="${FLAGS} -p$DB_PASSWORD"
2019

2120
# handle flags
2221
FORCE=false
@@ -29,6 +28,12 @@ collect_vars() {
2928
esac
3029
shift 1
3130
done
31+
32+
# Optionally print flags (before appending password)
33+
[[ ${VERBOSE} = 'true' ]] && echo "- Using MySQL Flags: ${FLAGS}"
34+
35+
# append password if supplied
36+
[ -z ${DB_PASSWORD+x} ] || FLAGS="${FLAGS} -p'${DB_PASSWORD}'"
3237
}
3338

3439
main() {
@@ -48,10 +53,10 @@ main() {
4853
if [ -z ${REPLY+x} ] || [[ $REPLY =~ ^[Yy]$ ]]
4954
then
5055
echo "Resetting DB..."
51-
mysql -u $DB_USER $FLAGS -e "DROP DATABASE IF EXISTS ${DB_NAME};"
52-
mysql -u $DB_USER $FLAGS -e "CREATE DATABASE ${DB_NAME};"
53-
mysql -u $DB_USER $FLAGS -e "GRANT ALL ON ${DB_NAME}.* TO '${DB_NAME}'@'localhost' IDENTIFIED BY 'zaphod';"
54-
mysql -u $DB_USER $FLAGS -D ${DB_NAME} < ${TRILLIAN_PATH}/storage/mysql/storage.sql
56+
mysql -u $FLAGS $DB_USER -e "DROP DATABASE IF EXISTS ${DB_NAME};"
57+
mysql -u $FLAGS $DB_USER -e "CREATE DATABASE ${DB_NAME};"
58+
mysql -u $FLAGS $DB_USER -e "GRANT ALL ON ${DB_NAME}.* TO '${DB_NAME}'@'localhost' IDENTIFIED BY 'zaphod';"
59+
mysql -u $FLAGS $DB_USER -D ${DB_NAME} < ${TRILLIAN_PATH}/storage/mysql/storage.sql
5560
echo "Reset Complete"
5661
fi
5762
}

0 commit comments

Comments
 (0)