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

Reorganized containerfile to allow caching

This commit is contained in:
krateng 2023-03-31 02:44:53 +02:00
parent 9d9f3b500e
commit b8944b4954

View File

@ -2,13 +2,15 @@ FROM lsiobase/alpine:3.17 as base
WORKDIR /usr/src/app WORKDIR /usr/src/app
COPY --chown=abc:abc . .
COPY --chown=abc:abc ./requirements.txt ./requirements.txt
# based on https://github.com/linuxserver/docker-pyload-ng/blob/main/Dockerfile # 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 # everything but the app installation is run in one command so we can purge
# # all build dependencies and cache in the same layer
# -- it may be possible to decrease image size slightly by using build stage and copying all site-packages to runtime stage # it may be possible to decrease image size slightly by using build stage and
# but the image is already pretty small (117mb uncompressed, ~40mb compressed) # copying all site-packages to runtime stage but the image is already pretty small
RUN \ RUN \
echo "**** install build packages ****" && \ echo "**** install build packages ****" && \
apk add --no-cache --virtual=build-deps \ apk add --no-cache --virtual=build-deps \
@ -33,8 +35,6 @@ RUN \
wheel && \ wheel && \
echo "**** install maloja requirements ****" && \ echo "**** install maloja requirements ****" && \
pip3 install --no-cache-dir -r requirements.txt && \ pip3 install --no-cache-dir -r requirements.txt && \
echo "**** install maloja ****" && \
pip3 install /usr/src/app && \
echo "**** cleanup ****" && \ echo "**** cleanup ****" && \
apk del --purge \ apk del --purge \
build-deps && \ build-deps && \
@ -42,18 +42,33 @@ RUN \
/tmp/* \ /tmp/* \
${HOME}/.cache ${HOME}/.cache
# actual installation in extra layer so we can cache the stuff above
COPY --chown=abc:abc . .
RUN \
echo "**** install maloja ****" && \
apk add --no-cache --virtual=install-deps \
py3-pip && \
pip3 install /usr/src/app && \
apk del --purge \
install-deps && \
rm -rf \
/tmp/* \
${HOME}/.cache
COPY container/root/ / COPY container/root/ /
ENV \
# Docker-specific configuration # Docker-specific configuration
# defaulting to IPv4 is no longer necessary (default host is dual stack) MALOJA_SKIP_SETUP=yes \
ENV MALOJA_SKIP_SETUP=yes PYTHONUNBUFFERED=1 \
ENV PYTHONUNBUFFERED=1
# Prevents breaking change for previous container that ran maloja as root # 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
# 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 PUID=0 \
ENV PUID=0 PGID=0
ENV PGID=0
EXPOSE 42010 EXPOSE 42010