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
21 changes: 13 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ ENV LC_ALL=C.UTF-8
ENV LANG=C.UTF-8
ENV PIP=pip

ENV MAMBA_EXE=/usr/local/bin/conda
ENV MAMBA_ROOT_PREFIX=/conda
ENV PATH=$MAMBA_ROOT_PREFIX/bin:$PATH
ENV CONDA_EXE=$MAMBA_EXE
ENV CONDA_PREFIX=$MAMBA_ROOT_PREFIX
ENV CONDA_SHLVL='1'

WORKDIR /build-ocrd

COPY src ./src
Expand All @@ -21,27 +28,25 @@ COPY LICENSE .
COPY .git ./.git

RUN echo 'APT::Install-Recommends "0"; APT::Install-Suggests "0";' >/etc/apt/apt.conf.d/ocr-d.conf
RUN apt-get update && apt-get -y install software-properties-common \
&& apt-get update && apt-get -y install \
RUN apt-get update && apt-get -y install \
ca-certificates \
python3-dev \
python3-venv \
gcc \
make \
wget \
time \
curl \
sudo \
git \
&& make deps-ubuntu
RUN python3 -m venv /usr/local \
&& make get-conda \
&& make deps-conda \
&& python3 -m venv /usr/local \
&& hash -r \
&& make install \
&& eval $FIXUP

WORKDIR /data

CMD ["/usr/local/bin/ocrd", "--help"]
CMD ["/conda/bin/ocrd", "--help"]

FROM ocrd_core_base as ocrd_core_test
WORKDIR /build-ocrd
Expand All @@ -54,4 +59,4 @@ RUN pip install -r requirements_test.txt
RUN mkdir /ocrd-data && chmod 777 /ocrd-data

CMD ["yes"]
# CMD ["make", "test", "integration-test"]
# CMD ["make", "test", "integration-test"]
9 changes: 1 addition & 8 deletions Dockerfile.cuda
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
ARG BASE_IMAGE
FROM $BASE_IMAGE AS ocrd_core_base

ENV MAMBA_EXE=/usr/local/bin/conda
ENV MAMBA_ROOT_PREFIX=/conda
ENV PATH=$MAMBA_ROOT_PREFIX/bin:$PATH
ENV CONDA_EXE=$MAMBA_EXE
ENV CONDA_PREFIX=$MAMBA_ROOT_PREFIX
ENV CONDA_SHLVL='1'

WORKDIR /build

COPY Makefile .
Expand All @@ -18,5 +11,5 @@ WORKDIR /data

RUN rm -fr /build

CMD ["/usr/local/bin/ocrd", "--help"]
CMD ["/conda/bin/ocrd", "--help"]

37 changes: 30 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ help:
@echo ""
@echo " Targets"
@echo ""
@echo " get-conda Install Conda distribution"
@echo " deps-conda Dependencies for deployment via Conda"
@echo " deps-cuda Dependencies for deployment with GPU support via Conda"
@echo " deps-ubuntu Dependencies for deployment in an Ubuntu/Debian Linux"
@echo " deps-test Install test python deps via pip"
Expand Down Expand Up @@ -59,18 +61,34 @@ PIP_INSTALL_CONFIG_OPTION ?=

.PHONY: deps-cuda deps-ubuntu deps-test

deps-cuda: CONDA_EXE ?= /usr/local/bin/conda
deps-cuda: export CONDA_PREFIX ?= /conda
deps-cuda: PYTHON_PREFIX != $(PYTHON) -c 'import sysconfig; print(sysconfig.get_paths()["purelib"])'
deps-cuda:
curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/latest | tar -xvj bin/micromamba
.PHONY: get-conda deps-cuda deps-conda deps-ubuntu

ifeq ($(shell command -v conda),)
# no prior Conda distribution, so install Mamba now
# (see https://mamba.readthedocs.io/en/latest/installation.html)
get-conda: CONDA_EXE ?= /usr/local/bin/conda
get-conda: export CONDA_PREFIX ?= /conda
# first part of recipe: see micro.mamba.pm/install.sh
get-conda: OS != uname
get-conda: PLATFORM = $(subst Darwin,osx,$(subst Linux,linux,$(OS)))
get-conda: ARCH != uname -m
get-conda: MACHINE = $(or $(filter aarch64 arm64 ppc64le, $(ARCH)), 64)
get-conda: URL = https://micro.mamba.pm/api/micromamba/$(PLATFORM)-$(MACHINE)/latest
get-conda:
curl -Ls $(URL) | tar -xvj bin/micromamba
mv bin/micromamba $(CONDA_EXE)
# Install Conda system-wide (for interactive / login shells)
echo 'export MAMBA_EXE=$(CONDA_EXE) MAMBA_ROOT_PREFIX=$(CONDA_PREFIX) CONDA_PREFIX=$(CONDA_PREFIX) PATH=$(CONDA_PREFIX)/bin:$$PATH' >> /etc/profile.d/98-conda.sh
# workaround for tf-keras#62
echo 'export XLA_FLAGS=--xla_gpu_cuda_data_dir=$(CONDA_PREFIX)/' >> /etc/profile.d/98-conda.sh
mkdir -p $(CONDA_PREFIX)/lib $(CONDA_PREFIX)/include
echo $(CONDA_PREFIX)/lib >> /etc/ld.so.conf.d/conda.conf
else
get-conda: ;
endif

deps-cuda: PYTHON_PREFIX != $(PYTHON) -c 'import sysconfig; print(sysconfig.get_paths()["purelib"])'
deps-cuda: get-conda
# Get CUDA toolkit, including compiler and libraries with dev,
# however, the Nvidia channels do not provide (recent) cudnn (needed for Torch, TF etc):
#MAMBA_ROOT_PREFIX=$(CONDA_PREFIX) \
Expand All @@ -79,7 +97,6 @@ deps-cuda:
# The conda-forge channel has cudnn and cudatoolkit but no cudatoolkit-dev anymore (and we need both!),
# so let's combine nvidia and conda-forge (will be same lib versions, no waste of space),
# but omitting cuda-cudart-dev and cuda-libraries-dev (as these will be pulled by pip for torch anyway):
MAMBA_ROOT_PREFIX=$(CONDA_PREFIX) \
conda install -c nvidia/label/cuda-11.8.0 \
cuda-nvcc \
cuda-cccl \
Expand Down Expand Up @@ -115,10 +132,16 @@ deps-cuda:
&& ldconfig
# gputil/nvidia-smi would be nice, too – but that drags in Python as a conda dependency...

# Dependencies for deployment in an ubuntu/debian linux
# Dependencies for deployment via Conda
deps-conda: get-conda
conda install -c conda-forge python==3.8.* imagemagick geos pkgconfig

# Dependencies for deployment in an Ubuntu/Debian Linux
deps-ubuntu:
apt-get install -y python3 imagemagick libgeos-dev

.PHONY: deps-test install install-dev uninstall

# Install test python deps via pip
deps-test:
$(PIP) install -U pip
Expand Down