mirror of
https://github.com/NVIDIA/OpenShell.git
synced 2026-10-25 06:42:52 +08:00
62 lines
1.8 KiB
Docker
62 lines
1.8 KiB
Docker
# 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.
|
|
#
|
|
# Rust binaries are normally built natively before the image build and staged at:
|
|
# deploy/docker/.build/prebuilt-binaries/<arch>/openshell-gateway
|
|
#
|
|
# Local dev callers such as Skaffold can pass BUILD_FROM_SOURCE=1 to compile the
|
|
# gateway inside Docker instead.
|
|
|
|
ARG BUILD_FROM_SOURCE=0
|
|
ARG GATEWAY_BASE_IMAGE=nvcr.io/nvidia/distroless/cc:4.0.0
|
|
|
|
FROM rust:1.95.0-slim-bookworm AS rust-builder
|
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
build-essential \
|
|
ca-certificates \
|
|
cmake \
|
|
libssl-dev \
|
|
pkg-config \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
WORKDIR /build
|
|
|
|
COPY Cargo.toml Cargo.lock ./
|
|
COPY crates/ crates/
|
|
COPY proto/ proto/
|
|
COPY providers/ providers/
|
|
|
|
RUN --mount=type=cache,target=/usr/local/cargo/registry \
|
|
--mount=type=cache,target=/build/target \
|
|
cargo build --release \
|
|
--features "openshell-core/dev-settings" \
|
|
-p openshell-server \
|
|
--bin openshell-gateway \
|
|
&& mkdir -p /build/out \
|
|
&& install -m 0755 target/release/openshell-gateway /build/out/openshell-gateway
|
|
|
|
FROM scratch AS gateway-binary-0
|
|
ARG TARGETARCH
|
|
COPY --chmod=755 deploy/docker/.build/prebuilt-binaries/${TARGETARCH}/openshell-gateway /build/out/openshell-gateway
|
|
|
|
FROM rust-builder AS gateway-binary-1
|
|
|
|
FROM gateway-binary-${BUILD_FROM_SOURCE} AS gateway-binary
|
|
|
|
FROM ${GATEWAY_BASE_IMAGE} AS gateway
|
|
|
|
WORKDIR /app
|
|
|
|
COPY --from=gateway-binary /build/out/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"]
|