Skip to content
Merged
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
88 changes: 37 additions & 51 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,51 +1,37 @@
FROM ubuntu:bionic

# Update system
RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections

# Configure locales
RUN apt-get update -y && \
apt-get install -y --no-install-recommends locales && \
apt-get clean -y && \
rm -rf /var/lib/apt/lists/*
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
RUN locale-gen en_US.UTF-8

# Install necessary packages
RUN apt-get update -y && \
apt-get install -y --no-install-recommends git pkg-config libtool automake autoconf make g++ liblzma-dev coreutils meson ninja-build wget zlib1g-dev libicu-dev libgumbo-dev libmagic-dev ca-certificates && \
apt-get clean -y && \
rm -rf /var/lib/apt/lists/*

# Update CA certificates
RUN update-ca-certificates

# Install Xapian (wget zlib1g-dev)
RUN wget https://oligarchy.co.uk/xapian/1.4.14/xapian-core-1.4.14.tar.xz
RUN tar xvf xapian-core-1.4.14.tar.xz
RUN cd xapian-core-1.4.14 && ./configure
RUN cd xapian-core-1.4.14 && make all install
RUN rm -rf xapian

# Install zimlib (libicu-dev)
RUN git clone https://github.com/openzim/libzim.git
RUN cd libzim && git checkout 6.0.2
RUN cd libzim && meson . build
RUN cd libzim && ninja -C build install
RUN rm -rf libzim

RUN ldconfig
ENV LD_LIBRARY_PATH /usr/local/lib/x86_64-linux-gnu/

# Install python dependecies

RUN apt-get update -y && \
apt-get install -y --no-install-recommends python-dev python3-dev python3-pip && \
apt-get clean -y && \
rm -rf /var/lib/apt/lists/*

# Install Cython

RUN pip3 install Cython
# A minimal runtime environment for python-libzim using pre-built releases.
# Usage:
# docker build . --tag openzim:python-libzim
# docker run -it openzim:python-libzim
# >>> from libzim import ZimCreator, ZimArticle, ZimBlob
# docker run -it openzim:python-libzim ./some_example_script.py

FROM python:3.7-buster

ENV LIBZIM_VERSION 6.1.1
ENV LIBZIM_RELEASE libzim_linux-x86_64-$LIBZIM_VERSION
ENV LIBZIM_LIBRARY_PATH lib/x86_64-linux-gnu/libzim.so.$LIBZIM_VERSION
ENV LIBZIM_INCLUDE_PATH include/zim

# Install libzim from pre-built release
RUN wget -qO- https://download.openzim.org/release/libzim/$LIBZIM_RELEASE.tar.gz \
| tar -xz -C . \
&& mv $LIBZIM_RELEASE/$LIBZIM_LIBRARY_PATH /usr/lib/libzim.so \
&& mv $LIBZIM_RELEASE/$LIBZIM_INCLUDE_PATH /usr/include/zim \
&& ldconfig
# installing these system-wide inside of docker allows
# users to run their dockerized code without needing to muck
# around with LDFLAGS and CPPFLAGS to find libzim.
# there will be only one copy of libzim, and it will be
# automatically available to all software system-wide

# Install python dependencies
RUN pip3 install --no-cache-dir --upgrade \
pip cython==0.29.6 setuptools wheel pytest

# Install python-libzim from local source
ADD . /opt/python-libzim
WORKDIR /opt/python-libzim
RUN pip install -e .
VOLUME /opt/python-libzim

ENTRYPOINT ["/usr/bin/env", "python3"]
60 changes: 60 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# A full development environment with everything built from source.
# Usage:
# docker build . -f Dockerfile.dev --tag openzim:python-libzim-dev
# docker run -it openzim:python-libzim-dev
# $ black . && flake8 . && pytest .
# $ pipenv install --dev <newpackagehere>
# $ python setup.py build_ext
# $ python setup.py sdist bdist_wheel
# $ python setup.py install
# $ python -c "from libzim import ZimArticle"

FROM python:3.7-buster

ENV LIBZIM_VERSION 6.1.1
ENV LIBZIM_REPOSITORY https://github.com/openzim/libzim.git

ENV XAPIAN_VERSION 1.4.14
ENV XAPIAN_RELEASE xapian-core-1.4.14
ENV XAPIAN_URL https://oligarchy.co.uk/xapian/$XAPIAN_VERSION/$XAPIAN_RELEASE.tar.xz

WORKDIR /opt/

# Install C++ build environment
RUN apt-get -qq update && \
apt-get -qq install -y --no-install-recommends \
coreutils wget git ca-certificates \
g++ pkg-config libtool automake autoconf make meson ninja-build \
liblzma-dev zlib1g-dev libicu-dev libgumbo-dev libmagic-dev && \
apt-get clean -y && \
rm -rf /var/lib/apt/lists/*

# Build & install Xapian from source: /opt/xapian
RUN wget $XAPIAN_URL && \
tar xvf $XAPIAN_RELEASE.tar.xz && \
cd $XAPIAN_RELEASE && \
./configure && \
make all install && \
ldconfig

# Build & install libzim from source: /opt/libzim
RUN git clone $LIBZIM_REPOSITORY --depth 1 --branch $LIBZIM_VERSION && \
cd libzim && \
meson . build && \
ninja -C build install && \
ldconfig

# Install python dependecies
RUN pip3 install --no-cache-dir --upgrade \
pip pipenv cython==0.29.6 wheel pytest tox ipython black flake8 mypy

# Add local source code dir to docker container
ADD . /opt/python-libzim
VOLUME /opt/python-libzim
WORKDIR /opt/python-libzim

# Build & install python-libzim from source: /opt/python-libzim
RUN python3 setup.py build_ext && \
pip install -e .

CMD ["/bin/bash"]
10 changes: 8 additions & 2 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@ url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]
pytest = "*"
cython = "==0.29.6"
e1839a8 = {editable = true, path = "."}
setuptools = "*"
wheel = "*"
ipython = "*"
black = "*"
flake8 = "*"
mypy = "*"
pytest = "*"
twine = "*"

[packages]
Loading