2019-07-27 20:34:58 +02:00
|
|
|
FROM busybox as approot
|
2018-07-12 05:30:13 +02:00
|
|
|
|
2019-07-27 20:34:58 +02:00
|
|
|
COPY . /opt/app/
|
|
|
|
RUN \
|
|
|
|
# Remove unit tests from production release
|
|
|
|
rm -rf /opt/app/szurubooru/tests && \
|
|
|
|
# Remove requirements files, will be added later
|
|
|
|
rm -f /opt/app/requirements.txt && \
|
|
|
|
rm -f /opt/app/dev-requirements.txt
|
2018-07-12 05:30:13 +02:00
|
|
|
|
|
|
|
|
|
|
|
FROM python:3.6-slim
|
|
|
|
WORKDIR /opt/app
|
|
|
|
|
|
|
|
ARG PUID=1000
|
|
|
|
ARG PGID=1000
|
|
|
|
ARG PORT=6666
|
|
|
|
RUN \
|
|
|
|
# Set users
|
|
|
|
mkdir -p /opt/app /data && \
|
|
|
|
groupadd -g ${PGID} app && \
|
|
|
|
useradd -d /opt/app -M -c '' -g app -r -u ${PUID} app && \
|
|
|
|
chown -R app:app /opt/app /data && \
|
|
|
|
# Create init file
|
|
|
|
echo "#!/bin/sh" >> /init && \
|
|
|
|
echo "set -e" >> /init && \
|
|
|
|
echo "cd /opt/app" >> /init && \
|
|
|
|
echo "alembic upgrade head" >> /init && \
|
|
|
|
echo "exec waitress-serve --port ${PORT} szurubooru.facade:app" \
|
|
|
|
>> /init && \
|
|
|
|
chmod a+x /init && \
|
|
|
|
# Install ffmpeg
|
|
|
|
apt-get -yqq update && \
|
|
|
|
apt-get -yq install --no-install-recommends ffmpeg && \
|
|
|
|
rm -rf /var/lib/apt/lists/* && \
|
|
|
|
# Install waitress
|
|
|
|
pip3 install --no-cache-dir waitress
|
|
|
|
|
|
|
|
COPY --chown=app:app requirements.txt ./requirements.txt
|
|
|
|
RUN pip3 install --no-cache-dir -r ./requirements.txt
|
|
|
|
|
|
|
|
# done to minimize number of layers in final image
|
2019-07-27 20:34:58 +02:00
|
|
|
COPY --chown=app:app --from=approot /opt/app /opt/app/
|
2018-07-12 05:30:13 +02:00
|
|
|
|
|
|
|
VOLUME ["/data/"]
|
|
|
|
EXPOSE ${PORT}
|
|
|
|
USER app
|
|
|
|
CMD ["/init"]
|