-
Notifications
You must be signed in to change notification settings - Fork 667
refactor(docker): split gateway/supervisor Dockerfiles and use native rust builds #1316
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,16 @@ use tracing::debug; | |
| /// Value of `SECCOMP_SET_MODE_FILTER` (linux/seccomp.h). | ||
| const SECCOMP_SET_MODE_FILTER: u64 = 1; | ||
|
|
||
| // libc 0.2.185 omits `SYS_kexec_file_load` from the musl/aarch64 bindings even | ||
| // though the kernel exposes syscall 294. Fall back to the literal so the | ||
| // supervisor's seccomp filter still blocks fileless kernel-image loads when | ||
| // built statically against musl on aarch64. | ||
| #[cfg(all(target_arch = "aarch64", target_env = "musl"))] | ||
| #[allow(non_upper_case_globals)] | ||
| const SYS_kexec_file_load: libc::c_long = 294; | ||
| #[cfg(not(all(target_arch = "aarch64", target_env = "musl")))] | ||
| use libc::SYS_kexec_file_load; | ||
|
|
||
| /// Apply the supervisor seccomp filter across the running process. | ||
| /// | ||
| /// This runs after privileged startup helpers complete and synchronizes the | ||
|
|
@@ -81,7 +91,7 @@ fn build_supervisor_prelude_rules() -> BTreeMap<i64, Vec<SeccompRule>> { | |
| libc::SYS_finit_module, | ||
| libc::SYS_delete_module, | ||
| libc::SYS_kexec_load, | ||
| libc::SYS_kexec_file_load, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be dependant on the constant defined or imported above? https://github.com/NVIDIA/OpenShell/pull/1316/changes#r3223215941 |
||
| SYS_kexec_file_load, | ||
| ] { | ||
| rules.entry(syscall).or_default(); | ||
| } | ||
|
|
@@ -423,7 +433,7 @@ mod tests { | |
| libc::SYS_finit_module, | ||
| libc::SYS_delete_module, | ||
| libc::SYS_kexec_load, | ||
| libc::SYS_kexec_file_load, | ||
| SYS_kexec_file_load, | ||
| ] { | ||
| assert!( | ||
| filter_rules.contains_key(&syscall), | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,37 @@ | ||||
| # syntax=docker/dockerfile:1.4 | ||||
|
|
||||
| # SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||||
| # SPDX-License-Identifier: Apache-2.0 | ||||
|
|
||||
| # Gateway image build. | ||||
| # | ||||
| # The Rust binary is built natively before this image build runs and staged at: | ||||
| # deploy/docker/.build/prebuilt-binaries/<arch>/openshell-gateway | ||||
| # | ||||
| # Use tasks/scripts/docker-build-image.sh gateway (or `mise run build:docker:gateway`) | ||||
| # to stage the binary and build the image in one step. CI builds the binary | ||||
| # per-architecture via the `rust-native-build.yml` workflow and uploads it as | ||||
| # an artifact, which is downloaded into the same staging directory before the | ||||
| # image build job runs. | ||||
| # | ||||
| # The runtime is `nvcr.io/nvidia/distroless/cc:4.0.0`, which provides glibc and | ||||
| # the dynamic loader needed by the GNU-linked gateway binary while keeping the | ||||
| # attack surface small. | ||||
|
|
||||
| ARG GATEWAY_BASE_IMAGE=nvcr.io/nvidia/distroless/cc:v4.0.4 | ||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We would need to update
The image choice in the job is pretty arbitrary and should work as long as |
||||
|
|
||||
| FROM ${GATEWAY_BASE_IMAGE} AS gateway | ||||
|
|
||||
| ARG TARGETARCH | ||||
|
|
||||
| WORKDIR /app | ||||
|
|
||||
| # --chmod=755 preserves the executable bit through actions/upload-artifact + | ||||
| # download-artifact, which strip exec perms during the roundtrip. | ||||
| COPY --chmod=755 deploy/docker/.build/prebuilt-binaries/${TARGETARCH}/openshell-gateway /usr/local/bin/openshell-gateway | ||||
|
|
||||
| USER 65532:65532 | ||||
| EXPOSE 8080 | ||||
|
|
||||
| ENTRYPOINT ["/usr/local/bin/openshell-gateway"] | ||||
| CMD ["--bind-address", "0.0.0.0", "--port", "8080"] | ||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This failed to work on macOS locally, so was added to get it working with a static build.