Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: docker images for iroh #2404

Merged
merged 18 commits into from
Jul 8, 2024
Merged

feat: docker images for iroh #2404

merged 18 commits into from
Jul 8, 2024

Conversation

Arqu
Copy link
Collaborator

@Arqu Arqu commented Jun 24, 2024

Description

  • Enable binding of the RPC endpoint to arbitrary addresses
  • Add Dockerfile for iroh

Breaking Changes

  • changed iroh::node::Node::my_rpc_port is now my_rpc_addr and returns Option<SocketAddr>
  • iroh::node::Builder::rpc_endpoint takes Option<SocketAddr> instead of Option`
  • added iroh::node::Builder::enable_rpc_with_addr allowing to specify on which address + port to bind to

Notes & open questions

Change checklist

  • Self-review.
  • Documentation updates if relevant.
  • Tests if relevant.
  • All breaking changes documented.

@Arqu Arqu self-assigned this Jun 24, 2024
Copy link
Collaborator Author

@Arqu Arqu left a comment

Choose a reason for hiding this comment

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

Also to make this easy to connect to other services on the local host, best bet is to run in network mode host.

Dockerfile Outdated Show resolved Hide resolved
Dockerfile Outdated Show resolved Hide resolved
@dignifiedquire
Copy link
Contributor

@Arqu once we merge this, can we automate it, to publish this to dockerhub on release?

Dockerfile Outdated
RUN cargo build --bin iroh --release --all-features

### Final Image
FROM ubuntu:latest as iroh
Copy link
Contributor

Choose a reason for hiding this comment

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

can we switch this to alpine?

Copy link
Contributor

Choose a reason for hiding this comment

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

or sth else that is smaller

@dignifiedquire dignifiedquire added this to the v0.20.0 milestone Jun 28, 2024
@Arqu Arqu changed the title WIP: feat: docker image for iroh feat: docker images for iroh Jun 28, 2024
@Arqu Arqu marked this pull request as ready for review June 28, 2024 13:18
@Arqu Arqu requested a review from flub June 28, 2024 13:18
@dignifiedquire
Copy link
Contributor

@Arqu we should have one minimal test in CI running the docker image and calling iroh node status or sth, to make sure the basic interactions always work

@Arqu Arqu requested a review from dignifiedquire July 2, 2024 11:30
@Arqu
Copy link
Collaborator Author

Arqu commented Jul 2, 2024

@Arqu we should have one minimal test in CI running the docker image and calling iroh node status or sth, to make sure the basic interactions always work

We got a node stats test now too.

Also should we title it as breaking? Document the rpc changes?

@dignifiedquire dignifiedquire self-assigned this Jul 3, 2024

/// Address to serve RPC on.
///
/// This overrides the address found in the IPFS_PATH.
Copy link
Contributor

Choose a reason for hiding this comment

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

What IPFS_PATH?

Copy link
Contributor

Choose a reason for hiding this comment

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

great question..

Copy link
Contributor

Choose a reason for hiding this comment

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

fixed

@@ -316,8 +320,10 @@ where
}

/// Configure the default iroh rpc endpoint.
pub async fn enable_rpc(self) -> Result<Builder<D>> {
let (ep, actual_rpc_port) = make_rpc_endpoint(&self.secret_key, DEFAULT_RPC_PORT)?;
pub async fn enable_rpc(self, rpc_addr: Option<SocketAddr>) -> Result<Builder<D>> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we keep the default builder API simple? I would guess that 99% of all users will want to enable rpc with the default value here.

So either .enable_rpc() or .enable_custom_rpc(AddrOpt) or maybe enable_rpc_with_opts(RpcOpts) in case we expect more options in the future?

Copy link
Contributor

Choose a reason for hiding this comment

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

fixed

let rpc_quinn_endpoint = match rpc_quinn_endpoint {
Ok(ep) => ep,
Err(err) => {
if err.kind() == std::io::ErrorKind::AddrInUse {
tracing::warn!(
"RPC port {} already in use, switching to random port",
rpc_port
rpc_addr.port(),
Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably log the entire addr.

Copy link
Contributor

Choose a reason for hiding this comment

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

fixed

build_docker.sh Outdated
@@ -0,0 +1,2 @@
docker buildx build -f docker/Dockerfile --target iroh --platform linux/arm64/v8 --tag n0computer/iroh:latest .
# docker buildx build -f docker/Dockerfile --target iroh --platform linux/amd64 --tag n0computer/iroh:latest .
Copy link
Contributor

Choose a reason for hiding this comment

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

what about this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We should drop this, stuff is already there in the readme.

## Building

- All commands are run from the root folder
- If you're on macOS run `docker buildx build -f docker/Dockerfile --target iroh --platform linux/arm64/v8 --tag n0computer/iroh:latest .`
Copy link
Contributor

Choose a reason for hiding this comment

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

what does buildx mean?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Buildx is an official extension by docker for the build system for images. Gives you the ability to specify platforms and some other nifty stuff.

@Arqu Arqu enabled auto-merge July 8, 2024 11:06
@Arqu Arqu added this pull request to the merge queue Jul 8, 2024
Merged via the queue into main with commit debc4fb Jul 8, 2024
25 of 26 checks passed
@dignifiedquire dignifiedquire deleted the arqu/docker branch July 8, 2024 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

3 participants