1
0
Fork 0
mirror of synced 2024-05-21 21:02:29 +12:00

minor docker process tweaks

This commit is contained in:
Nick Sweeting 2020-07-22 01:30:58 -04:00
parent 8cb530230c
commit 6b7dfa773e
6 changed files with 53 additions and 14 deletions

View file

@ -1,9 +1,9 @@
# This is the Dockerfile for ArchiveBox, it includes the following major pieces:
# git, curl, wget, python3, youtube-dl, google-chrome-stable, ArchiveBox
# Usage:
# docker build . -t archivebox:latest
# docker run -v=$PWD/data:/data archivebox:latest archivebox init
# echo 'https://example.com' | docker run -v=$PWD/data:/data -i archivebox:latest archivebox add
# docker build . -t archivebox
# docker run -v "$PWD/data":/data archivebox init
# docker run -v "$PWD/data":/data archivebox add 'https://example.com'
# Documentation:
# https://github.com/pirate/ArchiveBox/wiki/Docker#docker
@ -43,8 +43,7 @@ RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selectio
fonts-symbola \
fonts-noto \
fonts-freefont-ttf \
&& rm -rf /var/lib/apt/lists/* \
&& pip install --upgrade --no-cache-dir pip setuptools
&& rm -rf /var/lib/apt/lists/*
# Run everything from here on out as non-privileged user
RUN groupadd --system archivebox \
@ -54,6 +53,7 @@ ADD . "$CODE_PATH"
WORKDIR "$CODE_PATH"
ENV PATH="$VENV_PATH/bin:${PATH}"
RUN python -m venv --clear --symlinks "$VENV_PATH" \
&& pip install --upgrade pip setuptools \
&& pip install -e .
VOLUME "$DATA_PATH"
@ -62,5 +62,7 @@ EXPOSE 8000
ENV CHROME_BINARY=google-chrome \
CHROME_SANDBOX=False
ENTRYPOINT ["dumb-init", "--", "/app/bin/entrypoint.sh", "archivebox"]
RUN env ALLOW_ROOT=True archivebox version
ENTRYPOINT ["dumb-init", "--", "/app/bin/docker_entrypoint.sh", "archivebox"]
CMD ["server", "0.0.0.0:8000"]

View file

@ -1,22 +1,24 @@
#!/usr/bin/env bash
# detect userid:groupid of contents of data folder
COMMAND="$*"
# Autodetect UID,GID of host user based on ownership of files in the data volume
DATA_DIR="${DATA_DIR:-/data}"
ARCHIVEBOX_USER="${ARCHIVEBOX_USER:-archivebox}"
# Autodetect UID and GID of host user based on ownership of files in the volume
USID=$(stat --format="%u" "$DATA_DIR")
GRID=$(stat --format="%g" "$DATA_DIR")
COMMAND="$*"
# run django as the host user's uid:gid so that any files touched have the same permissions as outside the container
# e.g. ./manage.py runserver
chown "$USID":"$GRID" "$DATA_DIR"
# If user is not root, modify the archivebox user+files to have the same uid,gid
if [[ "$USID" != 0 && "$GRID" != 0 ]]; then
chown "$USID":"$GRID" "$DATA_DIR"
usermod -u "$USID" "$ARCHIVEBOX_USER"
groupmod -g "$GRID" "$ARCHIVEBOX_USER"
chown -R "$USID":"$GRID" "/home/$ARCHIVEBOX_USER"
fi
# run django as the new archivebox user
# any files touched will have the same uid,gid
# inside docker and outside docker on the host
gosu "$ARCHIVEBOX_USER" bash -c "$COMMAND"
# e.g. "archivebox server"

18
bin/lint.sh Executable file
View file

@ -0,0 +1,18 @@
#!/usr/bin/env bash
### Bash Environment Setup
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
# https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html
# set -o xtrace
set -o errexit
set -o errtrace
set -o nounset
set -o pipefail
IFS=$'\n'
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && cd .. && pwd )"
source "$DIR/.venv/bin/activate"
flake8 archivebox
mypy archivebox

17
bin/test.sh Executable file
View file

@ -0,0 +1,17 @@
#!/usr/bin/env bash
### Bash Environment Setup
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
# https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html
# set -o xtrace
set -o errexit
set -o errtrace
set -o nounset
set -o pipefail
IFS=$'\n'
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && cd .. && pwd )"
source "$DIR/.venv/bin/activate"
pytest