From fc5e2dcb5bcbed4ae39574e8e1f9861289028037 Mon Sep 17 00:00:00 2001 From: JustAnotherArchivist Date: Fri, 5 Mar 2021 06:25:46 +0000 Subject: [PATCH] Cleanup --- backend/Dockerfile | 18 ++++++++++++------ backend/README.md | 7 +++++++ 2 files changed, 19 insertions(+), 6 deletions(-) create mode 100644 backend/README.md diff --git a/backend/Dockerfile b/backend/Dockerfile index ae54555..7edc6bb 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,5 +1,7 @@ FROM debian:buster-slim ENV LC_ALL=C + +# Software installation RUN echo 'deb http://deb.debian.org/debian buster-backports main' >/etc/apt/sources.list.d/backports.list \ && DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical apt-get -qqy --no-install-recommends -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confold -o Dpkg::Options::=--force-unsafe-io update \ && DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical apt-get -qqy --no-install-recommends -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confold -o Dpkg::Options::=--force-unsafe-io install apt-utils \ @@ -10,6 +12,8 @@ RUN echo 'deb http://deb.debian.org/debian buster-backports main' >/etc/apt/sour && DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical apt-get -qqy --no-install-recommends -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confold -o Dpkg::Options::=--force-unsafe-io install build-essential ruby ruby-dev bundler python3 python3-websockets redis-server couchdb=2.3.1-1~buster git libzmq5 libzmq3-dev \ && DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical apt-get -qqy --no-install-recommends -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confold -o Dpkg::Options::=--force-unsafe-io -t buster-backports install zstd \ && rm -rf /var/lib/apt/lists/* + +# Set up things under archivebot user and launch scripts RUN groupadd -r archivebot && useradd -r -m -g archivebot archivebot USER archivebot RUN git clone https://github.com/ArchiveTeam/ArchiveBot.git /home/archivebot/ArchiveBot \ @@ -20,22 +24,24 @@ RUN git clone https://github.com/ArchiveTeam/ArchiveBot.git /home/archivebot/Arc && GEM_HOME=/home/archivebot/.gems bundle install \ && cd /home/archivebot/ArchiveBot/plumbing \ && rm Gemfile.lock \ - && GEM_HOME=/home/archivebot/.gems bundle install -RUN mkdir -p /home/archivebot/redis/data/ + && GEM_HOME=/home/archivebot/.gems bundle install \ + && mkdir -p /home/archivebot/redis/data/ COPY --chown=root:root launch-root.sh /root/ COPY --chown=archivebot:archivebot launch-archivebot.sh /home/archivebot/ COPY --chown=archivebot:archivebot redis.conf /home/archivebot/redis/ +VOLUME /home/archivebot/redis/data/ + USER root -RUN \ - # Set up CouchDB - /etc/init.d/couchdb start \ - # Wait for it to start up properly... + +# Set up CouchDB +RUN /etc/init.d/couchdb start \ && ( set +e; for i in $(seq 10); do curl -sf http://127.0.0.1:5984/ && exit 0 || sleep 1; done; echo 'CouchDB still not operational after 10 seconds'; exit 1; ) \ && curl -sf -X PUT http://127.0.0.1:5984/_users \ && curl -sf -X PUT http://127.0.0.1:5984/_replicator \ && curl -sf -X PUT http://127.0.0.1:5984/archivebot \ && grep -v _rev /home/archivebot/ArchiveBot/db/design_docs/ignore_patterns.json | curl -sf -X PUT --data @- http://127.0.0.1:5984/archivebot/_design/ignore_patterns \ && grep -v _rev /home/archivebot/ArchiveBot/db/design_docs/user_agents.json | curl -sf -X PUT --data @- http://127.0.0.1:5984/archivebot/_design/user_agents + EXPOSE 4567 EXPOSE 4568 ENTRYPOINT ["/root/launch-root.sh"] diff --git a/backend/README.md b/backend/README.md new file mode 100644 index 0000000..e41741e --- /dev/null +++ b/backend/README.md @@ -0,0 +1,7 @@ +Build: + + docker build -t archivebot-backend . + +Run: + + docker run -d -p 80:4567 -p 4568:4568 -v abredis:/home/archivebot/redis/data/ archivebot-backend