mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-16 16:14:28 -04:00
minor docker process tweaks
This commit is contained in:
parent
8cb530230c
commit
6b7dfa773e
6 changed files with 53 additions and 14 deletions
24
bin/docker_entrypoint.sh
Executable file
24
bin/docker_entrypoint.sh
Executable file
|
@ -0,0 +1,24 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
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}"
|
||||
|
||||
USID=$(stat --format="%u" "$DATA_DIR")
|
||||
GRID=$(stat --format="%g" "$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"
|
Loading…
Add table
Add a link
Reference in a new issue