-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from willemolding/willem/indexer-docker
Add a dockerfile for the indexer and github actions to push to container registry
- Loading branch information
Showing
6 changed files
with
221 additions
and
2 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,56 @@ | ||
name: Publish Docker images | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
push_fullnode_to_registry: | ||
name: Push fullnode Docker image to fly.io | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out the repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: 🔑 Fly Registry Auth | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: registry.fly.io | ||
username: x | ||
password: ${{ secrets.FLY_API_TOKEN }} | ||
|
||
- name: 🐳 Docker build (fullnode) | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
file: ./fullnode.Dockerfile | ||
push: true | ||
tags: registry.fly.io/cartezcash-fullnode:latest | ||
build-args: | | ||
COMMIT_SHA=${{ github.sha }} | ||
push_cartesi_node_to_registry: | ||
name: Push cartesi node Docker image to fly.io | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out the repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: 🔑 Fly Registry Auth | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: registry.fly.io | ||
username: x | ||
password: ${{ secrets.FLY_API_TOKEN }} | ||
|
||
- name: Setup Node.js 20 | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
registry-url: "https://registry.npmjs.org" | ||
|
||
- name: Install Sunodo and build | ||
run: | | ||
npm install -g @sunodo/cli | ||
IMAGE_TAG=$(sunodo deploy build --platform linux/amd64 | grep "Application node Docker image" | awk '{print $NF}') | ||
docker push $IMAGE_TAG:registry.fly.io/cartezcash:latest |
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,32 @@ | ||
name: Fly.io Deploy | ||
|
||
on: | ||
workflow_run: | ||
workflows: ["Publish Docker images"] | ||
types: | ||
- completed | ||
|
||
jobs: | ||
deploy-node: | ||
name: Deploy Cartesi node | ||
if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
runs-on: ubuntu-latest | ||
concurrency: deploy-group # optional: ensure only one action runs at a time | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: superfly/flyctl-actions/setup-flyctl@master | ||
- run: flyctl deploy --config fly.toml --remote-only | ||
env: | ||
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} | ||
|
||
deploy-fullnode: | ||
name: Deploy fullnode | ||
if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
runs-on: ubuntu-latest | ||
concurrency: deploy-group # optional: ensure only one action runs at a time | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: superfly/flyctl-actions/setup-flyctl@master | ||
- run: fflyctl deploy --config fly.fullnode.toml --remote-only | ||
env: | ||
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} |
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,23 @@ | ||
app = "cartezcash-fullnode" | ||
|
||
[build] | ||
image = "registry.fly.io/cartezcash-fullnode:latest" | ||
|
||
[[services]] | ||
internal_port = 50051 | ||
protocol = "tcp" | ||
|
||
[[services.ports]] | ||
handlers = ["tls"] | ||
port = "443" | ||
|
||
[services.ports.tls_options] | ||
alpn = ["h2"] | ||
|
||
[[vm]] | ||
size = "shared-cpu-1x" | ||
memory = "2gb" | ||
|
||
[env] | ||
GRPC_SERVER_URL="[::1]:50051" | ||
ROLLUP_HTTP_SERVER_URL="http://cartezcash.internal:8080/graphql" |
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,35 @@ | ||
app = "cartezcash" | ||
|
||
[build] | ||
image = "registry.fly.io/cartezcash:latest" | ||
|
||
[http_service] | ||
internal_port = 10000 | ||
force_https = true | ||
|
||
[http_service.concurrency] | ||
type = "requests" | ||
soft_limit = 200 | ||
hard_limit = 250 | ||
|
||
[[http_service.checks]] | ||
grace_period = "10s" | ||
interval = "30s" | ||
method = "GET" | ||
timeout = "5s" | ||
path = "/healthz" | ||
|
||
[[vm]] | ||
size = "shared-cpu-1x" | ||
memory = "2gb" | ||
|
||
[env] | ||
CARTESI_BLOCKCHAIN_FINALITY_OFFSET = "1" | ||
CARTESI_BLOCKCHAIN_ID = "11155111" | ||
CARTESI_CONTRACTS_APPLICATION_ADDRESS = "0xb8017DF47f872946A01D3ad392e4c45AB7B67262" | ||
CARTESI_CONTRACTS_APPLICATION_DEPLOYMENT_BLOCK_NUMBER = "5700129" | ||
CARTESI_CONTRACTS_AUTHORITY_ADDRESS = "0x7858f8b09FFC111e9dfb4465ddCEe323654C25c3" | ||
CARTESI_CONTRACTS_HISTORY_ADDRESS = "0xD0ab8247fFc3d161dCCe7ca50B3B5aa78dE52412" | ||
CARTESI_CONTRACTS_INPUT_BOX_ADDRESS = "0x59b22D57D4f067708AB0c00552767405926dc768" | ||
CARTESI_CONTRACTS_INPUT_BOX_DEPLOYMENT_BLOCK_NUMBER = "3963384" | ||
CARTESI_EPOCH_DURATION = "86400" |
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,66 @@ | ||
# syntax=docker.io/docker/dockerfile:1 | ||
FROM ubuntu:22.04 as base | ||
|
||
ENV RUSTUP_HOME=/usr/local/rustup \ | ||
CARGO_HOME=/usr/local/cargo \ | ||
PATH=/usr/local/cargo/bin:$PATH \ | ||
RUST_VERSION=1.76.0 | ||
|
||
ARG DEBIAN_FRONTEND=noninteractive | ||
RUN <<EOF | ||
set -e | ||
apt update | ||
apt install -y --no-install-recommends \ | ||
build-essential=12.9ubuntu3 \ | ||
ca-certificates=20230311ubuntu0.22.04.1 \ | ||
wget=1.21.2-2ubuntu1 \ | ||
libclang-dev | ||
EOF | ||
|
||
RUN set -eux; \ | ||
dpkgArch="$(dpkg --print-architecture)"; \ | ||
case "${dpkgArch##*-}" in \ | ||
amd64) rustArch='x86_64-unknown-linux-gnu'; rustupSha256='0b2f6c8f85a3d02fde2efc0ced4657869d73fccfce59defb4e8d29233116e6db' ;; \ | ||
armhf) rustArch='armv7-unknown-linux-gnueabihf'; rustupSha256='f21c44b01678c645d8fbba1e55e4180a01ac5af2d38bcbd14aa665e0d96ed69a' ;; \ | ||
arm64) rustArch='aarch64-unknown-linux-gnu'; rustupSha256='673e336c81c65e6b16dcdede33f4cc9ed0f08bde1dbe7a935f113605292dc800' ;; \ | ||
i386) rustArch='i686-unknown-linux-gnu'; rustupSha256='e7b0f47557c1afcd86939b118cbcf7fb95a5d1d917bdd355157b63ca00fc4333' ;; \ | ||
*) echo >&2 "unsupported architecture: ${dpkgArch}"; exit 1 ;; \ | ||
esac; \ | ||
url="https://static.rust-lang.org/rustup/archive/1.26.0/${rustArch}/rustup-init"; \ | ||
wget "$url"; \ | ||
echo "${rustupSha256} *rustup-init" | sha256sum -c -; \ | ||
chmod +x rustup-init; \ | ||
./rustup-init -y --no-modify-path --profile minimal --default-toolchain $RUST_VERSION --default-host ${rustArch}; \ | ||
rm rustup-init; \ | ||
chmod -R a+w $RUSTUP_HOME $CARGO_HOME; \ | ||
rustup --version; \ | ||
cargo --version; \ | ||
rustc --version; | ||
|
||
RUN cargo install cargo-chef | ||
WORKDIR /opt/cartesi/cartezcash | ||
|
||
### the planner helps cache depdenency builds | ||
|
||
FROM base AS planner | ||
COPY . . | ||
RUN cargo chef prepare --recipe-path recipe.json | ||
|
||
### Builder compiles the service | ||
|
||
FROM base as builder | ||
COPY --from=planner /opt/cartesi/cartezcash/recipe.json recipe.json | ||
RUN cargo chef cook --release --recipe-path recipe.json --no-default-features --features listen-graphql,lightwalletd | ||
COPY . . | ||
RUN cargo build --release --no-default-features --features listen-graphql,lightwalletd | ||
|
||
### final image is the dapp itself | ||
|
||
FROM ubuntu:22.04 | ||
|
||
ENV PATH="/opt/cartesi/bin:/opt/cartesi/cartezcash:${PATH}" | ||
|
||
WORKDIR /opt/cartesi/cartezcash | ||
COPY --from=builder /opt/cartesi/cartezcash/target/release/cartezcash . | ||
|
||
CMD ["cartezcash"] |
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