|
| 1 | +## EXPERIMENT BASE CONTAINER |
| 2 | +FROM nvidia/cuda:11.7.1-cudnn8-runtime-ubuntu20.04 AS cebra-base |
| 3 | + |
| 4 | +ENV DEBIAN_FRONTEND=noninteractive |
| 5 | +RUN apt-get update -y \ |
| 6 | + && apt-get install --no-install-recommends -yy git python3 python3-pip python-is-python3 \ |
| 7 | + && rm -rf /var/lib/apt/lists/* |
| 8 | + |
| 9 | +RUN pip install --no-cache-dir torch==2.0.0+cu117 \ |
| 10 | + --index-url https://download.pytorch.org/whl/cu117 |
| 11 | +RUN pip install --no-cache-dir --pre 'cebra[dev,datasets,integrations]' \ |
| 12 | + && pip uninstall -y cebra |
| 13 | + |
| 14 | + |
| 15 | +## GIT repository |
| 16 | +FROM ubuntu AS repo |
| 17 | + |
| 18 | +ENV DEBIAN_FRONTEND=noninteractive |
| 19 | +RUN apt-get update -y \ |
| 20 | + && apt-get install --no-install-recommends -yy git python3 python3-pip python-is-python3 \ |
| 21 | + && rm -rf /var/lib/apt/lists/* |
| 22 | + |
| 23 | +WORKDIR /repo |
| 24 | +COPY . /repo |
| 25 | +RUN git status --porcelain |
| 26 | + |
| 27 | +WORKDIR /target |
| 28 | +RUN git clone --filter=tree:0 --depth=1 file:///repo/.git /target |
| 29 | +RUN git log |
| 30 | + |
| 31 | +## CEBRA WHEEL |
| 32 | +FROM python:3.9 AS wheel |
| 33 | + |
| 34 | +RUN pip install --upgrade --no-cache-dir pip |
| 35 | +RUN pip install --upgrade --no-cache-dir build virtualenv |
| 36 | + |
| 37 | +WORKDIR /build |
| 38 | +COPY --from=repo /target . |
| 39 | +RUN make dist |
| 40 | + |
| 41 | +## CEBRA CONTAINER |
| 42 | +FROM cebra-base |
| 43 | + |
| 44 | +# install the cebra wheel |
| 45 | +ENV WHEEL=cebra-0.3.0rc2-py2.py3-none-any.whl |
| 46 | +WORKDIR /build |
| 47 | +COPY --from=wheel /build/dist/${WHEEL} . |
| 48 | +RUN pip install --no-cache-dir ${WHEEL}'[dev,integrations,datasets]' |
| 49 | +RUN rm -rf /build |
| 50 | + |
| 51 | +# add the repository |
| 52 | +WORKDIR /app |
| 53 | +COPY --from=repo /target . |
| 54 | + |
| 55 | +ENV PYTHONPATH=/app |
| 56 | + |
| 57 | +ARG UID |
| 58 | +ARG GID |
| 59 | +RUN groupadd -g $GID appgroup |
| 60 | +RUN useradd -u $UID -g $GID -ms "/bin/bash" appuser |
| 61 | +RUN chown -R appuser:appgroup /app |
| 62 | +USER appuser |
| 63 | + |
| 64 | +ARG GIT_HASH |
| 65 | +RUN if [ "$(git rev-parse HEAD)" != "${GIT_HASH}" ]; then \ |
| 66 | + git rev-parse HEAD; \ |
| 67 | + echo ${GIT_HASH}; \ |
| 68 | + exit 1; \ |
| 69 | + fi |
| 70 | +RUN git status --porcelain || exit 1 |
0 commit comments