-
Notifications
You must be signed in to change notification settings - Fork 18
194 lines (178 loc) · 7.52 KB
/
testnet_deploy_services.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
name: Deploy Testnet services
on:
push:
tags:
- 'v*'
jobs:
solver-build-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
context: app
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
with:
mask-password: 'true'
- name: Solver build, tag, and push image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY_SOLVER: ${{ secrets.ECR_REPOSITORY_SOLVER }}
run: |
docker build \
-t $ECR_REPOSITORY_SOLVER \
-f ./docker/solver/Dockerfile \
--build-arg="expose_via=cloudflare" \
--build-arg="network=testnet" \
.
docker tag $ECR_REPOSITORY_SOLVER:latest $ECR_REGISTRY/$ECR_REPOSITORY_SOLVER:latest
docker push $ECR_REGISTRY/$ECR_REPOSITORY_SOLVER:latest
- name: Solver deploy to EC2 instance
uses: appleboy/ssh-action@master
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY_SOLVER: ${{ secrets.ECR_REPOSITORY_SOLVER }}
TESTNET_DOPPLER_TOKEN_SOLVER: ${{ secrets.TESTNET_DOPPLER_TOKEN_SOLVER }}
with:
host: ${{ secrets.TESTNET_EC2_HOST_SOLVER }}
username: ${{ secrets.TESTNET_EC2_USERNAME_SOLVER }}
key: ${{ secrets.TESTNET_EC2_PRIVATE_KEY_SOLVER }}
envs: ECR_REGISTRY, ECR_REPOSITORY_SOLVER, TESTNET_DOPPLER_TOKEN_SOLVER
script_stop: true
script: |
docker stop solver || true
docker rm solver || true
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin $ECR_REGISTRY
docker system prune -af
docker pull $ECR_REGISTRY/$ECR_REPOSITORY_SOLVER:latest
docker run \
-d \
--restart always \
--name solver \
-e DOPPLER_TOKEN=$TESTNET_DOPPLER_TOKEN_SOLVER \
$ECR_REGISTRY/$ECR_REPOSITORY_SOLVER:latest
job-creator-build-deploy:
needs: [solver-build-deploy]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
context: app
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
with:
mask-password: 'true'
- name: Job creator build, tag, and push image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY_JOB_CREATOR: ${{ secrets.ECR_REPOSITORY_JOB_CREATOR }}
run: |
docker build \
-t $ECR_REPOSITORY_JOB_CREATOR \
-f ./docker/job-creator/Dockerfile \
--build-arg="network=testnet" \
.
docker tag $ECR_REPOSITORY_JOB_CREATOR:latest $ECR_REGISTRY/$ECR_REPOSITORY_JOB_CREATOR:latest
docker push $ECR_REGISTRY/$ECR_REPOSITORY_JOB_CREATOR:latest
- name: Job creator deploy to EC2 instance
uses: appleboy/ssh-action@master
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY_JOB_CREATOR: ${{ secrets.ECR_REPOSITORY_JOB_CREATOR }}
TESTNET_DOPPLER_TOKEN_JOB_CREATOR: ${{ secrets.TESTNET_DOPPLER_TOKEN_JOB_CREATOR }}
with:
host: ${{ secrets.TESTNET_EC2_HOST_JOB_CREATOR }}
username: ${{ secrets.TESTNET_EC2_USERNAME_JOB_CREATOR }}
key: ${{ secrets.TESTNET_EC2_PRIVATE_KEY_JOB_CREATOR }}
envs: ECR_REGISTRY, ECR_REPOSITORY_JOB_CREATOR, TESTNET_DOPPLER_TOKEN_JOB_CREATOR
script_stop: true
script: |
docker stop job-creator || true
docker rm job-creator || true
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin $ECR_REGISTRY
docker system prune -af
docker pull $ECR_REGISTRY/$ECR_REPOSITORY_JOB_CREATOR:latest
docker run \
-d \
--restart always \
--name job-creator \
-e DOPPLER_TOKEN=$TESTNET_DOPPLER_TOKEN_JOB_CREATOR \
$ECR_REGISTRY/$ECR_REPOSITORY_JOB_CREATOR:latest
resource-provider-build-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
context: app
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
with:
mask-password: 'true'
- name: Resource provider build, tag, and push image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY_RESOURCE_PROVIDER: ${{ secrets.ECR_REPOSITORY_RESOURCE_PROVIDER }}
run: |
docker build \
-t $ECR_REPOSITORY_RESOURCE_PROVIDER \
-f ./docker/resource-provider/Dockerfile \
--build-arg="network=testnet" \
--build-arg="disable_pow=true" \
.
docker tag $ECR_REPOSITORY_RESOURCE_PROVIDER:latest $ECR_REGISTRY/$ECR_REPOSITORY_RESOURCE_PROVIDER:latest
docker push $ECR_REGISTRY/$ECR_REPOSITORY_RESOURCE_PROVIDER:latest
- name: Resource provider deploy to EC2 instance
uses: appleboy/ssh-action@master
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY_RESOURCE_PROVIDER: ${{ secrets.ECR_REPOSITORY_RESOURCE_PROVIDER }}
WEB3_PRIVATE_KEY_RESOURCE_PROVIDER: ${{ secrets.WEB3_PRIVATE_KEY_RESOURCE_PROVIDER }}
with:
host: ${{ secrets.TESTNET_EC2_HOST_RESOURCE_PROVIDER }}
username: ${{ secrets.TESTNET_EC2_USERNAME_RESOURCE_PROVIDER }}
key: ${{ secrets.TESTNET_EC2_PRIVATE_KEY_RESOURCE_PROVIDER }}
envs: ECR_REGISTRY, ECR_REPOSITORY_RESOURCE_PROVIDER, WEB3_PRIVATE_KEY_RESOURCE_PROVIDER
script_stop: true
script: |
docker stop resource-provider || true
docker rm resource-provider || true
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin $ECR_REGISTRY
docker system prune -af
docker pull $ECR_REGISTRY/$ECR_REPOSITORY_RESOURCE_PROVIDER:latest
docker run \
-d \
--privileged \
--restart always \
--name resource-provider \
-e OFFER_GPU=0 \
-e BACALHAU_API_HOST="DO_NOT_SET" \
-e LOG_LEVEL=debug \
-e WEB3_PRIVATE_KEY=$WEB3_PRIVATE_KEY_RESOURCE_PROVIDER \
$ECR_REGISTRY/$ECR_REPOSITORY_RESOURCE_PROVIDER:latest