Skip to content

Dockerfile for running client and server #82

Description

@dav-ell

To get this running in my environment I had to create a Dockerfile and build both the client and server from source, wanted to contribute it here

FROM python:3.12-slim-bookworm

ENV DEBIAN_FRONTEND=noninteractive

# Rust toolchain setup
ENV RUSTUP_HOME=/usr/local/rustup \
    CARGO_HOME=/usr/local/cargo \
    PATH=/usr/local/cargo/bin:${PATH}

# Source directory
ENV OXEN_SRC_DIR=/opt/oxen-dev
ENV PATH="${OXEN_SRC_DIR}/Oxen/target/debug:${PATH}"

# Install system dependencies
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
        git \
        curl \
        vim \
        nano \
        less \
        procps \
        openssh-client \
        gnupg \
        iputils-ping \
        dnsutils \
        bash-completion \
        wget \
        ca-certificates \
        build-essential \
        pkg-config \
        libssl-dev \
        cmake \
        libclang-dev \
        python3-dev && \
    curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable --profile default --no-modify-path && \
    apt-get clean && rm -rf /var/lib/apt/lists/*

# Install Python build tools
RUN pip install --no-cache-dir uv maturin wheel setuptools

# Clone and build Oxen from source
WORKDIR ${OXEN_SRC_DIR}
RUN git clone --depth 1 https://github.com/Oxen-AI/Oxen.git && \
    git clone --depth 1 https://github.com/Oxen-AI/oxen-release.git

WORKDIR ${OXEN_SRC_DIR}/Oxen
# Build the Oxen server
RUN cargo build

# Set up Python virtual environment for oxen-release
ENV OXEN_RELEASE_VENV_PATH=${OXEN_SRC_DIR}/oxen-release/.venv
RUN uv venv ${OXEN_RELEASE_VENV_PATH} --python $(which python3)
ENV PATH="${OXEN_RELEASE_VENV_PATH}/bin:${PATH}" \
    VIRTUAL_ENV=${OXEN_RELEASE_VENV_PATH}

WORKDIR ${OXEN_SRC_DIR}/oxen-release/oxen
RUN uv pip install --no-cache -r requirements.txt
RUN maturin develop

# Expose port and set default command
WORKDIR ${OXEN_SRC_DIR}/Oxen
EXPOSE 3001
CMD ["oxen-server", "start"]

Can be run with a docker-compose.yml like the below and then docker compose up --build

services:
  oxen-server-app:
    build:
      context: .
      dockerfile: Dockerfile
    image: oxen-app-server-custom
    container_name: my_oxen_server_instance
    ports:
      - "3000:3000"
    volumes:
      - ./my-oxen-data:/var/oxen/data
    command: "oxen-server start"
    restart: unless-stopped

And if you want to access the client you can docker exec -it my_oxen_server_instance bash and run

/var/oxen/data
oxen init
# ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions