From 5e6dfeeac7e40ea13e930357376e24fa63ba32e6 Mon Sep 17 00:00:00 2001 From: "James W." <104535511+0xThresh@users.noreply.github.com> Date: Fri, 4 Apr 2025 03:11:08 +0000 Subject: [PATCH 01/28] feat: initial userdata for EC2 and Dockerfile --- Dockerfile | 27 ++++++++++++++++++ userdata.sh | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+) create mode 100644 Dockerfile create mode 100644 userdata.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..7268536 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +FROM lukemathwalker/cargo-chef:latest-rust-1 AS chef +WORKDIR /app + +FROM chef AS planner +COPY . . +RUN cargo chef prepare --recipe-path recipe.json + +FROM chef AS builder +COPY --from=planner /app/recipe.json recipe.json +# Build dependencies - this is the caching Docker layer! +RUN cargo chef cook --release --recipe-path recipe.json +# Build application +COPY . . +#RUN cargo build --release --bin app +RUN cargo install sqlx-cli +RUN cargo sqlx prepare --workspace +RUN cargo build --release + +# We do not need the Rust toolchain to run the binary! +FROM debian:bookworm-slim AS runtime + +WORKDIR /app +COPY --from=builder /app/target/release/app /usr/local/bin +COPY --from=builder /app/target/release/.sqlx ./.sqlx + + +ENTRYPOINT ["/usr/local/bin/app"] \ No newline at end of file diff --git a/userdata.sh b/userdata.sh new file mode 100644 index 0000000..87673f4 --- /dev/null +++ b/userdata.sh @@ -0,0 +1,81 @@ +#!/bin/bash + +# Installs + +## Rust +curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh +cargo install sqlx-cli +sudo apt update -y +sudo apt install git jq docker.io clang openssl pkg-config libssl-dev -y + +# TODO: Set up SSH key for repo or container pull +git clone git@github.com:Developer-DAO/rpc.git +cd ./rpc/ + +# Get required secrets from SM +DB_SECRET=$(aws secretsmanager get-secret-value --secret-id pokt-db-master-password) +DB_USER=$(echo DB_SECRET | jq -r ".username") +DB_PASSWORD=$(echo DB_SECRET | jq -r ".password") +DB_HOST=$(echo DB_SECRET | jq -r ".host") + +SMTP_USERNAME=$(aws secretsmanager get-secret-value --secret-id ) +SMTP_PASSWORD=$(aws secretsmanager get-secret-value --secret-id ) + +JWT_SECRET=$(aws secretsmanager get-secret-value --secret-id rpc-jwt) + +ETHEREUM_ENDPOINT=$(aws secretsmanager get-secret-value --secret-id ) + +# Populate env vars +cat << EOF > .env +DATABASE_URL=postgres://$DB_USER:$DB_PASSWORD@$DB_HOST:5432/rpc +SMTP_USERNAME=$SMTP_USERNAME +SMTP_PASSWORD=$SMTP_PASSWORD +ETHEREUM_ENDPOINT=$ETHEREUM_ENDPOINT +JWT_KEY=$JWT_SECRET +EOF + +# Start database connection +cargo sqlx prepare --workspace + +# Start Docker Compose services +echo "Starting Docker Compose services..." +sudo docker compose up -d # TODO: Add flag for .env file + +# Check if Docker Compose services were started successfully +if [ $? -eq 0 ]; then + echo "Docker Compose services started successfully." +else + echo "Failed to start Docker Compose services." + exit 1 +fi + + +# Check if sqlx command exists +if ! command -v sqlx &> /dev/null; then + echo "sqlx could not be found. Please install sqlx first." + exit 1 +fi + +# Create the database +echo "Creating database..." +sqlx database create + +# Check if the database was created successfully +if [ $? -eq 0 ]; then + echo "Database created successfully." +else + echo "Failed to create the database." + exit 1 +fi + +# Run migrations +echo "Running migrations..." +sqlx migrate run + +# Check if the migrations were run successfully +if [ $? -eq 0 ]; then + echo "Migrations run successfully." +else + echo "Failed to run migrations." + exit 1 +fi From e77f0dd06d158f7d7bb76b964c27b685667f3912 Mon Sep 17 00:00:00 2001 From: "James W." <104535511+0xThresh@users.noreply.github.com> Date: Sun, 6 Apr 2025 04:43:10 +0000 Subject: [PATCH 02/28] fix: Add buildx to userdata, running Dockerfile --- Dockerfile | 11 +++++------ userdata.sh | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7268536..df9b6be 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,7 @@ FROM chef AS planner COPY . . RUN cargo chef prepare --recipe-path recipe.json -FROM chef AS builder +FROM chef AS builder COPY --from=planner /app/recipe.json recipe.json # Build dependencies - this is the caching Docker layer! RUN cargo chef cook --release --recipe-path recipe.json @@ -17,11 +17,10 @@ RUN cargo sqlx prepare --workspace RUN cargo build --release # We do not need the Rust toolchain to run the binary! -FROM debian:bookworm-slim AS runtime +#FROM debian:bookworm-slim AS runtime -WORKDIR /app -COPY --from=builder /app/target/release/app /usr/local/bin -COPY --from=builder /app/target/release/.sqlx ./.sqlx +#WORKDIR /app +#COPY --from=builder /app/target/release/.sqlx ./.sqlx -ENTRYPOINT ["/usr/local/bin/app"] \ No newline at end of file +ENTRYPOINT ["cargo", "run", "--release"] \ No newline at end of file diff --git a/userdata.sh b/userdata.sh index 87673f4..b032b33 100644 --- a/userdata.sh +++ b/userdata.sh @@ -6,7 +6,7 @@ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh cargo install sqlx-cli sudo apt update -y -sudo apt install git jq docker.io clang openssl pkg-config libssl-dev -y +sudo apt install git jq docker.io docker-buildx clang openssl pkg-config libssl-dev -y # TODO: Set up SSH key for repo or container pull git clone git@github.com:Developer-DAO/rpc.git From b665f31f7db3a89a2e73051f6b103969d77eb617 Mon Sep 17 00:00:00 2001 From: "James W." <104535511+0xThresh@users.noreply.github.com> Date: Tue, 8 Apr 2025 03:20:03 +0000 Subject: [PATCH 03/28] Adding dev dockerfile and removing unnecessary steps --- Dockerfile | 10 +--------- Dockerfile.dev | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 9 deletions(-) create mode 100644 Dockerfile.dev diff --git a/Dockerfile b/Dockerfile index df9b6be..6ffee7e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,15 +12,7 @@ RUN cargo chef cook --release --recipe-path recipe.json # Build application COPY . . #RUN cargo build --release --bin app -RUN cargo install sqlx-cli -RUN cargo sqlx prepare --workspace +#RUN cargo install sqlx-cli RUN cargo build --release -# We do not need the Rust toolchain to run the binary! -#FROM debian:bookworm-slim AS runtime - -#WORKDIR /app -#COPY --from=builder /app/target/release/.sqlx ./.sqlx - - ENTRYPOINT ["cargo", "run", "--release"] \ No newline at end of file diff --git a/Dockerfile.dev b/Dockerfile.dev new file mode 100644 index 0000000..f0e3e6e --- /dev/null +++ b/Dockerfile.dev @@ -0,0 +1,18 @@ +FROM lukemathwalker/cargo-chef:latest-rust-1 AS chef +WORKDIR /app + +FROM chef AS planner +COPY . . +RUN cargo chef prepare --recipe-path recipe.json + +FROM chef AS builder +COPY --from=planner /app/recipe.json recipe.json +# Build dependencies - this is the caching Docker layer! +RUN cargo chef cook --release --recipe-path recipe.json +# Build application +COPY . . +#RUN cargo build --release --bin app +RUN cargo install sqlx-cli +RUN cargo build --release + +ENTRYPOINT ["cargo", "run", "--release", "--features", "dev"] \ No newline at end of file From 56a652afeeb1c82df6dc1e22dff2041ed7381fb2 Mon Sep 17 00:00:00 2001 From: "0xThresh.eth" <0xthresh@protonmail.com> Date: Mon, 16 Jun 2025 21:37:41 -0600 Subject: [PATCH 04/28] Add host to compose to enable local access, add example .env file --- .env.example | 5 +++ docker-compose.yml | 4 ++- userdata.sh | 81 ---------------------------------------------- 3 files changed, 8 insertions(+), 82 deletions(-) create mode 100644 .env.example delete mode 100644 userdata.sh diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..5a8e916 --- /dev/null +++ b/.env.example @@ -0,0 +1,5 @@ +DATABASE_URL=postgres://ddrpcdev:ddrpc123@host.docker.internal:5432/ddrpc +SMTP_USERNAME=test@asdlfknason.com +SMTP_PASSWORD=test! +ETHEREUM_ENDPOINT=http://host.docker.internal:8545 +JWT_KEY= diff --git a/docker-compose.yml b/docker-compose.yml index 7abf179..aa1b7cf 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,6 +11,8 @@ services: - "5432:5432" volumes: - postgres_data:/var/lib/postgresql/data - + extra_hosts: + - "host.docker.internal:host-gateway" + volumes: postgres_data: diff --git a/userdata.sh b/userdata.sh deleted file mode 100644 index b032b33..0000000 --- a/userdata.sh +++ /dev/null @@ -1,81 +0,0 @@ -#!/bin/bash - -# Installs - -## Rust -curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -cargo install sqlx-cli -sudo apt update -y -sudo apt install git jq docker.io docker-buildx clang openssl pkg-config libssl-dev -y - -# TODO: Set up SSH key for repo or container pull -git clone git@github.com:Developer-DAO/rpc.git -cd ./rpc/ - -# Get required secrets from SM -DB_SECRET=$(aws secretsmanager get-secret-value --secret-id pokt-db-master-password) -DB_USER=$(echo DB_SECRET | jq -r ".username") -DB_PASSWORD=$(echo DB_SECRET | jq -r ".password") -DB_HOST=$(echo DB_SECRET | jq -r ".host") - -SMTP_USERNAME=$(aws secretsmanager get-secret-value --secret-id ) -SMTP_PASSWORD=$(aws secretsmanager get-secret-value --secret-id ) - -JWT_SECRET=$(aws secretsmanager get-secret-value --secret-id rpc-jwt) - -ETHEREUM_ENDPOINT=$(aws secretsmanager get-secret-value --secret-id ) - -# Populate env vars -cat << EOF > .env -DATABASE_URL=postgres://$DB_USER:$DB_PASSWORD@$DB_HOST:5432/rpc -SMTP_USERNAME=$SMTP_USERNAME -SMTP_PASSWORD=$SMTP_PASSWORD -ETHEREUM_ENDPOINT=$ETHEREUM_ENDPOINT -JWT_KEY=$JWT_SECRET -EOF - -# Start database connection -cargo sqlx prepare --workspace - -# Start Docker Compose services -echo "Starting Docker Compose services..." -sudo docker compose up -d # TODO: Add flag for .env file - -# Check if Docker Compose services were started successfully -if [ $? -eq 0 ]; then - echo "Docker Compose services started successfully." -else - echo "Failed to start Docker Compose services." - exit 1 -fi - - -# Check if sqlx command exists -if ! command -v sqlx &> /dev/null; then - echo "sqlx could not be found. Please install sqlx first." - exit 1 -fi - -# Create the database -echo "Creating database..." -sqlx database create - -# Check if the database was created successfully -if [ $? -eq 0 ]; then - echo "Database created successfully." -else - echo "Failed to create the database." - exit 1 -fi - -# Run migrations -echo "Running migrations..." -sqlx migrate run - -# Check if the migrations were run successfully -if [ $? -eq 0 ]; then - echo "Migrations run successfully." -else - echo "Failed to run migrations." - exit 1 -fi From 404fb733571c03e9d95e671da0b4aea454d9b30c Mon Sep 17 00:00:00 2001 From: crypdoughdoteth Date: Tue, 17 Jun 2025 14:31:22 -0400 Subject: [PATCH 05/28] Explicitly copy .sqlx and migrations folder into container build --- ...a73a17d0482c4ea12ef0c71eadee773b7b82a.json | 12 +++++ ...c96dc1c6a40c3d7c6b57027a9059b2642a6c7.json | 15 ++++++ ...b93124abfaa1a02a725e4bd528436c47ac7de.json | 27 ++++++++++ ...ae5c2249f4e0691efd299f19e50c7a89b8167.json | 15 ++++++ ...c36dc8895cc4bb3c4dbc62cf2494760321174.json | 50 +++++++++++++++++++ ...4d56c5ec230826d23204f9c4a93fc2164e01d.json | 14 ++++++ Dockerfile | 9 +++- 7 files changed, 140 insertions(+), 2 deletions(-) create mode 100644 .sqlx/query-30b50c894f7a5b9177b3adfd00ba73a17d0482c4ea12ef0c71eadee773b7b82a.json create mode 100644 .sqlx/query-3e5a094b5f72bda56f81650ae92c96dc1c6a40c3d7c6b57027a9059b2642a6c7.json create mode 100644 .sqlx/query-653f85d8b85aaf39d9ca0fba7dbb93124abfaa1a02a725e4bd528436c47ac7de.json create mode 100644 .sqlx/query-98b2db4293bc95af2babcf2b14eae5c2249f4e0691efd299f19e50c7a89b8167.json create mode 100644 .sqlx/query-a894b9ae427c94e2db9095cc5b7c36dc8895cc4bb3c4dbc62cf2494760321174.json create mode 100644 .sqlx/query-df14410f966197efb84a9b9426a4d56c5ec230826d23204f9c4a93fc2164e01d.json diff --git a/.sqlx/query-30b50c894f7a5b9177b3adfd00ba73a17d0482c4ea12ef0c71eadee773b7b82a.json b/.sqlx/query-30b50c894f7a5b9177b3adfd00ba73a17d0482c4ea12ef0c71eadee773b7b82a.json new file mode 100644 index 0000000..cfe8312 --- /dev/null +++ b/.sqlx/query-30b50c894f7a5b9177b3adfd00ba73a17d0482c4ea12ef0c71eadee773b7b82a.json @@ -0,0 +1,12 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE RpcPlans SET calls = 0 WHERE now() >= expires AND calls > 0", + "describe": { + "columns": [], + "parameters": { + "Left": [] + }, + "nullable": [] + }, + "hash": "30b50c894f7a5b9177b3adfd00ba73a17d0482c4ea12ef0c71eadee773b7b82a" +} diff --git a/.sqlx/query-3e5a094b5f72bda56f81650ae92c96dc1c6a40c3d7c6b57027a9059b2642a6c7.json b/.sqlx/query-3e5a094b5f72bda56f81650ae92c96dc1c6a40c3d7c6b57027a9059b2642a6c7.json new file mode 100644 index 0000000..34cd3f0 --- /dev/null +++ b/.sqlx/query-3e5a094b5f72bda56f81650ae92c96dc1c6a40c3d7c6b57027a9059b2642a6c7.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE Customers SET nonce = $1 where wallet = $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text", + "Text" + ] + }, + "nullable": [] + }, + "hash": "3e5a094b5f72bda56f81650ae92c96dc1c6a40c3d7c6b57027a9059b2642a6c7" +} diff --git a/.sqlx/query-653f85d8b85aaf39d9ca0fba7dbb93124abfaa1a02a725e4bd528436c47ac7de.json b/.sqlx/query-653f85d8b85aaf39d9ca0fba7dbb93124abfaa1a02a725e4bd528436c47ac7de.json new file mode 100644 index 0000000..bdc9b5c --- /dev/null +++ b/.sqlx/query-653f85d8b85aaf39d9ca0fba7dbb93124abfaa1a02a725e4bd528436c47ac7de.json @@ -0,0 +1,27 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE RpcPlans SET plan = $1 where email = $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + { + "Custom": { + "name": "plan", + "kind": { + "Enum": [ + "free", + "tier1", + "tier2", + "tier3" + ] + } + } + }, + "Text" + ] + }, + "nullable": [] + }, + "hash": "653f85d8b85aaf39d9ca0fba7dbb93124abfaa1a02a725e4bd528436c47ac7de" +} diff --git a/.sqlx/query-98b2db4293bc95af2babcf2b14eae5c2249f4e0691efd299f19e50c7a89b8167.json b/.sqlx/query-98b2db4293bc95af2babcf2b14eae5c2249f4e0691efd299f19e50c7a89b8167.json new file mode 100644 index 0000000..c7365e8 --- /dev/null +++ b/.sqlx/query-98b2db4293bc95af2babcf2b14eae5c2249f4e0691efd299f19e50c7a89b8167.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE Customers SET balance = balance - $1 where email = $2", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Int8", + "Text" + ] + }, + "nullable": [] + }, + "hash": "98b2db4293bc95af2babcf2b14eae5c2249f4e0691efd299f19e50c7a89b8167" +} diff --git a/.sqlx/query-a894b9ae427c94e2db9095cc5b7c36dc8895cc4bb3c4dbc62cf2494760321174.json b/.sqlx/query-a894b9ae427c94e2db9095cc5b7c36dc8895cc4bb3c4dbc62cf2494760321174.json new file mode 100644 index 0000000..48f0e59 --- /dev/null +++ b/.sqlx/query-a894b9ae427c94e2db9095cc5b7c36dc8895cc4bb3c4dbc62cf2494760321174.json @@ -0,0 +1,50 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT balance, Customers.email, plan as \"plan!: Plan\", expires FROM RpcPlans, Customers where now() > expires\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "balance", + "type_info": "Int8" + }, + { + "ordinal": 1, + "name": "email", + "type_info": "Varchar" + }, + { + "ordinal": 2, + "name": "plan!: Plan", + "type_info": { + "Custom": { + "name": "plan", + "kind": { + "Enum": [ + "free", + "tier1", + "tier2", + "tier3" + ] + } + } + } + }, + { + "ordinal": 3, + "name": "expires", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [] + }, + "nullable": [ + false, + false, + false, + false + ] + }, + "hash": "a894b9ae427c94e2db9095cc5b7c36dc8895cc4bb3c4dbc62cf2494760321174" +} diff --git a/.sqlx/query-df14410f966197efb84a9b9426a4d56c5ec230826d23204f9c4a93fc2164e01d.json b/.sqlx/query-df14410f966197efb84a9b9426a4d56c5ec230826d23204f9c4a93fc2164e01d.json new file mode 100644 index 0000000..6d910a5 --- /dev/null +++ b/.sqlx/query-df14410f966197efb84a9b9426a4d56c5ec230826d23204f9c4a93fc2164e01d.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "DELETE FROM RpcPlans WHERE email = $1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [] + }, + "hash": "df14410f966197efb84a9b9426a4d56c5ec230826d23204f9c4a93fc2164e01d" +} diff --git a/Dockerfile b/Dockerfile index 6ffee7e..e8994f0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,9 +10,14 @@ COPY --from=planner /app/recipe.json recipe.json # Build dependencies - this is the caching Docker layer! RUN cargo chef cook --release --recipe-path recipe.json # Build application -COPY . . +COPY ./Cargo.lock ./Cargo.lock +COPY ./Cargo.toml ./Cargo.toml +COPY ./src ./src +COPY ./.sqlx ./.sqlx +COPY ./migrations ./migrations #RUN cargo build --release --bin app #RUN cargo install sqlx-cli +RUN apt-get update RUN cargo build --release -ENTRYPOINT ["cargo", "run", "--release"] \ No newline at end of file +ENTRYPOINT ["cargo", "run", "--release"] From 3a640a603210097125287abe9f82ff441893961c Mon Sep 17 00:00:00 2001 From: crypdoughdoteth Date: Tue, 17 Jun 2025 14:32:03 -0400 Subject: [PATCH 06/28] Remove module --- src/json_rpc/.gitignore | 3 --- src/json_rpc/mod.rs | 1 - src/json_rpc/types.rs | 27 --------------------------- src/main.rs | 1 - 4 files changed, 32 deletions(-) delete mode 100644 src/json_rpc/.gitignore delete mode 100644 src/json_rpc/mod.rs delete mode 100644 src/json_rpc/types.rs diff --git a/src/json_rpc/.gitignore b/src/json_rpc/.gitignore deleted file mode 100644 index f9a3295..0000000 --- a/src/json_rpc/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/target -.env -~/.config/nvim-data/undodir/ diff --git a/src/json_rpc/mod.rs b/src/json_rpc/mod.rs deleted file mode 100644 index cd40856..0000000 --- a/src/json_rpc/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod types; diff --git a/src/json_rpc/types.rs b/src/json_rpc/types.rs deleted file mode 100644 index dad7a7c..0000000 --- a/src/json_rpc/types.rs +++ /dev/null @@ -1,27 +0,0 @@ -use serde::{Deserialize, Serialize}; - -#[derive(Debug, Serialize, Deserialize)] -pub struct JsonRpcResponse { - pub jsonrpc: String, - pub id: u16, - pub result: T, -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct JsonRpcRequest { - pub jsonrpc: String, - pub method: String, - pub params: Option, - pub id: u16, -} - -impl JsonRpcRequest { - pub fn new(method: String, params: Option, id: u16) -> Self { - Self { - jsonrpc: "2.0".to_owned(), - method, - params, - id, - } - } -} diff --git a/src/main.rs b/src/main.rs index 356f688..748ad88 100644 --- a/src/main.rs +++ b/src/main.rs @@ -37,7 +37,6 @@ use tracing_subscriber::fmt::format::FmtSpan; pub mod database; pub mod eth_rpc; -pub mod json_rpc; pub mod middleware; pub mod routes; From 1470153f26957d6e57186e4b554da9b790e39b71 Mon Sep 17 00:00:00 2001 From: "0xThresh.eth" <0xthresh@protonmail.com> Date: Wed, 18 Jun 2025 11:02:42 -0600 Subject: [PATCH 07/28] feat: Add Docker build and test actions --- .github/workflows/docker-build.yml | 40 ++++++++++++++++++++++++++++++ Dockerfile | 18 +++++++++----- Dockerfile.dev | 2 +- 3 files changed, 53 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/docker-build.yml diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml new file mode 100644 index 0000000..ba4bd38 --- /dev/null +++ b/.github/workflows/docker-build.yml @@ -0,0 +1,40 @@ +name: docker-build-test + +on: + push: + +jobs: + docker: + runs-on: ubuntu-latest + steps: + # - + # name: Login to Docker Hub + # uses: docker/login-action@v3 + # with: + # username: ${{ vars.DOCKERHUB_USERNAME }} + # password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - + name: Build and export + uses: docker/build-push-action@v6 + with: + push: false + load: true + tags: Developer-DAO/rpc:latest + + - + name: Test the container + run: docker run -p 3000:3000 Developer-DAO/rpc:latest + + - + name: Build and push + uses: docker/build-push-action@v6 + with: + push: false + load: true + tags: Developer-DAO/rpc:latest \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index e8994f0..8a0cec1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,17 +7,23 @@ RUN cargo chef prepare --recipe-path recipe.json FROM chef AS builder COPY --from=planner /app/recipe.json recipe.json -# Build dependencies - this is the caching Docker layer! -RUN cargo chef cook --release --recipe-path recipe.json +# Build dependencies +RUN rustup target add x86_64-unknown-linux-musl +RUN cargo chef cook --release --target x86_64-unknown-linux-musl --recipe-path recipe.json # Build application COPY ./Cargo.lock ./Cargo.lock COPY ./Cargo.toml ./Cargo.toml COPY ./src ./src COPY ./.sqlx ./.sqlx COPY ./migrations ./migrations -#RUN cargo build --release --bin app -#RUN cargo install sqlx-cli RUN apt-get update -RUN cargo build --release +RUN cargo build --release --target x86_64-unknown-linux-musl -ENTRYPOINT ["cargo", "run", "--release"] +# Create a minimal image with the compiled binary +#FROM gcr.io/distroless/static AS runtime +FROM scratch +WORKDIR /app +COPY --from=builder /app/target/release/dd_rpc /app/dd_rpc + +ENTRYPOINT ["/app/dd_rpc"] +#ENTRYPOINT ["/bin/sh"] diff --git a/Dockerfile.dev b/Dockerfile.dev index f0e3e6e..ff18190 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -8,7 +8,7 @@ RUN cargo chef prepare --recipe-path recipe.json FROM chef AS builder COPY --from=planner /app/recipe.json recipe.json # Build dependencies - this is the caching Docker layer! -RUN cargo chef cook --release --recipe-path recipe.json +RUN rustup target add x86_64-unknown-linux-mus # Build application COPY . . #RUN cargo build --release --bin app From dcfc354348f799f897e24fd192ed64038a50bc0f Mon Sep 17 00:00:00 2001 From: "0xThresh.eth" <0xthresh@protonmail.com> Date: Wed, 18 Jun 2025 11:09:31 -0600 Subject: [PATCH 08/28] fix: Add cargo config and env var for cross compile --- .cargo/.config | 2 ++ Dockerfile | 2 ++ 2 files changed, 4 insertions(+) create mode 100644 .cargo/.config diff --git a/.cargo/.config b/.cargo/.config new file mode 100644 index 0000000..730c383 --- /dev/null +++ b/.cargo/.config @@ -0,0 +1,2 @@ +[target.x86_64-unknown-linux-musl] +linker = "x86_64-linux-musl-gcc" \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 8a0cec1..c7c225d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,6 +9,7 @@ FROM chef AS builder COPY --from=planner /app/recipe.json recipe.json # Build dependencies RUN rustup target add x86_64-unknown-linux-musl +ENV CC_x86_64_unknown_linux_musl="x86_64-linux-musl-gcc" RUN cargo chef cook --release --target x86_64-unknown-linux-musl --recipe-path recipe.json # Build application COPY ./Cargo.lock ./Cargo.lock @@ -17,6 +18,7 @@ COPY ./src ./src COPY ./.sqlx ./.sqlx COPY ./migrations ./migrations RUN apt-get update +ENV CC_x86_64_unknown_linux_musl="x86_64-linux-musl-gcc" RUN cargo build --release --target x86_64-unknown-linux-musl # Create a minimal image with the compiled binary From 2bfcae9f59e6277fa760c3e8845115d06304f6c2 Mon Sep 17 00:00:00 2001 From: "0xThresh.eth" <0xthresh@protonmail.com> Date: Wed, 18 Jun 2025 11:11:58 -0600 Subject: [PATCH 09/28] fix: apt install required package for musl --- Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Dockerfile b/Dockerfile index c7c225d..51dd9d9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,6 +8,8 @@ RUN cargo chef prepare --recipe-path recipe.json FROM chef AS builder COPY --from=planner /app/recipe.json recipe.json # Build dependencies +RUN apt-get update +RUN apt-get install musl-tools RUN rustup target add x86_64-unknown-linux-musl ENV CC_x86_64_unknown_linux_musl="x86_64-linux-musl-gcc" RUN cargo chef cook --release --target x86_64-unknown-linux-musl --recipe-path recipe.json @@ -18,6 +20,7 @@ COPY ./src ./src COPY ./.sqlx ./.sqlx COPY ./migrations ./migrations RUN apt-get update +RUN apt-get install musl-tools ENV CC_x86_64_unknown_linux_musl="x86_64-linux-musl-gcc" RUN cargo build --release --target x86_64-unknown-linux-musl From 5e8f106918bb190e7b8564a3ebff524da19fbec2 Mon Sep 17 00:00:00 2001 From: "0xThresh.eth" <0xthresh@protonmail.com> Date: Wed, 18 Jun 2025 11:13:06 -0600 Subject: [PATCH 10/28] fix: add -y to apt-get --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 51dd9d9..0150b34 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,7 @@ FROM chef AS builder COPY --from=planner /app/recipe.json recipe.json # Build dependencies RUN apt-get update -RUN apt-get install musl-tools +RUN apt-get install musl-tools -y RUN rustup target add x86_64-unknown-linux-musl ENV CC_x86_64_unknown_linux_musl="x86_64-linux-musl-gcc" RUN cargo chef cook --release --target x86_64-unknown-linux-musl --recipe-path recipe.json @@ -20,7 +20,7 @@ COPY ./src ./src COPY ./.sqlx ./.sqlx COPY ./migrations ./migrations RUN apt-get update -RUN apt-get install musl-tools +RUN apt-get install musl-tools -y ENV CC_x86_64_unknown_linux_musl="x86_64-linux-musl-gcc" RUN cargo build --release --target x86_64-unknown-linux-musl From f93794df00bca6c49445de7c5f5ae8403e0ffa5e Mon Sep 17 00:00:00 2001 From: "0xThresh.eth" <0xthresh@protonmail.com> Date: Wed, 18 Jun 2025 11:17:04 -0600 Subject: [PATCH 11/28] fix: Add explicit OpenSSL dependency --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index d182d5d..c880008 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,7 @@ dotenvy = "0.15.7" hex = "0.4.3" jwt-simple = { version = "0.12.7", default-features = false, features = ["pure-rust"] } lettre = {version = "0.11.4", features = ["rustls-tls"]} +openssl = {version = "0.10.72", features = ["vendored"]} rand = "0.8.5" secp256k1 = {version = "0.28.2", features = ["rand", "global-context"]} serde = {version = "1.0.195", features = ["derive"]} From 64efb883b9dbcb36b50d94c1d3234c3d1f5197b9 Mon Sep 17 00:00:00 2001 From: "0xThresh.eth" <0xthresh@protonmail.com> Date: Wed, 18 Jun 2025 11:30:25 -0600 Subject: [PATCH 12/28] debug: find where dd_rpc binary ends up --- Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Dockerfile b/Dockerfile index 0150b34..8d7732c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,6 +23,9 @@ RUN apt-get update RUN apt-get install musl-tools -y ENV CC_x86_64_unknown_linux_musl="x86_64-linux-musl-gcc" RUN cargo build --release --target x86_64-unknown-linux-musl +RUN ls -al +RUN ls -al /app/target +RUN ls -al /app/target/release # Create a minimal image with the compiled binary #FROM gcr.io/distroless/static AS runtime From fa072278f42fe68e11d5724746c830579f6d2af0 Mon Sep 17 00:00:00 2001 From: "0xThresh.eth" <0xthresh@protonmail.com> Date: Wed, 18 Jun 2025 11:45:23 -0600 Subject: [PATCH 13/28] debug: check new x86 folder contents --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 8d7732c..7bc406b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,12 +26,13 @@ RUN cargo build --release --target x86_64-unknown-linux-musl RUN ls -al RUN ls -al /app/target RUN ls -al /app/target/release +RUN ls -al /app/target/x86_64-unknown-linux-musl # Create a minimal image with the compiled binary #FROM gcr.io/distroless/static AS runtime FROM scratch WORKDIR /app -COPY --from=builder /app/target/release/dd_rpc /app/dd_rpc +COPY --from=builder /app/target/x86_64-unknown-linux-musl/dd_rpc /app/dd_rpc ENTRYPOINT ["/app/dd_rpc"] #ENTRYPOINT ["/bin/sh"] From a0b90bfc84acdcd316aa9b3f53cd8ef77ad7ed85 Mon Sep 17 00:00:00 2001 From: "0xThresh.eth" <0xthresh@protonmail.com> Date: Wed, 18 Jun 2025 11:56:29 -0600 Subject: [PATCH 14/28] debug: check release folder --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 7bc406b..a756a15 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,6 +27,7 @@ RUN ls -al RUN ls -al /app/target RUN ls -al /app/target/release RUN ls -al /app/target/x86_64-unknown-linux-musl +RUN ls -al /app/target/x86_64-unknown-linux-musl/release # Create a minimal image with the compiled binary #FROM gcr.io/distroless/static AS runtime From e305044de81dc2ea3b7b605c4a010285b404d6c6 Mon Sep 17 00:00:00 2001 From: "0xThresh.eth" <0xthresh@protonmail.com> Date: Wed, 18 Jun 2025 12:02:27 -0600 Subject: [PATCH 15/28] fix: copy path for new dd_rpc binary --- Dockerfile | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index a756a15..99e3025 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,12 +7,14 @@ RUN cargo chef prepare --recipe-path recipe.json FROM chef AS builder COPY --from=planner /app/recipe.json recipe.json + # Build dependencies RUN apt-get update RUN apt-get install musl-tools -y RUN rustup target add x86_64-unknown-linux-musl ENV CC_x86_64_unknown_linux_musl="x86_64-linux-musl-gcc" RUN cargo chef cook --release --target x86_64-unknown-linux-musl --recipe-path recipe.json + # Build application COPY ./Cargo.lock ./Cargo.lock COPY ./Cargo.toml ./Cargo.toml @@ -23,17 +25,11 @@ RUN apt-get update RUN apt-get install musl-tools -y ENV CC_x86_64_unknown_linux_musl="x86_64-linux-musl-gcc" RUN cargo build --release --target x86_64-unknown-linux-musl -RUN ls -al -RUN ls -al /app/target -RUN ls -al /app/target/release -RUN ls -al /app/target/x86_64-unknown-linux-musl -RUN ls -al /app/target/x86_64-unknown-linux-musl/release # Create a minimal image with the compiled binary #FROM gcr.io/distroless/static AS runtime FROM scratch WORKDIR /app -COPY --from=builder /app/target/x86_64-unknown-linux-musl/dd_rpc /app/dd_rpc +COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/dd_rpc /app/dd_rpc ENTRYPOINT ["/app/dd_rpc"] -#ENTRYPOINT ["/bin/sh"] From 6e08d8402243c2c5f324b50889e0300a3f3bcee8 Mon Sep 17 00:00:00 2001 From: "0xThresh.eth" <0xthresh@protonmail.com> Date: Wed, 18 Jun 2025 12:09:34 -0600 Subject: [PATCH 16/28] fix: update from scratch to debian image to try to resolve deps issues --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 99e3025..b70e741 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,7 +28,8 @@ RUN cargo build --release --target x86_64-unknown-linux-musl # Create a minimal image with the compiled binary #FROM gcr.io/distroless/static AS runtime -FROM scratch +#FROM scratch +FROM debian:bookworm-slim WORKDIR /app COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/dd_rpc /app/dd_rpc From 548238f764eb0b524401383c4cacb5e6448b0485 Mon Sep 17 00:00:00 2001 From: "0xThresh.eth" <0xthresh@protonmail.com> Date: Wed, 18 Jun 2025 12:15:24 -0600 Subject: [PATCH 17/28] debug: Add rust backtrace to entrypoint --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index b70e741..3bd7fbf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -33,4 +33,4 @@ FROM debian:bookworm-slim WORKDIR /app COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/dd_rpc /app/dd_rpc -ENTRYPOINT ["/app/dd_rpc"] +ENTRYPOINT ["RUST_BACKTRACE=1", "/app/dd_rpc"] From 3afa1e80450bf60c05257bba9a04cf2aaccb98ad Mon Sep 17 00:00:00 2001 From: "0xThresh.eth" <0xthresh@protonmail.com> Date: Wed, 18 Jun 2025 12:22:10 -0600 Subject: [PATCH 18/28] fix: Rust debug env var --- Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 3bd7fbf..fa8bf07 100644 --- a/Dockerfile +++ b/Dockerfile @@ -33,4 +33,6 @@ FROM debian:bookworm-slim WORKDIR /app COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/dd_rpc /app/dd_rpc -ENTRYPOINT ["RUST_BACKTRACE=1", "/app/dd_rpc"] +ENV RUST_BACKTRACE="1" + +ENTRYPOINT ["/app/dd_rpc"] From 3d7afc2bf172eae1f5293b4d2ce3499d1c232ac1 Mon Sep 17 00:00:00 2001 From: "0xThresh.eth" <0xthresh@protonmail.com> Date: Wed, 18 Jun 2025 12:27:22 -0600 Subject: [PATCH 19/28] fix: Rust debug env var --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index fa8bf07..c4da28e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -33,6 +33,6 @@ FROM debian:bookworm-slim WORKDIR /app COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/dd_rpc /app/dd_rpc -ENV RUST_BACKTRACE="1" +ENV RUST_BACKTRACE="full" ENTRYPOINT ["/app/dd_rpc"] From 07ca4dda32ec25254a019554f6d03c954e643165 Mon Sep 17 00:00:00 2001 From: "0xThresh.eth" <0xthresh@protonmail.com> Date: Wed, 18 Jun 2025 12:32:16 -0600 Subject: [PATCH 20/28] test: run binary without copying to new layer --- Dockerfile | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index c4da28e..b12452c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,13 +26,16 @@ RUN apt-get install musl-tools -y ENV CC_x86_64_unknown_linux_musl="x86_64-linux-musl-gcc" RUN cargo build --release --target x86_64-unknown-linux-musl +# Test without smaller image +ENV RUST_BACKTRACE="full" + +ENTRYPOINT [ "/app/target/x86_64-unknown-linux-musl/release/dd_rpc" ] + # Create a minimal image with the compiled binary #FROM gcr.io/distroless/static AS runtime #FROM scratch -FROM debian:bookworm-slim -WORKDIR /app -COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/dd_rpc /app/dd_rpc - -ENV RUST_BACKTRACE="full" +# FROM debian:bookworm-slim +# WORKDIR /app +# COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/dd_rpc /app/dd_rpc -ENTRYPOINT ["/app/dd_rpc"] +#ENTRYPOINT ["/app/dd_rpc"] From 48874c6246b68ad38b1690a0cf7747de86bc7dca Mon Sep 17 00:00:00 2001 From: crypdoughdoteth Date: Wed, 18 Jun 2025 14:58:05 -0400 Subject: [PATCH 21/28] Fix program init --- Cargo.lock | 11 +++++++++++ src/main.rs | 1 - 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 235e615..892f1eb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1557,6 +1557,7 @@ dependencies = [ "jwt-simple", "lettre", "mimalloc", + "openssl", "rand 0.8.5", "reqwest", "secp256k1 0.28.2", @@ -3044,6 +3045,15 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" +[[package]] +name = "openssl-src" +version = "300.5.0+3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8ce546f549326b0e6052b649198487d91320875da901e7bd11a06d1ee3f9c2f" +dependencies = [ + "cc", +] + [[package]] name = "openssl-sys" version = "0.9.108" @@ -3052,6 +3062,7 @@ checksum = "e145e1651e858e820e4860f7b9c5e169bc1d8ce1c86043be79fa7b7634821847" dependencies = [ "cc", "libc", + "openssl-src", "pkg-config", "vcpkg", ] diff --git a/src/main.rs b/src/main.rs index 748ad88..5157d7c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -45,7 +45,6 @@ static GLOBAL: MiMalloc = MiMalloc; #[tokio::main] async fn main() { - dotenv().unwrap(); // PoktChains::init_deployment_url(); JWTKey::init().unwrap(); Database::init().await.unwrap(); From 4189d0e6a8427748351971c599b9415d48d8e441 Mon Sep 17 00:00:00 2001 From: "0xThresh.eth" <0xthresh@protonmail.com> Date: Sun, 22 Jun 2025 14:35:29 -0600 Subject: [PATCH 22/28] ci: remove test job to push imge --- .github/workflows/docker-build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index ba4bd38..bfe2655 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -27,9 +27,9 @@ jobs: load: true tags: Developer-DAO/rpc:latest - - - name: Test the container - run: docker run -p 3000:3000 Developer-DAO/rpc:latest + # - + # name: Test the container + # run: docker run -p 3000:3000 Developer-DAO/rpc:latest - name: Build and push From b97ee836d0fa048fcf0295bb84b58f6abd68b67c Mon Sep 17 00:00:00 2001 From: "0xThresh.eth" <0xthresh@protonmail.com> Date: Sun, 22 Jun 2025 16:44:52 -0600 Subject: [PATCH 23/28] ci: add ghcr login and push arg --- .github/workflows/docker-build.yml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index bfe2655..70fa0c3 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -6,13 +6,16 @@ on: jobs: docker: runs-on: ubuntu-latest + permissions: + packages: write steps: - # - - # name: Login to Docker Hub - # uses: docker/login-action@v3 - # with: - # username: ${{ vars.DOCKERHUB_USERNAME }} - # password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Login to Github Container Registry + uses: docker/login-action@v3 + with: + registry: https://ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Set up QEMU uses: docker/setup-qemu-action@v3 From 38bdc0b9c557f2d5164e6b05f53075ced36360a0 Mon Sep 17 00:00:00 2001 From: "0xThresh.eth" <0xthresh@protonmail.com> Date: Sun, 22 Jun 2025 16:54:22 -0600 Subject: [PATCH 24/28] fix: push job --- .github/workflows/docker-build.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 70fa0c3..0cd00da 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -22,13 +22,13 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - - name: Build and export - uses: docker/build-push-action@v6 - with: - push: false - load: true - tags: Developer-DAO/rpc:latest + # - + # name: Build and export + # uses: docker/build-push-action@v6 + # with: + # push: false + # load: true + # tags: Developer-DAO/rpc:latest # - # name: Test the container @@ -38,6 +38,6 @@ jobs: name: Build and push uses: docker/build-push-action@v6 with: - push: false - load: true + push: true + load: false tags: Developer-DAO/rpc:latest \ No newline at end of file From d9ded09f94b4c39266ab0eb867582214cf4498f0 Mon Sep 17 00:00:00 2001 From: "0xThresh.eth" <0xthresh@protonmail.com> Date: Sun, 22 Jun 2025 17:01:40 -0600 Subject: [PATCH 25/28] fix: image tag --- .github/workflows/docker-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 0cd00da..37b81ca 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -40,4 +40,4 @@ jobs: with: push: true load: false - tags: Developer-DAO/rpc:latest \ No newline at end of file + tags: ghcr.io/Developer-DAO/rpc:latest \ No newline at end of file From 65478b2cd4ef41ecc846ff6a6762f6f36f67ab02 Mon Sep 17 00:00:00 2001 From: "0xThresh.eth" <0xthresh@protonmail.com> Date: Sun, 22 Jun 2025 17:06:00 -0600 Subject: [PATCH 26/28] fix: capitalization --- .github/workflows/docker-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 37b81ca..cb1cf71 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -40,4 +40,4 @@ jobs: with: push: true load: false - tags: ghcr.io/Developer-DAO/rpc:latest \ No newline at end of file + tags: ghcr.io/developer-dao/rpc:latest \ No newline at end of file From a751d627831b0f65d14ff8811f7c51a95b0d87c1 Mon Sep 17 00:00:00 2001 From: "0xThresh.eth" <0xthresh@protonmail.com> Date: Sun, 22 Jun 2025 17:15:12 -0600 Subject: [PATCH 27/28] chore: cleanup --- .github/workflows/docker-build.yml | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index cb1cf71..954d293 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -22,18 +22,6 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - # - - # name: Build and export - # uses: docker/build-push-action@v6 - # with: - # push: false - # load: true - # tags: Developer-DAO/rpc:latest - - # - - # name: Test the container - # run: docker run -p 3000:3000 Developer-DAO/rpc:latest - - name: Build and push uses: docker/build-push-action@v6 From 10c8f6bd02792a9c0c191b2f2d81054fdcd4d725 Mon Sep 17 00:00:00 2001 From: "0xThresh.eth" <0xthresh@protonmail.com> Date: Sun, 22 Jun 2025 18:51:50 -0600 Subject: [PATCH 28/28] enh: support branch tags, latest tag only on merges to main --- .github/workflows/docker-build.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 954d293..094a58b 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -2,6 +2,8 @@ name: docker-build-test on: push: + branches: + - "**" jobs: docker: @@ -22,10 +24,20 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + - + name: Determine Docker tags + id: vars + run: | + if [ "${{ github.ref }}" == "refs/heads/main" ]; then + echo "TAGS=ghcr.io/developer-dao/rpc:latest,ghcr.io/developer-dao/rpc:${{ github.sha }}" >> $GITHUB_ENV + else + BRANCH_NAME=$(echo "${{ github.ref }}" | sed 's|refs/heads/||' | tr '/' '-' | tr '[:upper:]' '[:lower:]') + echo "TAGS=ghcr.io/developer-dao/rpc:${BRANCH_NAME}-${{ github.sha }}" >> $GITHUB_ENV + fi - name: Build and push uses: docker/build-push-action@v6 with: push: true load: false - tags: ghcr.io/developer-dao/rpc:latest \ No newline at end of file + tags: ${{ env.TAGS }} \ No newline at end of file