Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 53 additions & 29 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
FROM obolibrary/odkfull:latest
FROM ubuntu:24.04

# Install git and dependencies
# Avoid apt cache issues
ENV DEBIAN_FRONTEND=noninteractive

# Install git and dependencies in one layer with proper cleanup
RUN apt-get update && apt-get install -y \
git \
build-essential \
Expand All @@ -12,26 +15,29 @@ RUN apt-get update && apt-get install -y \
curl \
liblzma-dev \
software-properties-common \
unzip \
ca-certificates \
--no-install-recommends \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /var/cache/apt/archives/*

# Set noninteractive installation
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Etc/UTC

# Install Python 3.11 directly
RUN add-apt-repository ppa:deadsnakes/ppa && \
apt-get update && \
apt-get install -y python3.11 python3.11-venv python3.11-dev python3-pip tzdata && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Set Python 3.11 as default
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 1 && \
update-alternatives --set python3 /usr/bin/python3.11 && \
update-alternatives --install /usr/bin/python python /usr/bin/python3.11 1 && \
update-alternatives --set python /usr/bin/python3.11 && \
ln -sf /usr/bin/python3.11 /usr/local/bin/python
# Install bun.sh
RUN curl -fsSL https://bun.sh/install | bash -

# Install pyenv for Python version management
WORKDIR /root
RUN curl -sL https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
ENV PYENV_ROOT="/root/.pyenv"
ENV PATH="${PYENV_ROOT}/bin:${PYENV_ROOT}/shims:${PATH}"

# Install Python 3.11 with pyenv
RUN pyenv install 3.11.4 && \
pyenv global 3.11.4

# Get the correct version of pip for Python 3.11
RUN curl -sS https://bootstrap.pypa.io/get-pip.py | python && \
pip install --upgrade pip

# Install Node.js using NVM
ENV NVM_DIR=/root/.nvm
Expand Down Expand Up @@ -59,15 +65,7 @@ RUN curl -fsSL https://get.pnpm.io/install.sh | bash -
# Install bun
RUN curl -fsSL https://bun.sh/install | bash -

# Clone and install cborg-code permanently using token
# Pass GH_TOKEN as a build arg: docker build --build-arg GH_TOKEN=your_token_here ...
ARG GH_TOKEN
RUN mkdir -p /tools/cborg && \
cd /tools/cborg && \
git clone https://${GH_TOKEN}@github.com/lbnl-science-it/cborg-code.git . && \
pnpm install && \
bun build src/entrypoints/cli.tsx --minify --outfile cli.mjs --target=node && \
pnpm link --global


# Pre-configure cborg-code with default settings
#RUN mkdir -p /root/.config/cborg-code && \
Expand All @@ -80,6 +78,13 @@ RUN curl -sS https://bootstrap.pypa.io/get-pip.py | python3.11 && \
# Install Python packages
RUN python3.11 -m pip install aurelian jinja2-cli "wrapt>=1.17.2"

# remove /tools/cborg/cborg-code if it exists
RUN rm -rf /tools/cborg/cborg-code

# Clone and install cborg-code permanently using token
# Pass GH_TOKEN as a build arg: docker build --build-arg GH_TOKEN=your_token_here ...


# #export LOGFIRE_SEND_TO_LOGFIRE=false
ENV LOGFIRE_SEND_TO_LOGFIRE=false

Expand All @@ -95,11 +100,29 @@ RUN cat /tmp/git-bashrc-config.sh >> ~/.bashrc
# Make sure git and bash-completion are installed
# RUN apt-get update && apt-get install -y bash-completion

RUN mkdir -p /tools

# make sure we have the latest obo-scripts
RUN cd /tools/ && rm -rf obo-scripts && git clone https://github.com/cmungall/obo-scripts

ENV PATH=$PATH:/tools/obo-scripts/

# Clone repository with GitHub token using BuildKit secrets
# This requires Docker BuildKit to be enabled
RUN --mount=type=secret,id=gh_token \
mkdir -p /tools/cborg && \
cd /tools/cborg && \
GH_TOKEN=$(cat /run/secrets/gh_token) && \
echo "Using token to clone repository..." && \
git clone https://oauth2:${GH_TOKEN}@github.com/lbnl-science-it/cborg-code.git . && \
echo "Installing dependencies with pnpm..." && \
pnpm install && \
echo "Building with bun..." && \
bun build src/entrypoints/cli.tsx --minify --outfile cli.mjs --target=node && \
echo "Linking package globally..." && \
pnpm link --global && \
rm -rf /tools/cborg/.git

# Copy entrypoint script
COPY bin/entrypoint.sh /usr/local/bin/entrypoint.sh

Expand All @@ -109,5 +132,6 @@ ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
# Set working directory
WORKDIR /work


# Default command
CMD ["bash"]
71 changes: 62 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,35 +1,88 @@
.PHONY: build push
.PHONY: build push setup-buildx build-multiarch push-multiarch run test test-repos

IMAGE_NAME = odk-ai
TAG = latest
PLATFORMS = linux/amd64,linux/arm64

#BUILD_OPTS = --no-cache
BUILD_OPTS =

build:
# Check for GH_TOKEN
check-token:
@if [ -z "$$GH_TOKEN" ]; then \
echo "ERROR: GH_TOKEN environment variable is not set"; \
echo "Please set it with: export GH_TOKEN=your_github_token"; \
echo "You can create a token at https://github.com/settings/tokens"; \
exit 1; \
fi

# Setup buildx for multi-architecture builds
setup-buildx:
docker buildx create --name multiarch-builder --use || true
docker buildx inspect --bootstrap

# Original single-architecture build
build: check-token
docker build $(BUILD_OPTS) --build-arg GH_TOKEN=$(GH_TOKEN) -t cmungall/$(IMAGE_NAME):$(TAG) .

# Push the single-architecture image
push: build
docker tag $(IMAGE_NAME):$(TAG) cmungall/$(IMAGE_NAME):$(TAG)
docker push cmungall/$(IMAGE_NAME):$(TAG)

# Multi-architecture build using buildx
build-multiarch: check-token setup-buildx
# Note: For local use, build only for the current architecture
docker system prune -f || true
docker buildx build $(BUILD_OPTS) \
--platform linux/amd64 \
--secret id=gh_token,env=GH_TOKEN \
-t cmungall/$(IMAGE_NAME):$(TAG) \
--load \
.


# Build individual platform images with proper disk space management
build-amd64: check-token setup-buildx
# Ensure we have enough disk space for the build
docker system prune -f || true
docker buildx build $(BUILD_OPTS) \
--platform linux/amd64 \
--secret id=gh_token,env=GH_TOKEN \
-t cmungall/$(IMAGE_NAME):amd64 \
--load \
.

build-arm64: check-token setup-buildx
# Ensure we have enough disk space for the build
docker system prune -f || true
docker buildx build $(BUILD_OPTS) \
--platform linux/arm64 \
--secret id=gh_token,env=GH_TOKEN \
-t cmungall/$(IMAGE_NAME):arm64 \
--load \
.

# Push multi-architecture images
push-multiarch: check-token setup-buildx
# Ensure we have enough disk space for the build
docker system prune -f || true
docker buildx build $(BUILD_OPTS) \
--platform $(PLATFORMS) \
--secret id=gh_token,env=GH_TOKEN \
-t cmungall/$(IMAGE_NAME):$(TAG) \
--push \
.

# Run the container
run:
docker run -it --rm $(IMAGE_NAME):$(TAG)
docker run -it --rm cmungall/$(IMAGE_NAME):$(TAG)

# Test in a scratch directory
test:
cd scratch && docker run -v $PWD:/work -e ANTHROPIC_API_KEY=$$ANTHROPIC_API_KEY -it --rm odk-ai:latest bash
cd scratch && docker run -v $${PWD}:/work -e ANTHROPIC_API_KEY=$$ANTHROPIC_API_KEY -it --rm cmungall/$(IMAGE_NAME):$(TAG) bash

# e.g. test-repos/obophenotype/uberon
# git clone https://github.com/obophenotype/uberon
test-repos/%:
cd test-repos && git clone https://github.com/$*




cd test-repos && git clone https://github.com/$*