Merge pull request #264 from alexschomb/projectsend-translations

Projectsend translations
This commit is contained in:
aptalca
2023-05-19 09:34:16 -04:00
committed by GitHub
14 changed files with 116 additions and 117 deletions
+34 -51
View File
@@ -1,62 +1,45 @@
name: Build Image
on: [push, pull_request, workflow_dispatch]
on: [push, pull_request_target, workflow_dispatch]
env:
GITHUB_REPO: "linuxserver/docker-mods" #don't modify
ENDPOINT: "linuxserver/mods" #don't modify
BASEIMAGE: "replace_baseimage" #replace
MODNAME: "replace_modname" #replace
BASEIMAGE: "projectsend" #replace
MODNAME: "translations" #replace
jobs:
build:
set-vars:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.3
- name: Build image
- name: Set Vars
id: outputs
run: |
docker build --no-cache -t ${{ github.sha }} .
echo "GITHUB_REPO=${{ env.GITHUB_REPO }}" >> $GITHUB_OUTPUT
echo "ENDPOINT=${{ env.ENDPOINT }}" >> $GITHUB_OUTPUT
echo "BASEIMAGE=${{ env.BASEIMAGE }}" >> $GITHUB_OUTPUT
echo "MODNAME=${{ env.MODNAME }}" >> $GITHUB_OUTPUT
# **** If the mod needs to be versioned, set the versioning logic below. Otherwise leave as is. ****
MOD_VERSION=""
echo "MOD_VERSION=${MOD_VERSION}" >> $GITHUB_OUTPUT
outputs:
GITHUB_REPO: ${{ steps.outputs.outputs.GITHUB_REPO }}
ENDPOINT: ${{ steps.outputs.outputs.ENDPOINT }}
BASEIMAGE: ${{ steps.outputs.outputs.BASEIMAGE }}
MODNAME: ${{ steps.outputs.outputs.MODNAME }}
MOD_VERSION: ${{ steps.outputs.outputs.MOD_VERSION }}
- name: Tag image
if: ${{ github.ref == format('refs/heads/{0}-{1}', env.BASEIMAGE, env.MODNAME) }}
run: |
docker tag ${{ github.sha }} ${ENDPOINT}:${BASEIMAGE}-${MODNAME}
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: |
echo "CR_USER=${{ secrets.CR_USER }}" >> $GITHUB_ENV
echo "CR_PAT=${{ secrets.CR_PAT }}" >> $GITHUB_ENV
echo "DOCKERUSER=${{ secrets.DOCKERUSER }}" >> $GITHUB_ENV
echo "DOCKERPASS=${{ secrets.DOCKERPASS }}" >> $GITHUB_ENV
if [[ "${{ secrets.CR_USER }}" == "" && "${{ secrets.CR_PAT }}" == "" && "${{ secrets.DOCKERUSER }}" == "" && "${{ secrets.DOCKERPASS }}" == "" ]]; then
echo "::error::Push credential secrets missing."
echo "::error::You must set either CR_USER & CR_PAT or DOCKERUSER & DOCKERPASS as secrets in your repo settings."
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}
build:
uses: linuxserver/github-workflows/.github/workflows/docker-mod-builder.yml@v1
needs: set-vars
secrets:
CR_USER: ${{ secrets.CR_USER }}
CR_PAT: ${{ secrets.CR_PAT }}
DOCKERUSER: ${{ secrets.DOCKERUSER }}
DOCKERPASS: ${{ secrets.DOCKERPASS }}
with:
GITHUB_REPO: ${{ needs.set-vars.outputs.GITHUB_REPO }}
ENDPOINT: ${{ needs.set-vars.outputs.ENDPOINT }}
BASEIMAGE: ${{ needs.set-vars.outputs.BASEIMAGE }}
MODNAME: ${{ needs.set-vars.outputs.MODNAME }}
MOD_VERSION: ${{ needs.set-vars.outputs.MOD_VERSION }}
@@ -0,0 +1,16 @@
name: Issue & PR Tracker
on:
issues:
types: [opened,reopened,labeled,unlabeled,closed]
pull_request_target:
types: [opened,reopened,review_requested,review_request_removed,labeled,unlabeled,closed]
pull_request_review:
types: [submitted,edited,dismissed]
jobs:
manage-project:
permissions:
issues: write
uses: linuxserver/github-workflows/.github/workflows/issue-pr-tracker.yml@v1
secrets: inherit
+10
View File
@@ -0,0 +1,10 @@
name: Permission check
on:
pull_request_target:
paths:
- '**/run'
- '**/finish'
- '**/check'
jobs:
permission_check:
uses: linuxserver/github-workflows/.github/workflows/init-svc-executable-permissions.yml@v1
+3 -1
View File
@@ -1,6 +1,8 @@
# syntax=docker/dockerfile:1
FROM scratch
LABEL maintainer="username"
LABEL maintainer="alexschomb"
# copy local files
COPY root/ /
-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/ /
+32 -12
View File
@@ -1,17 +1,37 @@
# 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 ``TRANSLATIONS`` as a comma-separated list and can be either be automatically installed from the [official translations website](https://www.projectsend.org/translations/) or the local ``/translations`` volume. 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 name to the ``TRANSLATIONS`` environment variable. You can choose to install multiple translations by separating them with commas. You can either install them by providing the folder name of a subfolder in the new ``/translations`` volume, or the "Lang. code" value from the before mentioned [official translations website](https://www.projectsend.org/translations/). 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
- <path to data>:/translations
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
@@ -0,0 +1,19 @@
#!/usr/bin/with-contenv bash
if [ ! -z "${TRANSLATIONS}" ]; then
OLDIFS=$IFS
IFS=','
for translation in ${TRANSLATIONS}; do
IFS=$OLDIFS
if [[ -d "/translations/${translation}" ]]; then
echo "**** install local translation: ${translation} ****"
cp -R "/translations/${translation}/*" /app/projectsend/
else
echo "**** install online 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;
fi
done
echo "**** cleanup ****"
rm -rf /tmp/*
fi
@@ -0,0 +1 @@
oneshot
@@ -0,0 +1 @@
/etc/s6-overlay/s6-rc.d/init-mod-projectsend-translations/run
-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