mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-15 00:03:28 +01:00
changes
This commit is contained in:
parent
7b0f8b5860
commit
139ce40a3e
24
Dockerfile
24
Dockerfile
@ -1,34 +1,34 @@
|
||||
ARG PYTHON=python:3.8
|
||||
|
||||
FROM $PYTHON
|
||||
|
||||
RUN groupadd -g 1001 archivist && useradd -m -u 1001 -g archivist -s /bin/bash archivist
|
||||
|
||||
WORKDIR /pywb
|
||||
|
||||
COPY requirements.txt extra_requirements.txt ./
|
||||
|
||||
COPY --chown=archivist:archivist requirements.txt extra_requirements.txt ./
|
||||
RUN pip install --no-cache-dir -r requirements.txt -r extra_requirements.txt
|
||||
|
||||
COPY . ./
|
||||
COPY --chown=archivist:archivist . ./
|
||||
|
||||
RUN python setup.py install \
|
||||
&& mv ./docker-entrypoint.sh / \
|
||||
&& mkdir /uwsgi && mv ./uwsgi.ini /uwsgi/ \
|
||||
&& mkdir /webarchive && mv ./config.yaml /webarchive/
|
||||
&& mkdir -p /uwsgi /webarchive \
|
||||
&& mv ./uwsgi.ini /uwsgi/ \
|
||||
&& mv ./config.yaml /webarchive/ \
|
||||
&& chmod -R g+rwX /webarchive /pywb
|
||||
|
||||
WORKDIR /webarchive
|
||||
|
||||
# auto init collection
|
||||
ENV INIT_COLLECTION ''
|
||||
|
||||
ENV VOLUME_DIR /webarchive
|
||||
|
||||
#USER archivist
|
||||
COPY docker-entrypoint.sh ./
|
||||
COPY --chown=archivist:archivist docker-entrypoint.sh /docker-entrypoint.sh
|
||||
RUN chmod +x /docker-entrypoint.sh
|
||||
|
||||
USER archivist
|
||||
|
||||
# volume and port
|
||||
VOLUME /webarchive
|
||||
EXPOSE 8080
|
||||
|
||||
ENTRYPOINT ["/docker-entrypoint.sh"]
|
||||
CMD ["uwsgi", "/uwsgi/uwsgi.ini"]
|
||||
|
||||
|
@ -2,38 +2,8 @@
|
||||
|
||||
set -e
|
||||
|
||||
# Get UID/GID from volume dir
|
||||
VOLUME_UID=$(stat -c '%u' $VOLUME_DIR)
|
||||
VOLUME_GID=$(stat -c '%g' $VOLUME_DIR)
|
||||
|
||||
MY_UID=$(id -u)
|
||||
MY_GID=$(id -g)
|
||||
|
||||
# Run as custom user
|
||||
if [ "$MY_GID" != "$VOLUME_GID" ] || [ "$MY_UID" != "$VOLUME_UID" ]; then
|
||||
# create or modify user and group to match expected uid/gid
|
||||
groupadd --gid $VOLUME_GID archivist || groupmod -o --gid $VOLUME_GID archivist
|
||||
useradd -ms /bin/bash -u $VOLUME_UID -g $VOLUME_GID archivist || usermod -o -u $VOLUME_UID archivist
|
||||
|
||||
# initialize a collection if defined and not present
|
||||
if [ -n "$INIT_COLLECTION" ] && [ ! -d $VOLUME_DIR/collections/$INIT_COLLECTION ]; then
|
||||
su archivist -c "wb-manager init $INIT_COLLECTION"
|
||||
fi
|
||||
|
||||
cmd="cd $PWD; $@"
|
||||
|
||||
# run process as new archivist user
|
||||
su archivist -c "$cmd"
|
||||
|
||||
# run as current user (root)
|
||||
else
|
||||
# initialize a collection if defined and not present
|
||||
if [ -n "$INIT_COLLECTION" ] && [ ! -d $VOLUME_DIR/collections/$INIT_COLLECTION ]; then
|
||||
cd $VOLUME_DIR
|
||||
wb-manager init $INIT_COLLECTION
|
||||
fi
|
||||
|
||||
# run process directly
|
||||
exec $@
|
||||
if [ -n "$INIT_COLLECTION" ] && [ ! -d "$VOLUME_DIR/collections/$INIT_COLLECTION" ]; then
|
||||
wb-manager init "$INIT_COLLECTION" || echo "Warning: Could not initialize collection."
|
||||
fi
|
||||
|
||||
exec "$@"
|
||||
|
Loading…
x
Reference in New Issue
Block a user