Skip to content

Commit

Permalink
Merge pull request #255 from polywrap/nerfzael/google-cloud-deploy
Browse files Browse the repository at this point in the history
Deployment for google cloud
  • Loading branch information
nerfZael authored Jun 7, 2024
2 parents ce7830e + 52c4c69 commit 1655c49
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 5 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/cd.prod-agent.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: CD Prod Agent
on:
push:
branches:
- main
paths:
- ./**

jobs:
deploy:
permissions:
contents: 'read'
id-token: 'write'

runs-on: ubuntu-latest
defaults:
run:
working-directory: .
steps:
- uses: 'actions/checkout@v4'

- name: Set up Python 3.10
uses: actions/setup-python@v2
with:
python-version: "3.10"

- name: Install and configure Poetry
uses: snok/install-poetry@v1
with:
version: 1.7.1
virtualenvs-create: true
virtualenvs-in-project: true

- id: 'auth'
uses: 'google-github-actions/auth@v2'
with:
workload_identity_provider: ${{ secrets.PROD_GOOGLE_WIP }}
service_account: ${{ secrets.PROD_GOOGLE_SA }}

- name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v1'
with:
version: '>= 363.0.0'
- name: 'Use gcloud CLI'
run: 'gcloud info'

- name: Create .deploy.env file
run: |
echo "ALCHEMY_API_KEY=${{ secrets.ALCHEMY_API_KEY }}" >> .deploy.env
echo "OPENAI_API_KEY=${{ secrets.CI_OPENAI_API_KEY }}" >> .deploy.env
echo "OPENAI_BASE_URL=https://api.openai.com/v1" >> .deploy.env
echo "OPENAI_MODEL_NAME=gpt-4o" >> .deploy.env
echo "COINGECKO_API_KEY=${{ secrets.CI_COINGECKO_API_KEY }}" >> .deploy.env
echo "LIFI_API_KEY=${{ secrets.LIFI_API_KEY }}" >> .deploy.env
echo "SUPABASE_SERVICE_ROLE_KEY=${{ secrets.PROD_SUPABASE_SERVICE_ROLE_KEY }}" >> .deploy.env
echo "SUPABASE_URL=${{ secrets.PROD_SUPABASE_URL }}" >> .deploy.env
- name: 'deploy'
run: 'gcloud run deploy sample --port 80 --source .'
17 changes: 13 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
FROM ghcr.io/foundry-rs/foundry
FROM python:3.11.3
ENV PYTHONUNBUFFERED True

WORKDIR /anvil
EXPOSE 8545
ENTRYPOINT anvil --fork-url $CHAIN_RPC_URL --host 0.0.0.0
RUN pip install --upgrade pip
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

ENV APP_HOME /root
WORKDIR $APP_HOME
COPY /autotx $APP_HOME/autotx
COPY .deploy.env $APP_HOME/.env

EXPOSE 8080
CMD ["uvicorn", "autotx.server:app", "--host", "0.0.0.0", "--port", "8080"]
2 changes: 1 addition & 1 deletion autotx/chain_fork.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def start() -> None:
delete_cached_safe_address()

build = subprocess.run(
["docker", "build", "-t", "autotx_chain_fork", "."], capture_output=True
["docker", "build", "-t", "autotx_chain_fork", ".", "-f", "fork.Dockerfile"], capture_output=True
)

if build.returncode != 0:
Expand Down
5 changes: 5 additions & 0 deletions fork.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM ghcr.io/foundry-rs/foundry

WORKDIR /anvil
EXPOSE 8545
ENTRYPOINT anvil --fork-url $CHAIN_RPC_URL --host 0.0.0.0

0 comments on commit 1655c49

Please sign in to comment.