forked from oduwsdl/ipwb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
72 lines (56 loc) · 2.22 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# Use Python 2.7 as default, but facilitate change at build time
ARG PYTHON_TAG=2.7
FROM python:${PYTHON_TAG} AS base
# Add some metadata
LABEL app.name="InterPlanetary Wayback (IPWB)" \
app.description="A distributed and persistent archive replay system using IPFS" \
app.license="MIT License" \
app.license.url="https://github.com/oduwsdl/ipwb/blob/master/LICENSE" \
app.repo.url="https://github.com/oduwsdl/ipwb" \
app.authors="Mat Kelly <@machawk1> and Sawood Alam <@ibnesayeed>"
# Add a custom entrypoint script
COPY entrypoint.sh /usr/local/bin/
RUN chmod a+x /usr/local/bin/entrypoint.sh
# Enable unbuffered STDOUT logging
ENV PYTHONUNBUFFERED=1
# Create folders for WARC, CDXJ and IPFS stores
RUN mkdir -p /data/{warc,cdxj,ipfs}
# Download and install IPFS
ENV IPFS_PATH=/data/ipfs
ARG IPFS_VERSION=v0.4.17
RUN cd /tmp \
&& wget -q https://dist.ipfs.io/go-ipfs/${IPFS_VERSION}/go-ipfs_${IPFS_VERSION}_linux-amd64.tar.gz \
&& tar xvfz go-ipfs*.tar.gz \
&& mv go-ipfs/ipfs /usr/local/bin/ipfs \
&& rm -rf go-ipfs* \
&& ipfs init
# Make necessary changes to prepare the environment for IPWB
RUN apt update && apt install -y locales \
&& rm -rf /var/lib/apt/lists/* \
&& echo "en_US.UTF-8 UTF-8" > /etc/locale.gen \
&& locale-gen
# Install basic requirements
WORKDIR /ipwb
COPY requirements.txt ./
RUN pip install -r requirements.txt
# Testing stage
FROM base AS test
# Install necessary test requirements
COPY test-requirements.txt ./
RUN pip install -r test-requirements.txt
# Perform tests
COPY . ./
ARG SKIPTEST=false
RUN $SKIPTEST || pycodestyle
RUN $SKIPTEST || (ipfs daemon & while ! curl -s localhost:5001 > /dev/null; do sleep 1; done && py.test --cov=./)
# Final production image
FROM base
# Install IPWB from the source code
COPY . ./
RUN python setup.py install
# Run ipfs daemon in background
# Wait for the daemon to be ready
# Runs provided command
ENTRYPOINT ["entrypoint.sh"]
# Index a sample WARC file and replay it
CMD ["ipwb", "replay"]