-
Notifications
You must be signed in to change notification settings - Fork 235
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Node status API dockerfile and env vars (#4986)
* feat: add dockerfile and env variables * Added workflow for pushing node status api on harbor * Misc changes to pathing and using yq instead of jq * fix: change the way we read env vars for nyxd, nym api and explorer * fix: docker build workflow * Remove config in favor of clap args * Added naming and tags * change from value to result --------- Co-authored-by: Lawrence Stalder <[email protected]> Co-authored-by: dynco-nym <[email protected]>
- Loading branch information
1 parent
e5a29cc
commit 40d9321
Showing
10 changed files
with
158 additions
and
121 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 |
---|---|---|
@@ -1,11 +1,55 @@ | ||
name: Build and upload Node Status API container to harbor.nymte.ch | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
env: | ||
WORKING_DIRECTORY: "nym-node-status-api" | ||
CONTAINER_NAME: "node-status-api" | ||
|
||
jobs: | ||
my-job: | ||
runs-on: arc-ubuntu-22.04 | ||
build-container: | ||
runs-on: arc-ubuntu-22.04-dind | ||
steps: | ||
- name: my-step | ||
run: echo "Hello World!" | ||
- name: Login to Harbor | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: harbor.nymte.ch | ||
username: ${{ secrets.HARBOR_ROBOT_USERNAME }} | ||
password: ${{ secrets.HARBOR_ROBOT_SECRET }} | ||
|
||
- name: Checkout repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: Configure git identity | ||
run: | | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "Lawrence Stalder" | ||
- name: Get version from cargo.toml | ||
uses: mikefarah/[email protected] | ||
id: get_version | ||
with: | ||
cmd: yq -oy '.package.version' ${{ env.WORKING_DIRECTORY }}/Cargo.toml | ||
|
||
- name: Check if tag exists | ||
run: | | ||
if git rev-parse ${{ env.WORKING_DIRECTORY }}-${{ steps.get_version.outputs.result }} >/dev/null 2>&1; then | ||
echo "Tag ${{ steps.get_version.outputs.result }} already exists" | ||
fi | ||
- name: Remove existing tag if exists | ||
run: | | ||
if git rev-parse ${{ env.WORKING_DIRECTORY }}-${{ steps.get_version.outputs.result }} >/dev/null 2>&1; then | ||
git push --delete origin ${{ env.WORKING_DIRECTORY }}-${{ steps.get_version.outputs.result }} | ||
git tag -d ${{ env.WORKING_DIRECTORY }}-${{ steps.get_version.outputs.result }} | ||
fi | ||
- name: Create tag | ||
run: | | ||
git tag -a ${{ env.WORKING_DIRECTORY }}-${{ steps.get_version.outputs.result }} -m "Version ${{ steps.get_version.outputs.result }}" | ||
git push origin ${{ env.WORKING_DIRECTORY }}-${{ steps.get_version.outputs.result }} | ||
- name: BuildAndPushImageOnHarbor | ||
run: | | ||
docker build -f ${{ env.WORKING_DIRECTORY }}/Dockerfile . -t harbor.nymte.ch/nym/${{ env.CONTAINER_NAME }}:${{ steps.get_version.outputs.result }} -t harbor.nymte.ch/nym/${{ env.CONTAINER_NAME }}:latest | ||
docker push harbor.nymte.ch/nym/${{ env.CONTAINER_NAME }} --all-tags |
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
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
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,15 @@ | ||
FROM rust:latest AS builder | ||
|
||
COPY ./ /usr/src/nym | ||
WORKDIR /usr/src/nym/nym-node-status-api | ||
|
||
RUN cargo build --release | ||
|
||
FROM ubuntu:24.04 | ||
|
||
RUN apt-get update && apt-get install -y ca-certificates | ||
|
||
WORKDIR /nym | ||
|
||
COPY --from=builder /usr/src/nym/target/release/nym-node-status-api ./ | ||
ENTRYPOINT [ "/nym/nym-node-status-api" ] |
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
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 |
---|---|---|
@@ -1,17 +1,69 @@ | ||
use clap::Parser; | ||
use nym_bin_common::bin_info; | ||
use std::sync::OnceLock; | ||
use reqwest::Url; | ||
use std::{sync::OnceLock, time::Duration}; | ||
|
||
// Helper for passing LONG_VERSION to clap | ||
fn pretty_build_info_static() -> &'static str { | ||
static PRETTY_BUILD_INFORMATION: OnceLock<String> = OnceLock::new(); | ||
PRETTY_BUILD_INFORMATION.get_or_init(|| bin_info!().pretty_print()) | ||
} | ||
|
||
#[derive(Parser, Debug)] | ||
#[derive(Clone, Debug, Parser)] | ||
#[clap(author = "Nymtech", version, long_version = pretty_build_info_static(), about)] | ||
pub(crate) struct Cli { | ||
/// Path pointing to an env file that configures the Nym API. | ||
#[clap(short, long)] | ||
pub(crate) config_env_file: Option<std::path::PathBuf>, | ||
/// Network name for the network to which we're connecting. | ||
#[clap(long, env = "NETWORK_NAME")] | ||
pub(crate) network_name: String, | ||
|
||
/// Explorer api url. | ||
#[clap(short, long, env = "EXPLORER_API")] | ||
pub(crate) explorer_api: String, | ||
|
||
/// Nym api url. | ||
#[clap(short, long, env = "NYM_API")] | ||
pub(crate) nym_api: String, | ||
|
||
/// TTL for the http cache. | ||
#[clap( | ||
long, | ||
default_value_t = 30, | ||
env = "NYM_NODE_STATUS_API_NYM_HTTP_CACHE_TTL" | ||
)] | ||
pub(crate) nym_http_cache_ttl: u64, | ||
|
||
/// HTTP port on which to run node status api. | ||
#[clap(long, default_value_t = 8000, env = "NYM_NODE_STATUS_API_HTTP_PORT")] | ||
pub(crate) http_port: u16, | ||
|
||
/// Nyxd address. | ||
#[clap(long, env = "NYXD")] | ||
pub(crate) nyxd_addr: Url, | ||
|
||
/// Nym api client timeout. | ||
#[clap( | ||
long, | ||
default_value = "15", | ||
env = "NYM_NODE_STATUS_API_NYM_API_CLIENT_TIMEOUT" | ||
)] | ||
#[arg(value_parser = parse_duration)] | ||
pub(crate) nym_api_client_timeout: Duration, | ||
|
||
/// Explorer api client timeout. | ||
#[clap( | ||
long, | ||
default_value = "15", | ||
env = "NYM_NODE_STATUS_API_EXPLORER_CLIENT_TIMEOUT" | ||
)] | ||
#[arg(value_parser = parse_duration)] | ||
pub(crate) explorer_client_timeout: Duration, | ||
|
||
/// Connection url for the database. | ||
#[clap(long, env = "NYM_NODE_STATUS_API_CONNECTION_URL")] | ||
pub(crate) connection_url: String, | ||
} | ||
|
||
fn parse_duration(arg: &str) -> Result<std::time::Duration, std::num::ParseIntError> { | ||
let seconds = arg.parse()?; | ||
Ok(std::time::Duration::from_secs(seconds)) | ||
} |
This file was deleted.
Oops, something went wrong.
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
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
Oops, something went wrong.