diff --git a/.github/workflows/synthetix-prod-ecr-deploy.yml b/.github/workflows/synthetix-prod-ecr-deploy.yml new file mode 100644 index 000000000000..779e34ba43c3 --- /dev/null +++ b/.github/workflows/synthetix-prod-ecr-deploy.yml @@ -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 }} diff --git a/aws/synthetix/prod/geth/README.md b/aws/synthetix/prod/geth/README.md new file mode 100644 index 000000000000..ba2a3273eaf0 --- /dev/null +++ b/aws/synthetix/prod/geth/README.md @@ -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 --secret-key --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 --vpc --subnets + ``` + +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 --enable-service-discovery --cluster-config synthetix-prod-geth-config --ecs-profile synthetix-prod-geth-profile --create-log-groups + ``` diff --git a/aws/synthetix/prod/geth/docker-compose.yml b/aws/synthetix/prod/geth/docker-compose.yml new file mode 100644 index 000000000000..7ba000d3614f --- /dev/null +++ b/aws/synthetix/prod/geth/docker-compose.yml @@ -0,0 +1,25 @@ +version: "3" +services: + geth_l2: + image: .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: + diff --git a/aws/synthetix/prod/geth/ecs-params.yml b/aws/synthetix/prod/geth/ecs-params.yml new file mode 100644 index 000000000000..3b5987102a9a --- /dev/null +++ b/aws/synthetix/prod/geth/ecs-params.yml @@ -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 + 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: + - + security_groups: + - + service_discovery_service: + name: 'geth' + description: 'Synthetix PROD Geth Service Discovery' + dns_config: + type: 'A' + ttl: 60 diff --git a/aws/synthetix/prod/web/README.md b/aws/synthetix/prod/web/README.md new file mode 100644 index 000000000000..56e119b2dc56 --- /dev/null +++ b/aws/synthetix/prod/web/README.md @@ -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 --secret-key --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 --vpc --subnets + ``` + +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 --cluster-config synthetix-prod-web-config --ecs-profile synthetix-prod-web-profile --create-log-groups + ``` diff --git a/aws/synthetix/prod/web/docker-compose.yml b/aws/synthetix/prod/web/docker-compose.yml new file mode 100644 index 000000000000..20251f636c27 --- /dev/null +++ b/aws/synthetix/prod/web/docker-compose.yml @@ -0,0 +1,29 @@ +version: "3" +services: + rollup-full-node: + image: .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: + diff --git a/aws/synthetix/prod/web/ecs-params.yml b/aws/synthetix/prod/web/ecs-params.yml new file mode 100644 index 000000000000..6063db89d90b --- /dev/null +++ b/aws/synthetix/prod/web/ecs-params.yml @@ -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' + diff --git a/aws/synthetix/uat/geth/docker-compose.yml b/aws/synthetix/uat/geth/docker-compose.yml index 9191b2863317..a9c398055126 100644 --- a/aws/synthetix/uat/geth/docker-compose.yml +++ b/aws/synthetix/uat/geth/docker-compose.yml @@ -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 diff --git a/aws/synthetix/uat/geth/ecs-params.yml b/aws/synthetix/uat/geth/ecs-params.yml index 8670740f7f9f..dd779aa04c67 100644 --- a/aws/synthetix/uat/geth/ecs-params.yml +++ b/aws/synthetix/uat/geth/ecs-params.yml @@ -9,7 +9,7 @@ task_definition: # timeout: 5s # retries: 3 # start_period: 10s - mem_limit: 32889600000 + mem_limit: 32653700000 ecs_network_mode: awsvpc