-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.worker
More file actions
110 lines (94 loc) · 3.34 KB
/
Dockerfile.worker
File metadata and controls
110 lines (94 loc) · 3.34 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# SPDX-FileCopyrightText: 2026 ArcheBase
#
# SPDX-License-Identifier: MulanPSL-2.0
# Multi-stage Dockerfile for building the Roboflow worker container.
#
# This Dockerfile creates a minimal container image for running Roboflow
# data conversion workers in Kubernetes environments.
#
# Build:
# docker build -f Dockerfile.worker -t roboflow-worker:latest .
#
# Run:
# docker run --rm roboflow-worker:latest convert --help
# =============================================================================
# Builder stage: Compile the Rust binary with all features
# =============================================================================
ARG RUST_VERSION=1.83
FROM docker.io/library/rust:${RUST_VERSION}-slim AS builder
# Install build dependencies
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
ca-certificates \
curl \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /build
# Copy Cargo manifests and lock file
COPY Cargo.toml Cargo.lock ./
COPY crates/ ./crates/
COPY src/ ./src/
# Build the worker binary with release optimizations and all features
# - dataset-all: Enable all dataset formats (HDF5, Parquet, depth)
# - distributed: Enable TiKV distributed coordination
# - cloud-storage: Enable S3/OSS cloud storage support
# - jemalloc: Use jemalloc for better multi-threaded performance
RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/target \
cargo build --release \
--bins \
--features "dataset-all,distributed,cloud-storage,jemalloc" \
&& mkdir -p /out \
&& cp target/release/convert /out/ \
&& cp target/release/extract /out/ \
&& cp target/release/inspect /out/ \
&& cp target/release/schema /out/ \
&& cp target/release/search /out/
# =============================================================================
# Runtime stage: Minimal image with only runtime dependencies
# =============================================================================
FROM docker.io/library/debian:bookworm-slim AS runtime
# Install runtime dependencies:
# - ffmpeg: For video encoding/decoding
# - ca-certificates: For HTTPS connections
# - libhdf5-*, libsz2, libzstd1, liblz4-1, libb2t1: HDF5 and compression libraries
# - libssl3, libcrypto++3: SSL/TLS support
RUN apt-get update && apt-get install -y \
ffmpeg \
ca-certificates \
libhdf5-103 \
libhdf5-cpp-103 \
libsz2 \
libzstd1 \
liblz4-1 \
libbz2-1 \
libssl3 \
libcurl4 \
libgomp1 \
&& rm -rf /var/lib/apt/lists/* \
&& update-ca-certificates
# Create non-root user for running the worker
RUN groupadd -r roboflow && useradd -r -g roboflow -u 1001 roboflow
# Set working directory
WORKDIR /workspace
# Copy binaries from builder
COPY --from=builder --chown=roboflow:roboflow /out/ /usr/local/bin/
# Verify the binary was copied
RUN chmod +x /usr/local/bin/convert \
/usr/local/bin/extract \
/usr/local/bin/inspect \
/usr/local/bin/schema \
/usr/local/bin/search
# Switch to non-root user
USER roboflow
# Set environment variables
ENV RUST_LOG=info \
RUST_BACKTRACE=1 \
PYTHONUNBUFFERED=1
# Health check to verify the container is functional
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD convert --version || exit 1
# Default command shows help
ENTRYPOINT ["/usr/local/bin/convert"]
CMD ["--help"]