Skip to content

Commit 7fee6e7

Browse files
Dockerize CLI tool & improve aesthetics
1 parent 58ca883 commit 7fee6e7

File tree

6 files changed

+79
-18
lines changed

6 files changed

+79
-18
lines changed

.github/workflows/cd.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Build and Distributed D_D Cloud CLI
2+
3+
on:
4+
branches: [main]
5+
6+
jobs:
7+
docker-build-deploy:
8+
steps:
9+
- name: Checkout code
10+
uses: actions/checkout@v4
11+
12+
- name: Set up Docker Buildx
13+
uses: docker/setup-buildx-action@v3
14+
15+
- name: Log in to GitHub Container Registry
16+
uses: docker/login-action@v3
17+
with:
18+
registry: ghcr.io
19+
username: ${{ github.actor }}
20+
password: ${{ secrets.GITHUB_TOKEN }}
21+
22+
- name: Build and push dd-rpc image
23+
uses: docker/build-push-action@v5
24+
with:
25+
context: .
26+
file: ./Dockerfile
27+
push: true
28+
tags: ghcr.io/developer-dao/rpc:${{ github.sha }}

Cargo.lock

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
[package]
2-
name = "cloud-cli"
2+
name = "dd-cloud"
3+
authors = ["Zachary Kornberg <[email protected]>"]
34
version = "0.1.0"
5+
description = "The official CLI tool of Developer DAO Cloud."
46
edition = "2024"
57

68
[dependencies]

Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM lukemathwalker/cargo-chef:latest-rust-1 AS chef
2+
WORKDIR /app
3+
4+
FROM chef AS planner
5+
COPY . .
6+
RUN cargo chef prepare --recipe-path recipe.json
7+
8+
FROM chef AS builder
9+
COPY --from=planner /app/recipe.json recipe.json
10+
# Build dependencies - this is the caching Docker layer!
11+
RUN cargo chef cook --release --recipe-path recipe.json
12+
# Build application
13+
COPY . .
14+
RUN cargo build --release --bin dd-cloud
15+
16+
# We do not need the Rust toolchain to run the binary!
17+
FROM debian:trixie-slim AS runtime
18+
WORKDIR /dd-cloud
19+
COPY --from=builder /app/target/release/dd-cloud /usr/local/bin
20+
ENTRYPOINT ["/usr/local/bin/dd-cloud"]

src/main.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::{
33
account_info::{get_balance, get_rpc_calls},
44
keys::{delete_api_key, new_api_key},
55
},
6-
types::{ASCII_ART, LoginRequest},
6+
types::{ABOUT, ASCII_ART, LoginRequest},
77
};
88
use clap::{Parser, Subcommand};
99
use commands::keys::get_keys_interactive;
@@ -12,22 +12,29 @@ use dialoguer::{Input, Password, theme::ColorfulTheme};
1212

1313
pub mod commands;
1414
pub mod types;
15-
1615
#[derive(Parser)]
16+
#[command(version, about = ABOUT, long_about = None, name = "dd-cloud", author)]
1717
pub struct CloudCli {
1818
#[command(subcommand)]
1919
cmd: Command,
2020
}
2121

2222
#[derive(Subcommand)]
2323
pub enum Command {
24+
/// Retrieve one of your API key for D_D Cloud.
2425
GetApiKey {
25-
#[arg(short, long)]
26+
/// Flag to print the full URL including your API key to the terminal.
27+
/// Unsafe to use because your API key is written to stdout.
28+
#[arg(long)]
2629
unsafe_print: bool,
2730
},
31+
/// Delete one of your API keys for D_D Cloud.
2832
DeleteApiKey,
33+
/// Generate a new API key for D_D Cloud. Max 10.
2934
NewApiKey,
35+
/// Returns the number of calls you made this cycle.
3036
TrackUsage,
37+
/// Returns your account balance.
3138
Balance,
3239
}
3340

@@ -50,6 +57,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
5057
.interact()?;
5158

5259
term.clear_screen()?;
60+
term.write_line(ASCII_ART)?;
61+
term.write_line("")?;
5362

5463
let login = LoginRequest { email, password };
5564

src/types.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ pub const ASCII_ART: &'static str = {
1313
"#
1414
};
1515

16+
pub const ABOUT: &str = "Welcome to the D_D Cloud CLI tool. Conveniently manage API keys, track service usage, and view account balances all from your terminal.";
17+
1618
pub static CHAINS: &[Chains] = &[
1719
Chains::Ethereum,
1820
Chains::Base,

0 commit comments

Comments
 (0)