Skip to content

Commit

Permalink
build: deploy resource provider (#184)
Browse files Browse the repository at this point in the history
* build: add job for deploying rp

* fix: resource provider dockerfile lilypad service run in background
  • Loading branch information
AquiGorka authored Jun 24, 2024
1 parent fbaf86f commit 210da18
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 2 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/testnet_deploy_services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,67 @@ jobs:
--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" \
.
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
5 changes: 3 additions & 2 deletions docker/resource-provider/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ ARG NETWORK=testnet
ENV LOG_LEVEL=info
ENV OFFER_GPU=1
ENV BACALHAU_API_HOST="localhost"
ENV WEB3_PRIVATE_KEY=""

# Install necessary dependencies
RUN apk update
Expand Down Expand Up @@ -35,14 +36,14 @@ ENV PATH="/usr/local/bin:${PATH}"
# Create a startup script to run both services simultaneously
RUN touch run
RUN echo "#!/bin/bash" >> run
RUN echo "cat run" >> run
# Launch docker daemon
RUN echo "dockerd &" >> run
RUN echo "while ! docker -v; do sleep 1; done" >> run
RUN echo "sleep 3" >> run
# Launch Bacalhau
RUN echo "/usr/local/bin/bacalhau serve --node-type compute,requester --peer none --private-internal-ipfs=false --job-selection-accept-networked &" >> run
# Launch Lilypad
RUN echo "/usr/local/bin/lilypad resource-provider --network ${NETWORK}" >> run
RUN echo "/usr/local/bin/lilypad resource-provider --network ${NETWORK} &" >> run
RUN echo "wait -n" >> run
RUN chmod +x run

Expand Down

0 comments on commit 210da18

Please sign in to comment.