Skip to content
This repository was archived by the owner on Feb 23, 2026. It is now read-only.

Build docker bootstrap image#6

Merged
gregcusack merged 3 commits intoanza-xyz:mainfrom
gregcusack:build-bootstrap-image
Apr 10, 2024
Merged

Build docker bootstrap image#6
gregcusack merged 3 commits intoanza-xyz:mainfrom
gregcusack:build-bootstrap-image

Conversation

@gregcusack
Copy link
Copy Markdown
Contributor

@gregcusack gregcusack commented Mar 29, 2024

Summary of Changes

  1. Add bootstrap startup script for docker container
  2. Build docker bootstrap image.

6th PR in a series of PRs that will build out the mongon testing framework for deploying validator clusters on Kubernetes
Previous PRs:

  1. PR: add PROGRESS.md and connect to k8s endpoint to check namespace exists #1
  2. PR: Add in ability to build solana binary from local repo on host #2
  3. PR: Add pull specific solana-release version #3
  4. PR: Create genesis struct. and generate bootstrap and faucet accounts #4
  5. PR: Build genesis and add genesis cli flags #5

@gregcusack gregcusack force-pushed the build-bootstrap-image branch from fac42c4 to 08f084a Compare April 8, 2024 16:54
@gregcusack gregcusack force-pushed the build-bootstrap-image branch from 5592544 to 836d006 Compare April 8, 2024 17:32
@gregcusack gregcusack requested review from joncinque and yihau and removed request for joncinque April 8, 2024 18:01
Comment thread src/docker.rs
Comment on lines +154 to +177
FROM {}
RUN apt-get update
RUN apt-get install -y iputils-ping curl vim bzip2

RUN useradd -ms /bin/bash solana
RUN adduser solana sudo
USER solana

RUN mkdir -p /home/solana/k8s-cluster-scripts
# TODO: this needs to be changed for non bootstrap, this should be ./src/scripts/<validator-type>-startup-scripts.sh
COPY {startup_script_directory}/bootstrap-startup-script.sh /home/solana/k8s-cluster-scripts

RUN mkdir -p /home/solana/ledger
COPY --chown=solana:solana ./config-k8s/bootstrap-validator /home/solana/ledger

RUN mkdir -p /home/solana/.cargo/bin

COPY ./{solana_build_directory}/bin/ /home/solana/.cargo/bin/
COPY ./{solana_build_directory}/version.yml /home/solana/

RUN mkdir -p /home/solana/config
ENV PATH="/home/solana/.cargo/bin:${{PATH}}"

WORKDIR /home/solana
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: could consider to use less RUN command to reduce the image size.

Comment thread src/lib.rs
pub mod release;

static SUN: Emoji = Emoji("🌞 ", "");
static BUILD: Emoji = Emoji("👷 ", "");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👷‍♂️

@gregcusack gregcusack merged commit 044c9d2 into anza-xyz:main Apr 10, 2024
@gregcusack gregcusack deleted the build-bootstrap-image branch April 10, 2024 17:10
Copy link
Copy Markdown

@joncinque joncinque left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some more fly-by comments!

Comment thread src/main.rs
let docker = DockerConfig::new(
matches
.value_of("base_image")
.unwrap_or_default()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: This should probably be an unwrap(), like all the others. Even though it won't get triggered thanks to default_value(...)

Comment thread src/main.rs
matches.value_of("image_name").unwrap().to_string(),
matches
.value_of("image_tag")
.unwrap_or_default()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Same here, should be an unwrap() instead

Comment thread src/release.rs
Comment on lines +57 to +59
pub fn build_path(&self) -> PathBuf {
self.build_path.clone()
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this be used in future PRs?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh shoot no not anymore.

Comment thread src/docker.rs
progress_bar.set_message(format!("{BUILD}Building {validator_type} docker image...",));

let command = format!(
"docker build -t {}/{image_name}:{} -f {dockerfile:?} {context_path}",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question on using {dockerfile:?} here: the documentation says to use the Debug formatter if you want to escape the path at https://doc.rust-lang.org/std/path/struct.PathBuf.html#method.display

Is using display() no good for your use-case?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did not realize that. will update.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that you're using the _lossy bits for Windows, and display "This may perform lossy conversion, depending on the platform", I'm more convinced that it's the better approach

Comment thread src/docker.rs
Comment on lines +136 to +137
let manifest_path =
PathBuf::from(env::var("CARGO_MANIFEST_DIR").expect("$CARGO_MANIFEST_DIR"));
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just did a little test, and CARGO_MANIFEST_DIR is only set when invoking the program using cargo, and not just calling the executable directly.

Since this might be slightly brittle, would it make sense to also pass a path to the scripts directory?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the best way to do this? Just add a flag that is something like: --startup-scripts-dir <path>? or were you thinking something else?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we also use this here:

validator-lab/src/lib.rs

Lines 19 to 21 in 044c9d2

pub fn get_solana_root() -> PathBuf {
PathBuf::from(env::var("CARGO_MANIFEST_DIR").expect("$CARGO_MANIFEST_DIR")).to_path_buf()
}
. We need this for the release-channel deployment method. So maybe we just pass in a --validator-lab-dir <absolute-path-to-validator-lab-directory>. From here we can get startup script directory and then of course the directory needed for release-channel deployment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense to me!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool! it's implemented in: #8

Comment thread src/main.rs
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants