Skip to content

Commit 754bc7a

Browse files
authored
Merge pull request #21 from openzim/documentation
2 parents 1ba2808 + 1f5e68c commit 754bc7a

File tree

7 files changed

+282
-156
lines changed

7 files changed

+282
-156
lines changed

Dockerfile

Lines changed: 37 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,37 @@
1-
FROM ubuntu:bionic
2-
3-
# Update system
4-
RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
5-
6-
# Configure locales
7-
RUN apt-get update -y && \
8-
apt-get install -y --no-install-recommends locales && \
9-
apt-get clean -y && \
10-
rm -rf /var/lib/apt/lists/*
11-
ENV LANG en_US.UTF-8
12-
ENV LANGUAGE en_US:en
13-
ENV LC_ALL en_US.UTF-8
14-
RUN locale-gen en_US.UTF-8
15-
16-
# Install necessary packages
17-
RUN apt-get update -y && \
18-
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 && \
19-
apt-get clean -y && \
20-
rm -rf /var/lib/apt/lists/*
21-
22-
# Update CA certificates
23-
RUN update-ca-certificates
24-
25-
# Install Xapian (wget zlib1g-dev)
26-
RUN wget https://oligarchy.co.uk/xapian/1.4.14/xapian-core-1.4.14.tar.xz
27-
RUN tar xvf xapian-core-1.4.14.tar.xz
28-
RUN cd xapian-core-1.4.14 && ./configure
29-
RUN cd xapian-core-1.4.14 && make all install
30-
RUN rm -rf xapian
31-
32-
# Install zimlib (libicu-dev)
33-
RUN git clone https://github.com/openzim/libzim.git
34-
RUN cd libzim && git checkout 6.0.2
35-
RUN cd libzim && meson . build
36-
RUN cd libzim && ninja -C build install
37-
RUN rm -rf libzim
38-
39-
RUN ldconfig
40-
ENV LD_LIBRARY_PATH /usr/local/lib/x86_64-linux-gnu/
41-
42-
# Install python dependecies
43-
44-
RUN apt-get update -y && \
45-
apt-get install -y --no-install-recommends python-dev python3-dev python3-pip && \
46-
apt-get clean -y && \
47-
rm -rf /var/lib/apt/lists/*
48-
49-
# Install Cython
50-
51-
RUN pip3 install Cython
1+
# A minimal runtime environment for python-libzim using pre-built releases.
2+
# Usage:
3+
# docker build . --tag openzim:python-libzim
4+
# docker run -it openzim:python-libzim
5+
# >>> from libzim import ZimCreator, ZimArticle, ZimBlob
6+
# docker run -it openzim:python-libzim ./some_example_script.py
7+
8+
FROM python:3.7-buster
9+
10+
ENV LIBZIM_VERSION 6.1.1
11+
ENV LIBZIM_RELEASE libzim_linux-x86_64-$LIBZIM_VERSION
12+
ENV LIBZIM_LIBRARY_PATH lib/x86_64-linux-gnu/libzim.so.$LIBZIM_VERSION
13+
ENV LIBZIM_INCLUDE_PATH include/zim
14+
15+
# Install libzim from pre-built release
16+
RUN wget -qO- https://download.openzim.org/release/libzim/$LIBZIM_RELEASE.tar.gz \
17+
| tar -xz -C . \
18+
&& mv $LIBZIM_RELEASE/$LIBZIM_LIBRARY_PATH /usr/lib/libzim.so \
19+
&& mv $LIBZIM_RELEASE/$LIBZIM_INCLUDE_PATH /usr/include/zim \
20+
&& ldconfig
21+
# installing these system-wide inside of docker allows
22+
# users to run their dockerized code without needing to muck
23+
# around with LDFLAGS and CPPFLAGS to find libzim.
24+
# there will be only one copy of libzim, and it will be
25+
# automatically available to all software system-wide
26+
27+
# Install python dependencies
28+
RUN pip3 install --no-cache-dir --upgrade \
29+
pip cython==0.29.6 setuptools wheel pytest
30+
31+
# Install python-libzim from local source
32+
ADD . /opt/python-libzim
33+
WORKDIR /opt/python-libzim
34+
RUN pip install -e .
35+
VOLUME /opt/python-libzim
36+
37+
ENTRYPOINT ["/usr/bin/env", "python3"]

Dockerfile.dev

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# A full development environment with everything built from source.
2+
# Usage:
3+
# docker build . -f Dockerfile.dev --tag openzim:python-libzim-dev
4+
# docker run -it openzim:python-libzim-dev
5+
# $ black . && flake8 . && pytest .
6+
# $ pipenv install --dev <newpackagehere>
7+
# $ python setup.py build_ext
8+
# $ python setup.py sdist bdist_wheel
9+
# $ python setup.py install
10+
# $ python -c "from libzim import ZimArticle"
11+
12+
FROM python:3.7-buster
13+
14+
ENV LIBZIM_VERSION 6.1.1
15+
ENV LIBZIM_REPOSITORY https://github.com/openzim/libzim.git
16+
17+
ENV XAPIAN_VERSION 1.4.14
18+
ENV XAPIAN_RELEASE xapian-core-1.4.14
19+
ENV XAPIAN_URL https://oligarchy.co.uk/xapian/$XAPIAN_VERSION/$XAPIAN_RELEASE.tar.xz
20+
21+
WORKDIR /opt/
22+
23+
# Install C++ build environment
24+
RUN apt-get -qq update && \
25+
apt-get -qq install -y --no-install-recommends \
26+
coreutils wget git ca-certificates \
27+
g++ pkg-config libtool automake autoconf make meson ninja-build \
28+
liblzma-dev zlib1g-dev libicu-dev libgumbo-dev libmagic-dev && \
29+
apt-get clean -y && \
30+
rm -rf /var/lib/apt/lists/*
31+
32+
# Build & install Xapian from source: /opt/xapian
33+
RUN wget $XAPIAN_URL && \
34+
tar xvf $XAPIAN_RELEASE.tar.xz && \
35+
cd $XAPIAN_RELEASE && \
36+
./configure && \
37+
make all install && \
38+
ldconfig
39+
40+
# Build & install libzim from source: /opt/libzim
41+
RUN git clone $LIBZIM_REPOSITORY --depth 1 --branch $LIBZIM_VERSION && \
42+
cd libzim && \
43+
meson . build && \
44+
ninja -C build install && \
45+
ldconfig
46+
47+
# Install python dependecies
48+
RUN pip3 install --no-cache-dir --upgrade \
49+
pip pipenv cython==0.29.6 wheel pytest tox ipython black flake8 mypy
50+
51+
# Add local source code dir to docker container
52+
ADD . /opt/python-libzim
53+
VOLUME /opt/python-libzim
54+
WORKDIR /opt/python-libzim
55+
56+
# Build & install python-libzim from source: /opt/python-libzim
57+
RUN python3 setup.py build_ext && \
58+
pip install -e .
59+
60+
CMD ["/bin/bash"]

Pipfile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,14 @@ url = "https://pypi.org/simple"
44
verify_ssl = true
55

66
[dev-packages]
7-
pytest = "*"
87
cython = "==0.29.6"
9-
e1839a8 = {editable = true, path = "."}
8+
setuptools = "*"
9+
wheel = "*"
10+
ipython = "*"
11+
black = "*"
12+
flake8 = "*"
13+
mypy = "*"
14+
pytest = "*"
15+
twine = "*"
1016

1117
[packages]

0 commit comments

Comments
 (0)