mirror of
https://github.com/pirate/ArchiveBox.git
synced 2025-08-30 01:30:15 +02:00
minor docker process tweaks
This commit is contained in:
@@ -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
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
|
Reference in New Issue
Block a user