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
|
ARG PYTHON=python:3.8
|
||||||
|
|
||||||
FROM $PYTHON
|
FROM $PYTHON
|
||||||
|
|
||||||
|
RUN groupadd -g 1001 archivist && useradd -m -u 1001 -g archivist -s /bin/bash archivist
|
||||||
|
|
||||||
WORKDIR /pywb
|
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
|
RUN pip install --no-cache-dir -r requirements.txt -r extra_requirements.txt
|
||||||
|
|
||||||
COPY . ./
|
COPY --chown=archivist:archivist . ./
|
||||||
|
|
||||||
RUN python setup.py install \
|
RUN python setup.py install \
|
||||||
&& mv ./docker-entrypoint.sh / \
|
&& mv ./docker-entrypoint.sh / \
|
||||||
&& mkdir /uwsgi && mv ./uwsgi.ini /uwsgi/ \
|
&& mkdir -p /uwsgi /webarchive \
|
||||||
&& mkdir /webarchive && mv ./config.yaml /webarchive/
|
&& mv ./uwsgi.ini /uwsgi/ \
|
||||||
|
&& mv ./config.yaml /webarchive/ \
|
||||||
|
&& chmod -R g+rwX /webarchive /pywb
|
||||||
|
|
||||||
WORKDIR /webarchive
|
WORKDIR /webarchive
|
||||||
|
|
||||||
# auto init collection
|
|
||||||
ENV INIT_COLLECTION ''
|
ENV INIT_COLLECTION ''
|
||||||
|
|
||||||
ENV VOLUME_DIR /webarchive
|
ENV VOLUME_DIR /webarchive
|
||||||
|
|
||||||
#USER archivist
|
COPY --chown=archivist:archivist docker-entrypoint.sh /docker-entrypoint.sh
|
||||||
COPY docker-entrypoint.sh ./
|
RUN chmod +x /docker-entrypoint.sh
|
||||||
|
|
||||||
|
USER archivist
|
||||||
|
|
||||||
# volume and port
|
|
||||||
VOLUME /webarchive
|
VOLUME /webarchive
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
|
|
||||||
ENTRYPOINT ["/docker-entrypoint.sh"]
|
ENTRYPOINT ["/docker-entrypoint.sh"]
|
||||||
CMD ["uwsgi", "/uwsgi/uwsgi.ini"]
|
CMD ["uwsgi", "/uwsgi/uwsgi.ini"]
|
||||||
|
|
||||||
|
@ -2,38 +2,8 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# Get UID/GID from volume dir
|
if [ -n "$INIT_COLLECTION" ] && [ ! -d "$VOLUME_DIR/collections/$INIT_COLLECTION" ]; then
|
||||||
VOLUME_UID=$(stat -c '%u' $VOLUME_DIR)
|
wb-manager init "$INIT_COLLECTION" || echo "Warning: Could not initialize collection."
|
||||||
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 $@
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
exec "$@"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user