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
31 changes: 16 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,58 +1,59 @@
FROM python:3.12 AS build
ARG PYTHON_VERSION=3.12.13-slim

ENV CRANE_VER=v0.20.2
FROM python:${PYTHON_VERSION} AS build

# Install crane
RUN apt-get update && apt-get install -y --no-install-recommends curl git \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /craneinstall

# crane install docs: https://github.com/google/go-containerregistry/blob/main/cmd/crane/README.md
# Note that the provenance verification step is broken, which wasted an hour or two of time
# https://github.com/google/go-containerregistry/issues/1982
RUN curl -sL https://github.com/google/go-containerregistry/releases/download/$CRANE_VER/go-containerregistry_Linux_x86_64.tar.gz > go-containerregistry.tar.gz \
&& tar -zxvf go-containerregistry.tar.gz
ENV CRANE_VER=v0.21.2
RUN curl -sL https://github.com/google/go-containerregistry/releases/download/$CRANE_VER/go-containerregistry_Linux_x86_64.tar.gz > go-containerregistry_Linux_x86_64.tar.gz \
&& curl -sL https://github.com/google/go-containerregistry/releases/download/$CRANE_VER/checksums.txt > checksums.txt \
&& grep "go-containerregistry_Linux_x86_64.tar.gz" checksums.txt | sha256sum -c - \
&& tar -zxvf go-containerregistry_Linux_x86_64.tar.gz

# Write the git commit for the service

WORKDIR /git
COPY .git /git
RUN GITCOMMIT=$(git rev-parse HEAD) && echo "GIT_COMMIT=\"$GITCOMMIT\"" > /git/git_commit.py

FROM python:3.12

RUN apt update \
&& apt install -y tini \
&& rm -rf /var/lib/apt/lists/*
FROM python:${PYTHON_VERSION}

RUN apt-get update \
&& apt-get install -y --no-install-recommends tini curl \
&& rm -rf /var/lib/apt/lists/*

# install uv
RUN pip install --upgrade pip && \
pip install uv
pip install uv

# install deps
ARG UV_DEV_ARGUMENT=--no-dev
RUN mkdir /uvinstall
WORKDIR /uvinstall
COPY pyproject.toml uv.lock .python-version .
ENV UV_PROJECT_ENVIRONMENT=/usr/local/
ARG UV_DEV_ARGUMENT=--no-dev
RUN uv sync --locked --inexact $UV_DEV_ARGUMENT

# install the actual code
RUN mkdir /cts
COPY cdmtaskservice /cts/cdmtaskservice
COPY scripts/* /cts
COPY cdmtaskservice_*config.toml.jinja /cts

COPY --from=build /craneinstall/crane /cts
COPY --from=build /git/git_commit.py /cts/cdmtaskservice/
ENV KBCTS_CRANE_PATH=/cts/crane

WORKDIR /cts

# build the code archive

RUN tar -czf cts.tgz --exclude="*/__pycache__*" cdmtaskservice -C /uvinstall .
ENV KBCTS_CODE_ARCHIVE_PATH=/cts/cts.tgz
ENV KBCTS_HTC_EXE_PATH=/cts/cdmtaskservice/condor/run_job.sh

ENTRYPOINT ["tini", "--", "/cts/entrypoint.sh"]

6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ dependencies = [
"awscrt==0.31.1",
"bidict==0.23.1",
"cacheout==0.16.0",
"cryptography==46.0.5",
"docker==7.1.0",
"docker-image-py==0.1.13",
"fastapi[standard]==0.128.0",
Expand All @@ -24,8 +25,10 @@ dependencies = [
"marisa-trie==1.3.1",
"motor==3.7.1",
"python-json-logger==4.0.0",
"python-multipart==0.0.22",
"requests==2.32.5",
"sfapi-client==0.4.1",
"starlette==0.49.3",
"uvicorn[standard]==0.40.0",
"yarl==1.22.0",
]
Expand All @@ -41,3 +44,6 @@ dev = [
"pytest-asyncio==1.3.0",
"pytest-cov==7.0.0",
]

[tool.uv]
environments = ["sys_platform == 'linux'"]
Loading
Loading