Mirror of https://github.com/roostorg/osprey
github.com/roostorg/osprey
1# syntax=docker/dockerfile:1
2FROM python:3.11-slim
3ARG TARGETPLATFORM
4
5WORKDIR /osprey
6ENV ETCD_PEERS=http://etcd:2379
7ENV PYTHONPATH=/osprey
8
9ENV PORT=5000
10EXPOSE ${PORT}
11
12RUN set -ex && \
13 apt-get update && \
14 apt-get install -yqq --no-install-recommends libjemalloc-dev git gcc g++ wget ssh && \
15 apt-get clean && \
16 apt-get -y purge wget && \
17 apt-get -y autoremove && \
18 rm -fr /var/cache/apt/archives/* && \
19 rm -rf /var/lib/apt/lists/*
20
21# Hack to get the right libjemalloc location
22ENV LIB_ARCH=${TARGETPLATFORM##*/}
23ENV LIB_ARCH=${LIB_ARCH/amd64/x86_64-linux-gnu}
24ENV LIB_ARCH=${LIB_ARCH/arm64/aarch64-linux-gnu}
25ENV LD_PRELOAD="/usr/lib/${LIB_ARCH}/libjemalloc.so"
26ENV MALLOC_CONF="narenas:4"
27
28# Set up python environment
29ADD uv.lock /osprey/uv.lock
30ADD pyproject.toml /osprey/pyproject.toml
31ADD README.md /osprey/README.md
32ADD LICENSE.md /osprey/LICENSE.md
33
34# Create workspace structure with pyproject.toml files for uv sync to work
35ADD osprey_rpc/pyproject.toml /osprey/osprey_rpc/pyproject.toml
36ADD osprey_worker/pyproject.toml /osprey/osprey_worker/pyproject.toml
37ADD example_plugins/pyproject.toml /osprey/example_plugins/pyproject.toml
38
39# Create minimal package structure required by uv
40RUN mkdir -p /osprey/osprey_worker /osprey/osprey_rpc /osprey/example_plugins/src && \
41 touch /osprey/osprey_worker/__init__.py /osprey/osprey_rpc/__init__.py /osprey/example_plugins/src/__init__.py
42
43# Install dependencies first (this layer will be cached when only source code changes)
44RUN pip install --upgrade pip uv && \
45 uv sync --locked --python=$(which python3.11) && \
46 pip cache purge && uv cache clean
47
48# https://tld.readthedocs.io/en/latest/#update-the-list-of-tld-names
49RUN . .venv/bin/activate && update-tld-names
50
51# Add source code after dependencies are installed
52ADD example_rules /osprey/example_rules
53ADD osprey_worker /osprey/osprey_worker
54ADD osprey_rpc /osprey/osprey_rpc
55ADD example_plugins /osprey/example_plugins
56
57COPY entrypoint.sh /osprey/entrypoint.sh
58
59ENTRYPOINT ["/osprey/entrypoint.sh"]