mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-17 00:24:26 -04:00
minor docker process tweaks
This commit is contained in:
parent
8cb530230c
commit
6b7dfa773e
6 changed files with 53 additions and 14 deletions
14
Dockerfile
14
Dockerfile
|
@ -1,9 +1,9 @@
|
||||||
# This is the Dockerfile for ArchiveBox, it includes the following major pieces:
|
# This is the Dockerfile for ArchiveBox, it includes the following major pieces:
|
||||||
# git, curl, wget, python3, youtube-dl, google-chrome-stable, ArchiveBox
|
# git, curl, wget, python3, youtube-dl, google-chrome-stable, ArchiveBox
|
||||||
# Usage:
|
# Usage:
|
||||||
# docker build . -t archivebox:latest
|
# docker build . -t archivebox
|
||||||
# docker run -v=$PWD/data:/data archivebox:latest archivebox init
|
# docker run -v "$PWD/data":/data archivebox init
|
||||||
# echo 'https://example.com' | docker run -v=$PWD/data:/data -i archivebox:latest archivebox add
|
# docker run -v "$PWD/data":/data archivebox add 'https://example.com'
|
||||||
# Documentation:
|
# Documentation:
|
||||||
# https://github.com/pirate/ArchiveBox/wiki/Docker#docker
|
# 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-symbola \
|
||||||
fonts-noto \
|
fonts-noto \
|
||||||
fonts-freefont-ttf \
|
fonts-freefont-ttf \
|
||||||
&& rm -rf /var/lib/apt/lists/* \
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
&& pip install --upgrade --no-cache-dir pip setuptools
|
|
||||||
|
|
||||||
# Run everything from here on out as non-privileged user
|
# Run everything from here on out as non-privileged user
|
||||||
RUN groupadd --system archivebox \
|
RUN groupadd --system archivebox \
|
||||||
|
@ -54,6 +53,7 @@ ADD . "$CODE_PATH"
|
||||||
WORKDIR "$CODE_PATH"
|
WORKDIR "$CODE_PATH"
|
||||||
ENV PATH="$VENV_PATH/bin:${PATH}"
|
ENV PATH="$VENV_PATH/bin:${PATH}"
|
||||||
RUN python -m venv --clear --symlinks "$VENV_PATH" \
|
RUN python -m venv --clear --symlinks "$VENV_PATH" \
|
||||||
|
&& pip install --upgrade pip setuptools \
|
||||||
&& pip install -e .
|
&& pip install -e .
|
||||||
|
|
||||||
VOLUME "$DATA_PATH"
|
VOLUME "$DATA_PATH"
|
||||||
|
@ -62,5 +62,7 @@ EXPOSE 8000
|
||||||
ENV CHROME_BINARY=google-chrome \
|
ENV CHROME_BINARY=google-chrome \
|
||||||
CHROME_SANDBOX=False
|
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"]
|
CMD ["server", "0.0.0.0:8000"]
|
||||||
|
|
|
@ -1,22 +1,24 @@
|
||||||
#!/usr/bin/env bash
|
#!/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}"
|
DATA_DIR="${DATA_DIR:-/data}"
|
||||||
ARCHIVEBOX_USER="${ARCHIVEBOX_USER:-archivebox}"
|
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")
|
USID=$(stat --format="%u" "$DATA_DIR")
|
||||||
GRID=$(stat --format="%g" "$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
|
if [[ "$USID" != 0 && "$GRID" != 0 ]]; then
|
||||||
|
chown "$USID":"$GRID" "$DATA_DIR"
|
||||||
usermod -u "$USID" "$ARCHIVEBOX_USER"
|
usermod -u "$USID" "$ARCHIVEBOX_USER"
|
||||||
groupmod -g "$GRID" "$ARCHIVEBOX_USER"
|
groupmod -g "$GRID" "$ARCHIVEBOX_USER"
|
||||||
chown -R "$USID":"$GRID" "/home/$ARCHIVEBOX_USER"
|
chown -R "$USID":"$GRID" "/home/$ARCHIVEBOX_USER"
|
||||||
fi
|
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"
|
gosu "$ARCHIVEBOX_USER" bash -c "$COMMAND"
|
||||||
|
# e.g. "archivebox server"
|
18
bin/lint.sh
Executable file
18
bin/lint.sh
Executable 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
17
bin/test.sh
Executable 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
|
Loading…
Add table
Add a link
Reference in a new issue