Skip to content

Commit

Permalink
remove ., and go back to 0.0.0.0
Browse files Browse the repository at this point in the history
Signed-off-by: schristoff <28318173+schristoff@users.noreply.github.com>
  • Loading branch information
schristoff committed May 9, 2024
1 parent fd627b5 commit c8e9f8f
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 5 deletions.
Binary file added packages/zarf-registry/armregistry-zarf
Binary file not shown.
Binary file modified packages/zarf-registry/zarf-injector
Binary file not shown.
3 changes: 2 additions & 1 deletion packages/zarf-registry/zarf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ components:
architecture: arm64
files:
# Rust Injector Binary
- source: ./armzarf-registry
- source: ./armregistry-zarf
target: "###ZARF_TEMP###/zarf-injector"
executable: true

- name: zarf-seed-registry
Expand Down
3 changes: 3 additions & 0 deletions src/injector/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: 2021-Present The Zarf Authors

rustflags = ["-C", "relocation-model=static", "-C", "strip=symbols"]


[profile.release]
opt-level = "z" # Optimize for size.
lto = true
Expand Down
7 changes: 7 additions & 0 deletions src/injector/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ cargo build --target x86_64-unknown-linux-musl --release
* Install Docker & have it running
* Rust must be installed via Rustup (Check `which rustc` if you're unsure)

Add this to your ~/.cargo/config.toml
```
rustflags = ["-C", "relocation-model=static", "-C", "strip=symbols"]
```

```
cargo install cross --git https://github.com/cross-rs/cross
```
Expand All @@ -34,6 +39,8 @@ rustup toolchain install --force-non-host stable-x86_64-unknown-linux-musl
```
```
cross build --target x86_64-unknown-linux-musl --release
cross build --target aarch64-unknown-linux-musl --release
```


Expand Down
9 changes: 5 additions & 4 deletions src/injector/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ fn unpack(sha_sum: &String) {
}



/// Starts a static docker compliant registry server that only serves the single image from the CWD
///
/// (which is a OCI image layout):
Expand Down Expand Up @@ -158,7 +159,7 @@ async fn handler(Path(path): Path<String>) -> Response {
/// Handles the GET request for the manifest (only returns a OCI manifest regardless of Accept header)
async fn handle_get_manifest(name: String, reference: String) -> Response {
println!("name {}, reference {}", name, reference);
let index = fs::read_to_string(PathBuf::from("./zarf-seed").join("index.json")).expect("read index.json");
let index = fs::read_to_string(PathBuf::from("/zarf-seed").join("index.json")).expect("read index.json");
let json: Value = serde_json::from_str(&index).expect("unable to parse index.json");

let mut sha_manifest: String = "".to_owned();
Expand All @@ -182,7 +183,7 @@ async fn handle_get_manifest(name: String, reference: String) -> Response {
}
}
if !sha_manifest.is_empty() {
let file_path = PathBuf::from("./zarf-seed").to_owned().join( "/blobs/").join( &sha_manifest);
let file_path = PathBuf::from("/zarf-seed").to_owned().join( "/blobs/").join( &sha_manifest);
match tokio::fs::File::open(&file_path).await {
Ok(file) => {
let stream = ReaderStream::new(file);
Expand Down Expand Up @@ -216,7 +217,7 @@ async fn handle_get_manifest(name: String, reference: String) -> Response {

/// Handles the GET request for a blob
async fn handle_get_digest(tag: String) -> Response {
let blob_root = PathBuf::from("./zarf-seed").join("blobs").join("sha256");
let blob_root = PathBuf::from("/zarf-seed").join("blobs").join("sha256");
let path = blob_root.join(tag.strip_prefix("sha256:").unwrap());

let data = fs::read_to_string(path).expect("read index.json");
Expand All @@ -241,7 +242,7 @@ async fn main() {

unpack(payload_sha);

let listener = tokio::net::TcpListener::bind("127.0.0.1:5000")
let listener = tokio::net::TcpListener::bind("0.0.0.0:5000")
.await
.unwrap();
println!("listening on {}", listener.local_addr().unwrap());
Expand Down

0 comments on commit c8e9f8f

Please sign in to comment.