1
0
mirror of https://github.com/krateng/maloja.git synced 2023-08-10 21:12:55 +03:00

Refactor containerfile to align with lsio python install

* Simplify project file copy
* Reduce system and project dependency installs into single layer
* Add default permission ENVs for backwards-compatibility
This commit is contained in:
FoxxMD 2023-03-17 11:44:16 -04:00
parent 7bc2ba0237
commit a9c29f158e

View File

@ -1,40 +1,59 @@
FROM lsiobase/alpine:3.17 as base FROM lsiobase/alpine:3.17 as base
# Python image includes two Python versions, so use base Alpine
# Based on the work of Jonathan Boeckel <jonathanboeckel1996@gmail.com>
WORKDIR /usr/src/app WORKDIR /usr/src/app
# Install run dependencies first
RUN apk add --no-cache python3 py3-lxml tzdata
# system pip could be removed after build, but apk then decides to also remove all its
# python dependencies, even if they are explicitly installed as python packages
# whut
RUN \
apk add py3-pip && \
pip install wheel
COPY ./requirements.txt ./requirements.txt
RUN \
apk add --no-cache --virtual .build-deps gcc g++ python3-dev libxml2-dev libxslt-dev libffi-dev libc-dev py3-pip linux-headers && \
pip install --no-cache-dir -r requirements.txt && \
apk del .build-deps
COPY container/root/ /
# no chance for caching below here
COPY --chown=abc:abc . . COPY --chown=abc:abc . .
RUN pip install /usr/src/app # based on https://github.com/linuxserver/docker-pyload-ng/blob/main/Dockerfile
# Everything is run in one command so we can purge all build dependencies and cache in the same layer after maloja is installed
#
# -- it may be possible to decrease image size slightly by using build stage and copying all site-packages to runtime stage
# but the image is already pretty small (117mb uncompressed, ~40mb compressed)
RUN \
echo "**** install build packages ****" && \
apk add --no-cache --virtual=build-deps \
gcc \
g++ \
python3-dev \
libxml2-dev \
libxslt-dev \
libffi-dev \
libc-dev \
py3-pip \
linux-headers && \
echo "**** install runtime packages ****" && \
apk add --no-cache \
python3 \
py3-lxml \
tzdata && \
echo "**** install pip dependencies ****" && \
python3 -m ensurepip && \
pip3 install -U --no-cache-dir \
pip \
wheel && \
echo "**** install maloja requirements ****" && \
pip3 install --no-cache-dir -r requirements.txt && \
echo "**** install maloja ****" && \
pip3 install /usr/src/app && \
echo "**** cleanup ****" && \
apk del --purge \
build-deps && \
rm -rf \
/tmp/* \
${HOME}/.cache
COPY container/root/ /
# Docker-specific configuration # Docker-specific configuration
# defaulting to IPv4 is no longer necessary (default host is dual stack) # defaulting to IPv4 is no longer necessary (default host is dual stack)
ENV MALOJA_SKIP_SETUP=yes ENV MALOJA_SKIP_SETUP=yes
ENV PYTHONUNBUFFERED=1 ENV PYTHONUNBUFFERED=1
# Prevents breaking change for previous container that ran maloja as root
# which meant MALOJA_DATA_DIRECTORY was created by and owned by root (UID 0)
#
# On linux hosts (non-podman rootless) these variables should be set to the host user that should own the host folder bound to MALOJA_DATA_DIRECTORY
ENV PUID=0
ENV PGID=0
EXPOSE 42010 EXPOSE 42010