Added translations to ProjectSend docker image

This commit is contained in:
Alexander Schomburg
2021-11-14 22:08:44 +01:00
parent d1dc6e5858
commit b9e83b3406
7 changed files with 56 additions and 76 deletions
+4 -10
View File
@@ -3,9 +3,9 @@ name: Build Image
on: [push, pull_request, workflow_dispatch]
env:
ENDPOINT: "linuxserver/mods" #don't modify
BASEIMAGE: "replace_baseimage" #replace
MODNAME: "replace_modname" #replace
ENDPOINT: "linuxserver/mods"
BASEIMAGE: "projectsend"
MODNAME: "translations"
jobs:
build:
@@ -16,7 +16,6 @@ jobs:
- name: Build image
run: |
docker build --no-cache -t ${{ github.sha }} .
- name: Tag image
if: ${{ github.ref == format('refs/heads/{0}-{1}', env.BASEIMAGE, env.MODNAME) }}
run: |
@@ -24,7 +23,6 @@ jobs:
docker tag ${{ github.sha }} ${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ github.sha }}
docker tag ${{ github.sha }} ghcr.io/${ENDPOINT}:${BASEIMAGE}-${MODNAME}
docker tag ${{ github.sha }} ghcr.io/${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ github.sha }}
- name: Credential check
if: ${{ github.ref == format('refs/heads/{0}-{1}', env.BASEIMAGE, env.MODNAME) }}
run: |
@@ -38,25 +36,21 @@ jobs:
echo "::error::See https://github.com/linuxserver/docker-mods/blob/master/README.md for more information/instructions."
exit 1
fi
- name: Login to GitHub Container Registry
if: ${{ github.ref == format('refs/heads/{0}-{1}', env.BASEIMAGE, env.MODNAME) && env.CR_USER && env.CR_PAT }}
run: |
echo "${{ secrets.CR_PAT }}" | docker login ghcr.io -u ${{ secrets.CR_USER }} --password-stdin
- name: Push tags to GitHub Container Registry
if: ${{ github.ref == format('refs/heads/{0}-{1}', env.BASEIMAGE, env.MODNAME) && env.CR_USER && env.CR_PAT }}
run: |
docker push ghcr.io/${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ github.sha }}
docker push ghcr.io/${ENDPOINT}:${BASEIMAGE}-${MODNAME}
- name: Login to DockerHub
if: ${{ github.ref == format('refs/heads/{0}-{1}', env.BASEIMAGE, env.MODNAME) && env.DOCKERUSER && env.DOCKERPASS }}
run: |
echo ${{ secrets.DOCKERPASS }} | docker login -u ${{ secrets.DOCKERUSER }} --password-stdin
- name: Push tags to DockerHub
if: ${{ github.ref == format('refs/heads/{0}-{1}', env.BASEIMAGE, env.MODNAME) && env.DOCKERUSER && env.DOCKERPASS }}
run: |
docker push ${ENDPOINT}:${BASEIMAGE}-${MODNAME}-${{ github.sha }}
docker push ${ENDPOINT}:${BASEIMAGE}-${MODNAME}
docker push ${ENDPOINT}:${BASEIMAGE}-${MODNAME}
+5 -1
View File
@@ -1,6 +1,10 @@
FROM scratch
LABEL maintainer="username"
LABEL maintainer="alexschomb"
# copy local files
COPY root/ /
# install languages
RUN chmod +x /install-translations.sh
CMD /install-translations.sh
-23
View File
@@ -1,23 +0,0 @@
## Buildstage ##
FROM ghcr.io/linuxserver/baseimage-alpine:3.12 as buildstage
RUN \
echo "**** install packages ****" && \
apk add --no-cache \
curl && \
echo "**** grab rclone ****" && \
mkdir -p /root-layer && \
curl -o \
/root-layer/rclone.deb -L \
"https://downloads.rclone.org/v1.47.0/rclone-v1.47.0-linux-amd64.deb"
# copy local files
COPY root/ /root-layer/
## Single layer deployed image ##
FROM scratch
LABEL maintainer="username"
# Add files from buildstage
COPY --from=buildstage /root-layer/ /
+31 -12
View File
@@ -1,17 +1,36 @@
# Rsync - Docker mod for openssh-server
# Translations - Docker mod for projectsend
This mod adds rsync to openssh-server, to be installed/updated during container start.
This mod adds installation options for adding translations to the [Docker image of LinuxServer.io](https://github.com/linuxserver/docker-projectsend) for [ProjectSend](http://www.projectsend.org/). The translations to be installed can be defined with ``PS_INSTALL_TRANSLATIONS`` as a comma-separated list and will be automatically downloaded from the [official translations website](https://www.projectsend.org/translations/). To help translating (and adding your preferred language to) ProjectSend, please follow [this link](https://www.transifex.com/subwaydesign/projectsend/).
In openssh-server docker arguments, set an environment variable `DOCKER_MODS=linuxserver/mods:openssh-server-rsync`
## Using this Docker Mod
If adding multiple mods, enter them in an array separated by `|`, such as `DOCKER_MODS=linuxserver/mods:openssh-server-rsync|linuxserver/mods:openssh-server-mod2`
To add this Docker Mod to your installation of the ProjectSend [Docker image of LinuxServer.io](https://github.com/linuxserver/docker-projectsend), please add this endpoint ``linuxserver/mods:projectsend-translations`` to the ``DOCKER_MODS`` environment variable. You can install multiple Docker Mods by separating them by ``|``. [Read this page](https://github.com/linuxserver/docker-mods#using-a-docker-mod) for more information.
# Mod creation instructions
Now, you can define the languages/translations to be installed with their "Lang. code" value from the before mentioned [official translations website](https://www.projectsend.org/translations/) to the ``TRANSLATIONS`` environment variable. You can choose to install multiple translations by separating them with commas. The English translation ``en`` is automatically installed by the ProjectSend image and does not have to be addressed by this Docker Mod or the ``TRANSLATIONS`` environment variable.
* Fork the repo, create a new branch based on the branch `template`.
* Edit the `Dockerfile` for the mod. `Dockerfile.complex` is only an example and included for reference; it should be deleted when done.
* Inspect the `root` folder contents. Edit, add and remove as necessary.
* Edit this readme with pertinent info, delete these instructions.
* Finally edit the `.github/workflows/BuildImage.yml`. Customize the build branch, and the vars for `BASEIMAGE` and `MODNAME`.
* Ask the team to create a new branch named `<baseimagename>-<modname>`. Baseimage should be the name of the image the mod will be applied to. The new branch will be based on the `template` branch.
* Submit PR against the branch created by the team.
Full example with ``docker-compose``:
```
---
version: "2.1"
services:
projectsend:
image: lscr.io/linuxserver/projectsend
container_name: projectsend
environment:
- PUID=1000
- PGID=1000
- TZ=Europe/London
- MAX_UPLOAD=<5000>
- DOCKER_MODS=linuxserver/mods:projectsend-translations
- TRANSLATIONS=de,fr,zh_CN
volumes:
- <path to data>:/config
- <path to data>:/data
ports:
- 80:80
restart: unless-stopped
```
## Source / References
I took inspiration from the Dockerfile of the [Grafana](https://github.com/grafana/grafana/) repository, especially [this file](https://github.com/grafana/grafana/blob/main/packaging/docker/run.sh). Thanks!
-27
View File
@@ -1,27 +0,0 @@
#!/usr/bin/with-contenv bash
# Determine if setup is needed
if [ ! -f /usr/local/lib/python***/dist-packages/sshuttle ] && \
[ -f /usr/bin/apt ]; then
## Ubuntu
apt-get update
apt-get install --no-install-recommends -y \
iptables \
openssh-client \
python3 \
python3-pip
pip3 install sshuttle
fi
if [ ! -f /usr/lib/python***/site-packages/sshuttle ] && \
[ -f /sbin/apk ]; then
# Alpine
apk add --no-cache \
iptables \
openssh \
py3-pip \
python3
pip3 install sshuttle
fi
chown -R root:root /root
chmod -R 600 /root/.ssh
-3
View File
@@ -1,3 +0,0 @@
#!/usr/bin/with-contenv bash
sshuttle --dns --remote root@${HOST}:${PORT} 0/0 -x 172.17.0.0/16
+16
View File
@@ -0,0 +1,16 @@
#!/bin/bash -e
if [ ! -z "${TRANSLATIONS}" ]; then
OLDIFS=$IFS
IFS=','
for translation in ${TRANSLATIONS}; do
IFS=$OLDIFS
echo "**** install translation: ${translation} ****"
curl -s -o "/tmp/${translation}.zip" -L "https://www.projectsend.org/translations/get.php?lang=${translation}"
unzip -o "/tmp/${translation}.zip" -d /app/projectsend;
done
echo "**** cleanup ****"
rm -rf /tmp/*
fi
while :; do :; done & kill -STOP $! && wait $!