Merge pull request #367 from afreydev/docker-stuff
This commit is contained in:
commit
073f4e4d16
2 changed files with 21 additions and 5 deletions
|
@ -28,7 +28,7 @@ ENV TZ=UTC \
|
|||
RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections \
|
||||
&& apt-get update -qq \
|
||||
&& apt-get install -qq -y --no-install-recommends \
|
||||
apt-transport-https ca-certificates apt-utils gnupg gnupg2 libgconf-2-4 zlib1g-dev \
|
||||
apt-transport-https ca-certificates apt-utils gnupg gosu gnupg2 libgconf-2-4 zlib1g-dev \
|
||||
dumb-init jq git wget curl youtube-dl ffmpeg \
|
||||
&& curl -sSL "https://dl.google.com/linux/linux_signing_key.pub" | apt-key add - \
|
||||
&& echo "deb https://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list \
|
||||
|
@ -58,12 +58,9 @@ RUN python -m venv --clear --symlinks "$VENV_PATH" \
|
|||
|
||||
VOLUME "$DATA_PATH"
|
||||
WORKDIR "$DATA_PATH"
|
||||
USER archivebox:archivebox
|
||||
EXPOSE 8000
|
||||
ENV CHROME_BINARY=google-chrome \
|
||||
CHROME_SANDBOX=False
|
||||
|
||||
RUN archivebox version
|
||||
|
||||
ENTRYPOINT ["dumb-init", "--", "archivebox"]
|
||||
ENTRYPOINT ["dumb-init", "--", "/app/bin/entrypoint.sh", "archivebox"]
|
||||
CMD ["server", "0.0.0.0:8000"]
|
||||
|
|
19
bin/entrypoint.sh
Executable file
19
bin/entrypoint.sh
Executable file
|
@ -0,0 +1,19 @@
|
|||
#!/bin/bash
|
||||
|
||||
# detect userid:groupid of contents of data folder
|
||||
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"
|
||||
chown -R "$USID":"$GRID" "/home/$ARCHIVEBOX_USER"
|
||||
usermod -u $USID $ARCHIVEBOX_USER
|
||||
groupmod -g $GRID $ARCHIVEBOX_USER
|
||||
gosu $ARCHIVEBOX_USER bash -c "$COMMAND"
|
Loading…
Reference in a new issue