Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding prod aws config and auto-deploy on merges to syntehtix-prod br… #104

Merged
merged 1 commit into from
Apr 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/synthetix-prod-ecr-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Build & Tag Container, Push to ECR, Deploy to UAT

on:
push:
branches:
- synthetix-prod

jobs:
build:
name: Build, Tag & push to ECR, Deploy to PROD
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v1

- name: Install Dependencies
run: yarn install

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_CI_USER_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_CI_USER_SECRET_ACCESS_KEY }}
aws-region: us-east-2

- name: Build, tag, and push Geth to ECR
env:
AWS_ACCOUNT_NUMBER: ${{ secrets.AWS_CI_AWS_ACCOUNT_ID }}
run: ./docker/publish-geth-container.sh synthetix-uat

- name: Build, tag, and push Full Node to ECR
env:
AWS_ACCOUNT_NUMBER: ${{ secrets.AWS_CI_AWS_ACCOUNT_ID }}
run: ./docker/publish-rollup-fullnode-container.sh synthetix-uat

- name: Stop existing ECS tasks to auto-start task with new image
run: |
./.github/scripts/stop-ecs-task.sh synthetix-uat-web synthetix-prod-web
./.github/scripts/stop-ecs-task.sh synthetix-uat-geth synthetix-prod-geth


- name: Logout of Amazon ECR
if: always()
run: docker logout ${{ steps.login-ecr.outputs.registry }}
33 changes: 33 additions & 0 deletions aws/synthetix/prod/geth/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Deploying L2 Geth node to Synthetix PROD

## Prerequisites
See prerequisites from parent AWS directory.

## Steps

### 1) Configure the Amazon ECS CLI
1. Create a cluster configuration:
```
ecs-cli configure --cluster synthetix-prod-geth --default-launch-type EC2 --config-name synthetix-prod-geth-config --region us-east-2
```

2. Create a profile to use to create the environment
```
ecs-cli configure profile --access-key <your access key here> --secret-key <your secret here> --profile-name synthetix-prod-geth-profile
```

### 2) Create the Cluster
```
ecs-cli up --keypair synthetix-prod --capability-iam --size 1 --instance-type c5.4xlarge --cluster-config synthetix-prod-geth-config --ecs-profile synthetix-prod-geth-profile --port 9545 --security-group <security group ID> --vpc <vpc ID> --subnets <comma-separated subnet IDs>
```

This may take a few minutes to finish. The result will be a fully provisioned EC2 instance on which your service/task will be deployed.

### 3) Choose the appropriate `docker-compose.yml` and `ecs-params.yml`
For the rest of the commands, you'll need to be in this directory to use the `docker-compose.yml` and an `ecs-params.yml`.
Make any necessary changes now.

### 4) Deploy Service & Task to Cluster & register service discovery.
```
ecs-cli compose --project-name synthetix-prod-geth service up --private-dns-namespace synthetix-prod --vpc <vpc ID> --enable-service-discovery --cluster-config synthetix-prod-geth-config --ecs-profile synthetix-prod-geth-profile --create-log-groups
```
25 changes: 25 additions & 0 deletions aws/synthetix/prod/geth/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
version: "3"
services:
geth_l2:
image: <aws_account_id>.dkr.ecr.us-east-2.amazonaws.com/optimism/geth:synthetix-prod
volumes:
- l2-node-data:/mnt/l2-node/l2:rw
environment:
- CLEAR_DATA_KEY
- VOLUME_PATH=/mnt/l2-node/l2
- HOSTNAME=0.0.0.0
- PORT=9545
- NETWORK_ID=108
ports:
- 9545:9545

logging:
driver: awslogs
options:
awslogs-group: sythetix-prod-geth
awslogs-region: us-east-2
awslogs-stream-prefix: geth

volumes:
l2-node-data:

34 changes: 34 additions & 0 deletions aws/synthetix/prod/geth/ecs-params.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
version: 1
task_definition:
services:
geth_l2:
essential: true
# healthcheck:
# test: ["CMD-SHELL", "curl -f -H \"Content-Type: application/json\" -d '{\"jsonrpc\": \"2.0\", \"id\": 9999999, \"method\": \"net_version\"}' http://localhost:9545/ || exit 1"]
# interval: 10s
# timeout: 5s
# retries: 3
# start_period: 10s
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this used for?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not currently. Was to be a health check, but the container has successfully stopped and restarted anytime there's a issue with geth, so it's not needed.

mem_limit: 32653700000


ecs_network_mode: awsvpc
docker_volumes:
- name: l2-node-data
scope: shared
autoprovision: true
driver: 'local'

run_params:
network_configuration:
awsvpc_configuration:
subnets:
- <subnet(s) here>
security_groups:
- <security group(s) here>
service_discovery_service:
name: 'geth'
description: 'Synthetix PROD Geth Service Discovery'
dns_config:
type: 'A'
ttl: 60
33 changes: 33 additions & 0 deletions aws/synthetix/prod/web/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Deploying Web RPC Server to Synthetix PROD

## Prerequisites
See prerequisites from parent AWS directory.

## Steps

### 1) Configure the Amazon ECS CLI
1. Create a cluster configuration:
```
ecs-cli configure --cluster synthetix-prod-web --default-launch-type EC2 --config-name synthetix-prod-web-config --region us-east-2
```

2. Create a profile to use to create the environment
```
ecs-cli configure profile --access-key <your access key here> --secret-key <your secret here> --profile-name synthetix-prod-web-profile
```

### 2) Create the Cluster
```
ecs-cli up --keypair synthetix-prod --capability-iam --size 1 --instance-type c5.xlarge --cluster-config synthetix-prod-web-config --ecs-profile synthetix-prod-web-profile --port 8545 --security-group <security group ID> --vpc <vpc ID> --subnets <comma-separated subnet IDs>
```

This may take a few minutes to finish. The result will be a fully provisioned EC2 instance on which your service/task will be deployed.

### 3) Choose the appropriate `docker-compose.yml` and `ecs-params.yml`
For the rest of the commands, you'll need to be in this directory to use the `docker-compose.yml` and an `ecs-params.yml`.
Make any necessary changes now.

### 4) Deploy Service & Task to Cluster
```
ecs-cli compose --project-name synthetix-prod-web service up --vpc <vpc ID> --cluster-config synthetix-prod-web-config --ecs-profile synthetix-prod-web-profile --create-log-groups
```
29 changes: 29 additions & 0 deletions aws/synthetix/prod/web/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
version: "3"
services:
rollup-full-node:
image: <aws_account_id>.dkr.ecr.us-east-2.amazonaws.com/optimism/rollup-full-node:synthetix-prod
volumes:
- full-node-data:/mnt/full-node:rw
- l1-node-data:/mnt/l1-node:rw
ports:
- 8545:8545
environment:
- CLEAR_DATA_KEY
- STARTUP_WAIT_TIMEOUT=60
- LOCAL_L1_NODE_PERSISTENT_DB_PATH=/mnt/l1-node
- L2_RPC_SERVER_PERSISTENT_DB_PATH=/mnt/full-node/level
- L2_WALLET_PRIVATE_KEY=0x29f3edee0ad3abf8e2699402e0e28cd6492c9be7eaab00d732a791c33552f797
- L2_NODE_WEB3_URL=http://synthetix-prod-geth.synthetix-prod:9545

logging:
driver: awslogs
options:
awslogs-group: synthetix-prod-web
awslogs-region: us-east-2
awslogs-stream-prefix: web

volumes:
full-node-data:
l1-node-data:
l2-node-data:

24 changes: 24 additions & 0 deletions aws/synthetix/prod/web/ecs-params.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: 1
task_definition:
services:
rollup-full-node:
essential: true
healthcheck:
test: ["CMD-SHELL", "curl -f -H \"Content-Type: application/json\" -d '{\"jsonrpc\": \"2.0\", \"id\": 9999999, \"method\": \"net_version\"}' http://localhost:8545/ || exit 1"]
interval: 10s
timeout: 5s
retries: 3
start_period: 5s
mem_limit: 7680000000


ecs_network_mode: host
docker_volumes:
- name: l1-node-data
scope: task
driver: 'local'
- name: full-node-data
scope: shared
autoprovision: true
driver: 'local'

10 changes: 1 addition & 9 deletions aws/synthetix/uat/geth/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,11 @@ services:
volumes:
- l2-node-data:/mnt/l2-node/l2:rw
environment:
- CLEAR_DATA_KEY=aaa
- CLEAR_DATA_KEY
- VOLUME_PATH=/mnt/l2-node/l2
- HOSTNAME=0.0.0.0
- PORT=9545
- NETWORK_ID=108
- PRIVATE_KEY=0x29f3edee0ad3abf8e2699402e0e28cd6492c9be7eaab00d732a791c33552f797
- SEALER_PRIVATE_KEY_PATH_SUFFIX=/sealer_private_key.txt
- PRIVATE_KEY_PATH_SUFFIX=/private_key.txt
- ADDRESS_PATH_SUFFIX=/address.txt
- SEALER_ADDRESS_PATH_SUFFIX=/sealer_address.txt
- INITIAL_BALANCE=0x200000000000000000000000000000000000000000000000000000000000000
- GENESIS_PATH=etc/rollup-fullnode.json
- SETUP_RUN_PATH_SUFFIX=/setup_run.txt
ports:
- 9545:9545

Expand Down
2 changes: 1 addition & 1 deletion aws/synthetix/uat/geth/ecs-params.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ task_definition:
# timeout: 5s
# retries: 3
# start_period: 10s
mem_limit: 32889600000
mem_limit: 32653700000


ecs_network_mode: awsvpc
Expand Down