forked from tiammomo/ModelPort
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
67 lines (54 loc) · 2.26 KB
/
Copy pathDockerfile
File metadata and controls
67 lines (54 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# syntax=docker/dockerfile:1
ARG RUST_VERSION=1.96.0
ARG MODELPORT_VERSION=0.1.0
ARG MODELPORT_SOURCE_REVISION=unknown
ARG MODELPORT_SOURCE_STATE=unknown
ARG MODELPORT_BUILD_DATE=unknown
FROM rust:${RUST_VERSION}-bookworm AS builder
ARG MODELPORT_SOURCE_REVISION
ARG MODELPORT_SOURCE_STATE
ENV MODELPORT_BUILD_REVISION=${MODELPORT_SOURCE_REVISION}
ENV MODELPORT_BUILD_SOURCE_STATE=${MODELPORT_SOURCE_STATE}
WORKDIR /app
COPY Cargo.toml Cargo.lock ./
COPY src ./src
COPY migrations ./migrations
COPY crates ./crates
COPY ops-agent ./ops-agent
# Embedded at compile time via include_str! (src/model_catalog.rs,
# src/runtime_adapter.rs); a missing directory fails `cargo build`.
COPY catalog ./catalog
COPY schemas ./schemas
RUN cargo build --release --locked -p model-port
FROM debian:bookworm-slim AS runtime
RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates curl \
&& rm -rf /var/lib/apt/lists/*
RUN useradd --system --home /nonexistent --shell /usr/sbin/nologin modelport
RUN mkdir -p /data /config \
&& chown -R modelport:modelport /data /config
COPY --from=builder /app/target/release/model-port /usr/local/bin/model-port
# Keep source metadata after dependency and binary layers so a new commit label
# does not invalidate the slow apt or Rust build cache.
ARG MODELPORT_SOURCE_REVISION
ARG MODELPORT_SOURCE_STATE
ARG MODELPORT_VERSION
ARG MODELPORT_BUILD_DATE
LABEL org.opencontainers.image.title="ModelPort" \
org.opencontainers.image.description="Self-hosted multi-protocol model gateway" \
org.opencontainers.image.source="https://github.com/tiammomo/ModelPort" \
org.opencontainers.image.revision="$MODELPORT_SOURCE_REVISION" \
org.opencontainers.image.version="$MODELPORT_VERSION" \
org.opencontainers.image.created="$MODELPORT_BUILD_DATE" \
org.opencontainers.image.licenses="MIT" \
io.modelport.source-state="$MODELPORT_SOURCE_STATE"
USER modelport
ENV MODELPORT_BIND=0.0.0.0:38082
ENV MODELPORT_STATE_DIR=/data
ENV MODELPORT_CONFIG=/config/config.toml
ENV RUST_LOG=model_port=info,tower_http=info
EXPOSE 38082
VOLUME ["/data"]
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD curl -fsS http://127.0.0.1:38082/livez >/dev/null || exit 1
ENTRYPOINT ["/usr/local/bin/model-port"]