mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-18 13:06:09 +05:00
feat: add github action for docker build on release (#132)
* feat: add github action Add github action for auto build slim torrverser alpine image with ffmpeg for linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le platforms * build: move creating dirs and files to entrypoint * fix: remove linux/386 and linux/ppc64le from docker building * fix: update readme with docker info
This commit is contained in:
49
.github/workflows/github-actions-docker.yml
vendored
Normal file
49
.github/workflows/github-actions-docker.yml
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
name: ci
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
|
||||
jobs:
|
||||
docker:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
-
|
||||
name: tag number
|
||||
run : echo ${{ github.event.release.tag_name }}
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
-
|
||||
name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
-
|
||||
name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
-
|
||||
name: set lower case owner name
|
||||
run: |
|
||||
echo "REG_REPO=${REPO,,}" >>${GITHUB_ENV}
|
||||
env:
|
||||
REPO: '${{ github.repository }}'
|
||||
-
|
||||
name: CHECK ENVS
|
||||
run: |
|
||||
echo ${{ env.REG_REPO }}
|
||||
-
|
||||
name: Build and push
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
context: .
|
||||
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64
|
||||
push: true
|
||||
tags: |
|
||||
ghcr.io/${{ env.REG_REPO }}:${{ github.event.release.tag_name }}
|
||||
ghcr.io/${{ env.REG_REPO }}:latest
|
||||
60
Dockerfile
Normal file
60
Dockerfile
Normal file
@@ -0,0 +1,60 @@
|
||||
### FRONT BUILD START ###
|
||||
FROM --platform=$BUILDPLATFORM node:16-alpine as front
|
||||
COPY ./web /app
|
||||
WORKDIR /app
|
||||
# Build front once upon multiarch build
|
||||
RUN yarn install && yarn run build
|
||||
### FRONT BUILD END ###
|
||||
|
||||
### BUILD TORRSERVER MULTIARCH START ###
|
||||
FROM --platform=$BUILDPLATFORM golang:1.17-alpine as builder
|
||||
|
||||
COPY . /opt/src
|
||||
COPY --from=front /app/build /opt/src/web/build
|
||||
|
||||
WORKDIR /opt/src
|
||||
|
||||
ARG TARGETARCH
|
||||
|
||||
# Step for multiarch build with docker buildx
|
||||
ENV GOARCH=$TARGETARCH
|
||||
|
||||
# Build torrserver
|
||||
RUN apk add --update g++ \
|
||||
&& go run gen_web.go \
|
||||
&& cd server \
|
||||
&& go clean -i -r -cache \
|
||||
&& go mod tidy \
|
||||
&& go build -ldflags '-w -s' --o "torrserver" ./cmd
|
||||
### BUILD TORRSERVER MULTIARCH END ###
|
||||
|
||||
|
||||
### UPX COMPRESSING START ###
|
||||
FROM debian:buster-slim as compressed
|
||||
|
||||
COPY --from=builder /opt/src/server/torrserver ./torrserver
|
||||
|
||||
RUN apt-get update && apt-get install -y upx-ucl && upx --best --lzma ./torrserver
|
||||
# Compress torrserver only for amd64 and arm64 no variant platforms
|
||||
# ARG TARGETARCH
|
||||
# ARG TARGETVARIANT
|
||||
# RUN if [ "$TARGETARCH" == 'amd64' ]; then compress=1; elif [ "$TARGETARCH" == 'arm64' ] && [ -z "$TARGETVARIANT" ]; then compress=1; else compress=0; fi \
|
||||
# && if [[ "$compress" -eq 1 ]]; then ./upx --best --lzma ./torrserver; fi
|
||||
### UPX COMPRESSING END ###
|
||||
|
||||
### BUILD MAIN IMAGE START ###
|
||||
FROM alpine
|
||||
|
||||
ENV TS_CONF_PATH="/opt/ts/config"
|
||||
ENV TS_LOG_PATH="/opt/ts/log"
|
||||
ENV TS_TORR_DIR="/opt/ts/torrents"
|
||||
ENV TS_PORT=8090
|
||||
ENV GODEBUG=madvdontneed=1
|
||||
|
||||
COPY --from=compressed ./torrserver /usr/bin/torrserver
|
||||
COPY ./docker-entrypoint.sh /docker-entrypoint.sh
|
||||
|
||||
RUN apk add --no-cache --update ffmpeg
|
||||
|
||||
CMD /docker-entrypoint.sh
|
||||
### BUILD MAIN IMAGE end ###
|
||||
21
README.md
21
README.md
@@ -190,6 +190,27 @@ local:127.0.0.1\
|
||||
Open msx and goto: Settings -> Start Parameter -> Setup \
|
||||
Enter current ip address and port of server e.g. _127.0.0.1:8090_
|
||||
|
||||
#
|
||||
### Running in docker
|
||||
Just run: `docker run --rm -d --name torrserver -p 8090:8090 ghcr.io/yourok/torrserver:latest` \
|
||||
For running in persistence mode, just mount volume to container by adding `-v ~/ts:/opt/ts`, where `~/ts` folder path is just example, but you could use it anyway... Result example command: `docker run --rm -d --name torrserver -v ~/ts:/opt/ts -p 8090:8090 ghcr.io/yourok/torrserver:latest` \
|
||||
Other options:
|
||||
- add `-e TS_HTTPAUTH=1` and place [auth file](#authorization) into `~/ts/config` forlder for enabling basic auth
|
||||
- add `-e TS_RDB=1` for enabling `--rdb` flag
|
||||
- add `-e TS_DONTKILL=1` for enabling `--dontkill` flag
|
||||
- add `-e TS_PORT=5555` for changind default port to 5555(example), also u need to change `-p 8090:8090` to `-p 5555:5555` (example)
|
||||
- add `-e TS_CONF_PATH=/opt/tsss` for overriding torrserver config path inside container
|
||||
- add `-e TS_TORR_DIR=/opt/torr_files` for overriding torrents directory
|
||||
- add `-e TS_LOG_PATH=/opt/torrserver.log` for overriding log path
|
||||
|
||||
|
||||
Example with full overrided command(on default values):
|
||||
```
|
||||
docker run --rm -d -e TS_PORT=5665 -e TS_DONTKILL=1 -e TS_HTTPAUTH=1 -e TS_RDB=1 -e TS_CONF_PATH=/opt/ts/config -e TS_LOG_PATH=/opt/ts/log -e TS_TORR_DIR=/opt/ts/torrents --name torrserver -v ~/ts:/opt/ts -p 5665:5665 ghcr.io/yourok/torrserver:latest
|
||||
|
||||
```
|
||||
|
||||
|
||||
#
|
||||
### Donate:
|
||||
[PayPal](https://www.paypal.me/yourok) \
|
||||
|
||||
22
docker-entrypoint.sh
Executable file
22
docker-entrypoint.sh
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/bin/sh
|
||||
|
||||
FLAGS="--path $TS_CONF_PATH --logpath $TS_LOG_PATH --port $TS_PORT --torrentsdir $TS_TORR_DIR"
|
||||
if [[ -n "$TS_HTTPAUTH" ]]; then FLAGS="${FLAGS} --httpauth"; fi
|
||||
if [[ -n "$TS_RDB" ]]; then FLAGS="${FLAGS} --rdb"; fi
|
||||
if [[ -n "$TS_DONTKILL" ]]; then FLAGS="${FLAGS} --dontkill"; fi
|
||||
|
||||
if [ ! -d $TS_CONF_PATH ]; then
|
||||
mkdir -p $TS_CONF_PATH
|
||||
fi
|
||||
|
||||
if [ ! -d $TS_TORR_DIR ]; then
|
||||
mkdir -p $TS_TORR_DIR
|
||||
fi
|
||||
|
||||
if [ ! -f $TS_LOG_PATH ]; then
|
||||
touch $TS_LOG_PATH
|
||||
fi
|
||||
|
||||
echo "Running with: ${FLAGS}"
|
||||
|
||||
torrserver $FLAGS
|
||||
16
gen_web.go
16
gen_web.go
@@ -14,14 +14,16 @@ import (
|
||||
|
||||
func main() {
|
||||
dir, _ := os.Getwd()
|
||||
os.Chdir("web")
|
||||
if run("yarn") != nil {
|
||||
os.Exit(1)
|
||||
if _, err := os.Stat("web/build/static"); os.IsNotExist(err) {
|
||||
os.Chdir("web")
|
||||
if run("yarn") != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
if run("yarn", "run", "build") != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
os.Chdir(dir)
|
||||
}
|
||||
if run("yarn", "run", "build") != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
os.Chdir(dir)
|
||||
|
||||
compileHtml := "web/build/"
|
||||
srcGo := "server/web/pages/"
|
||||
|
||||
Reference in New Issue
Block a user