-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #351 from oduwsdl/issue-70
A monolithic Dockerfile that actually works
- Loading branch information
Showing
3 changed files
with
99 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,49 @@ | ||
FROM python:2-onbuild | ||
# Use Python 2.7 as default, but facilitate change at build time | ||
ARG PYTHON_TAG=2.7 | ||
FROM python:${PYTHON_TAG} | ||
|
||
LABEL maintainer="Sawood Alam <@ibnesayeed>" | ||
# 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>" | ||
|
||
RUN pip install . | ||
EXPOSE 5000 | ||
# Create folders for WARC, CDXJ and IPFS stores | ||
RUN mkdir /warc /cdxj /ipfs | ||
|
||
CMD ["ipwb"] | ||
# Download and install IPFS | ||
ENV IPFS_PATH=/ipfs | ||
ARG IPFS_VERSION=v0.4.13 | ||
RUN cd /tmp \ | ||
&& wget https://dist.ipfs.io/go-ipfs/v0.4.13/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 | ||
|
||
# Add a custom entrypoint script | ||
COPY entrypoint.sh /usr/local/bin/ | ||
RUN chmod a+x /usr/local/bin/entrypoint.sh | ||
|
||
# Copy source files and install IPWB | ||
WORKDIR /ipwb | ||
COPY requirements.txt ./ | ||
RUN pip install -r requirements.txt | ||
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
if [[ ("$1" = "ipwb") && ("$1" != "$@") && ("$@" != *" -h"*) && ("$@" != *" --help"*) ]] | ||
then | ||
# Initialize IPFS if not initialized already | ||
if [ ! -f $IPFS_PATH/config ] | ||
then | ||
ipfs init | ||
fi | ||
# Run the IPFS daemon in background | ||
ipfs daemon & | ||
|
||
# Wait for IPFS daemon to be ready | ||
while ! curl -s localhost:5001 > /dev/null | ||
do | ||
sleep 1 | ||
done | ||
fi | ||
|
||
exec "$@" |