-
-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #205 from FoxxMD/lsio
Refactor container image to use linuxserverio alpine base
- Loading branch information
Showing
12 changed files
with
85 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
* | ||
!maloja | ||
!container | ||
!Containerfile | ||
!requirements.txt | ||
!pyproject.toml | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,59 @@ | ||
FROM alpine:3.15 | ||
# Python image includes two Python versions, so use base Alpine | ||
|
||
# Based on the work of Jonathan Boeckel <[email protected]> | ||
FROM lsiobase/alpine:3.17 as base | ||
|
||
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 | ||
COPY --chown=abc:abc . . | ||
|
||
# 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 \ | ||
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 | ||
|
||
|
||
# no chance for caching below here | ||
|
||
COPY . . | ||
|
||
RUN pip install /usr/src/app | ||
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 | ||
# defaulting to IPv4 is no longer necessary (default host is dual stack) | ||
ENV MALOJA_SKIP_SETUP=yes | ||
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 | ||
# use exec form for better signal handling https://docs.docker.com/engine/reference/builder/#entrypoint | ||
ENTRYPOINT ["maloja", "run"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
10 changes: 10 additions & 0 deletions
10
container/root/etc/s6-overlay/s6-rc.d/init-permission-check/run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/usr/bin/with-contenv bash | ||
|
||
if [ "$(s6-setuidgid abc id -u)" = "0" ]; then | ||
echo "-------------------------------------" | ||
echo "WARN: Running as root! If you meant to do this than this message can be ignored." | ||
echo "If you are running this container on a *linux* host and are not using podman rootless you SHOULD" | ||
echo "change the ENVs PUID and PGID for this container to ensure correct permissions on your config folder." | ||
echo -e "See: https://github.com/krateng/maloja#linux-host\n" | ||
echo -e "-------------------------------------\n" | ||
fi |
1 change: 1 addition & 0 deletions
1
container/root/etc/s6-overlay/s6-rc.d/init-permission-check/type
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
oneshot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/etc/s6-overlay/s6-rc.d/init-permission-check/run |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/with-contenv bash | ||
|
||
# used https://github.com/linuxserver/docker-wikijs/blob/master/root/etc/s6-overlay/s6-rc.d/svc-wikijs/run as a template | ||
|
||
echo -e "\nMaloja is starting!" | ||
exec \ | ||
s6-setuidgid abc python -m maloja run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
longrun |
Empty file.
Empty file.