generated from PaulRBerg/hardhat-template
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automated CipherNode deployment (#195)
* Add Dockerfiles * Expose Udp port * Update Entry point for CN * Dev compose * delete old compose * push image to ecr * Update ECS Deployment Workflow * Update ECS Deployment Workflow * Update ECS Deployment Workflow * Update node version to 22 * Update Entrypoint * Use Docker Swarm to manage Ciphernodes * Mount Secrets * Switch to ghcr.io * Update image tag * Deploy to EC2 * Testing EC2 Deployment * Optional mdns * Update Configs * Update config * Update Deployment workflow * Bypass overlay and use host network * Env substitution (#203) * Env substitution works * Move to dev-dependencies * Formatting * Ensure that there are no quotes or anything around substitution * use non normal env vars to avoid future issues * merge main and update workflow deployment * Update Dockerfile and add deployments artifacts --------- Co-authored-by: гλ <[email protected]>
- Loading branch information
1 parent
3a89686
commit 44aac5b
Showing
24 changed files
with
549 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
name: Build and Deploy Ciphernode | ||
|
||
on: | ||
push: | ||
branches: | ||
- release | ||
- main | ||
paths: | ||
- 'packages/ciphernode/**' | ||
- 'packages/evm/contracts/**' | ||
pull_request: | ||
branches: | ||
- release | ||
- main | ||
paths: | ||
- 'packages/ciphernode/**' | ||
- 'packages/evm/contracts/**' | ||
|
||
env: | ||
DOCKERFILE_PATH: packages/ciphernode/Dockerfile | ||
IMAGE_NAME: ghcr.io/gnosisguild/ciphernode | ||
|
||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
jobs: | ||
build: | ||
name: Build Image | ||
runs-on: ubuntu-latest | ||
outputs: | ||
image_tag: ${{ steps.version.outputs.version }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Generate version tag | ||
id: version | ||
run: echo "version=$(date +'%Y%m%d')-${GITHUB_SHA::8}" >> $GITHUB_OUTPUT | ||
|
||
- name: Log in to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build image | ||
env: | ||
IMAGE_TAG: ${{ steps.version.outputs.version }} | ||
run: | | ||
docker build -t $IMAGE_NAME:${{ steps.version.outputs.version }} -f $DOCKERFILE_PATH . | ||
docker push $IMAGE_NAME:$IMAGE_TAG | ||
- name: Push to GHCR | ||
if: github.ref == 'refs/heads/release' | ||
env: | ||
IMAGE_TAG: ${{ steps.version.outputs.version }} | ||
run: | | ||
docker tag $IMAGE_NAME:$IMAGE_TAG $IMAGE_NAME:latest | ||
docker push $IMAGE_NAME:latest | ||
deploy: | ||
name: Deploy to Production | ||
needs: build | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: production | ||
if: github.ref == 'refs/heads/release' | ||
|
||
steps: | ||
- name: Deploy to EC2 | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ secrets.EC2_HOST }} | ||
username: ${{ secrets.EC2_USERNAME }} | ||
key: ${{ secrets.EC2_KEY }} | ||
script: | | ||
IMAGE_TAG="${{ needs.build.outputs.image_tag }}" | ||
echo "Deploying version: $IMAGE_TAG" | ||
docker pull $IMAGE_NAME:$IMAGE_TAG | ||
cd /home/ec2-user/enclave | ||
git pull | ||
docker stack deploy -c docker-compose.yml ciphernode-stack | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
services: | ||
cn1: | ||
networks: | ||
- cn-network | ||
cn2: | ||
networks: | ||
- cn-network | ||
cn3: | ||
networks: | ||
- cn-network | ||
aggregator: | ||
networks: | ||
- cn-network | ||
|
||
networks: | ||
cn-network: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
services: | ||
cn1: | ||
image: ghcr.io/gnosisguild/ciphernode:latest | ||
volumes: | ||
- ./configs/cn1.yaml:/home/ciphernode/.config/enclave/config.yaml:ro | ||
- cn1-data:/home/ciphernode/.local/share/enclave | ||
secrets: | ||
- secrets.json | ||
environment: | ||
RUST_LOG: "info" | ||
AGGREGATOR: "false" | ||
ports: | ||
- target: 9091 | ||
published: 9091 | ||
protocol: udp | ||
mode: host | ||
deploy: | ||
replicas: 1 | ||
networks: | ||
- global-network | ||
|
||
|
||
cn2: | ||
image: ghcr.io/gnosisguild/ciphernode:latest | ||
depends_on: | ||
- cn1 | ||
volumes: | ||
- ./configs/cn2.yaml:/home/ciphernode/.config/enclave/config.yaml:ro | ||
- cn2-data:/home/ciphernode/.local/share/enclave | ||
secrets: | ||
- secrets.json | ||
environment: | ||
RUST_LOG: "info" | ||
AGGREGATOR: "false" | ||
ports: | ||
- target: 9092 | ||
published: 9092 | ||
protocol: udp | ||
mode: host | ||
deploy: | ||
replicas: 1 | ||
networks: | ||
- global-network | ||
|
||
cn3: | ||
image: ghcr.io/gnosisguild/ciphernode:latest | ||
depends_on: | ||
- cn1 | ||
volumes: | ||
- ./configs/cn3.yaml:/home/ciphernode/.config/enclave/config.yaml:ro | ||
- cn3-data:/home/ciphernode/.local/share/enclave | ||
secrets: | ||
- secrets.json | ||
environment: | ||
RUST_LOG: "info" | ||
AGGREGATOR: "false" | ||
ports: | ||
- target: 9093 | ||
published: 9093 | ||
protocol: udp | ||
mode: host | ||
deploy: | ||
replicas: 1 | ||
networks: | ||
- global-network | ||
|
||
|
||
aggregator: | ||
image: ghcr.io/gnosisguild/ciphernode:latest | ||
depends_on: | ||
- cn1 | ||
volumes: | ||
- ./configs/agg.yaml:/home/ciphernode/.config/enclave/config.yaml:ro | ||
- agg-data:/home/ciphernode/.local/share/enclave | ||
secrets: | ||
- secrets.json | ||
environment: | ||
RUST_LOG: "info" | ||
AGGREGATOR: "true" | ||
ports: | ||
- target: 9094 | ||
published: 9094 | ||
protocol: udp | ||
mode: host | ||
deploy: | ||
replicas: 1 | ||
networks: | ||
- global-network | ||
|
||
secrets: | ||
secrets.json: | ||
file: ./configs/secrets.json | ||
|
||
volumes: | ||
cn1-data: | ||
cn2-data: | ||
cn3-data: | ||
agg-data: | ||
|
||
networks: | ||
global-network: | ||
driver: overlay |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.