Skip to content

Commit

Permalink
Init repo.
Browse files Browse the repository at this point in the history
  • Loading branch information
dzhuang committed Jan 10, 2024
0 parents commit 141446c
Show file tree
Hide file tree
Showing 9 changed files with 278 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Build
on:
workflow_dispatch:
inputs:
tmmVersion:
description: 'Version of tmm.jar'
required: true
default: '5.0'

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Build image
uses: actions/checkout@v2
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
build-args: |
TMM_VERSION=${{ github.event.inputs.tmmVersion }}
tags: dzhuang/tinymediamanager:v${{ github.event.inputs.tmmVersion }}
push: true
22 changes: 22 additions & 0 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Tag
on:
workflow_dispatch:
inputs:
toBeTagAsLatestV5:
description: 'The image tag which will be tag as latest-v5'
required: true

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Pull and push image
run: |
docker pull dzhuang/tinymediamanager:${{ github.event.inputs.toBeTagAsLatestV5 }}
docker tag dzhuang/tinymediamanager:${{ github.event.inputs.toBeTagAsLatestV5 }} ${{ secrets.DOCKERHUB_USERNAME }}/tinymediamanager:latest-v5
docker push dzhuang/tinymediamanager:latest-v5
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/media
/config
80 changes: 80 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#
# TinyMediaManager Dockerfile
#
FROM jlesage/baseimage-gui:alpine-3.12-glibc

# Define software versions.
ARG TMM_VERSION=5.0

# Define software download URLs.
ARG TMM_URL=https://release.tinymediamanager.org/v5/dist/tinyMediaManager-${TMM_VERSION}-linux-amd64.tar.xz
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/jre/bin

# Define working directory.
WORKDIR /tmp

# Download TinyMediaManager
RUN \
mkdir -p /defaults && \
wget ${TMM_URL} -O /defaults/tmm.tar.xz

# Install dependencies.
RUN \
apk add --update \
libmediainfo \
ttf-dejavu \
bash \
zenity \
tar \
zstd \
fontconfig \
ttf-dejavu


# Fix Java Segmentation Fault
RUN wget "https://www.archlinux.org/packages/core/x86_64/zlib/download" -O /tmp/libz.tar.xz \
&& mkdir -p /tmp/libz \
&& tar -xf /tmp/libz.tar.xz -C /tmp/libz \
&& cp /tmp/libz/usr/lib/libz.so.1.3 /usr/glibc-compat/lib \
&& /usr/glibc-compat/sbin/ldconfig \
&& rm -rf /tmp/libz /tmp/libz.tar.xz

# Maximize only the main/initial window.
# It seems this is not needed for TMM 3.X version.
#RUN \
# sed-patch 's/<application type="normal">/<application type="normal" title="tinyMediaManager \/ 3.0.2">/' \
# /etc/xdg/openbox/rc.xml

# Generate and install favicons.
RUN \
APP_ICON_URL=https://gitlab.com/tinyMediaManager/tinyMediaManager/raw/45f9c702615a55725a508523b0524166b188ff75/AppBundler/tmm.png && \
install_app_icon.sh "$APP_ICON_URL"


# Install Chinese fonts
RUN wget -O /tmp/font.tar.gz http://downloads.sourceforge.net/wqy/wqy-zenhei-0.9.45.tar.gz && \
tar -xzvf /tmp/font.tar.gz -C /tmp/ && \
mkdir -p /usr/share/fonts/truetype/wqy && \
cp /tmp/wqy-zenhei/wqy-zenhei.ttc /usr/share/fonts/truetype/wqy/ && \
fc-cache -f -v && \
rm -rf /tmp/font.tar.gz /tmp/wqy-zenhei

# Add files.
COPY rootfs/ /
COPY VERSION /

# Set environment variables.
ENV APP_NAME="TinyMediaManager" \
S6_KILL_GRACETIME=8000

# Define mountable directories.
VOLUME ["/config"]
VOLUME ["/media"]

# Metadata.
LABEL \
org.label-schema.name="tinymediamanager" \
org.label-schema.description="Docker container for TinyMediaManager" \
org.label-schema.version="unknown" \
org.label-schema.vcs-url="https://github.com/dzhuang/tinymediamanager5-docker" \
org.label-schema.schema-version="1.0"
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# tinymediamanager5-docker

A repository for creating a docker container including TinyMediaManager with GUI interface (**with Chinese and Japanese fonts**).

## modification to the original repo
- Add Chinese and Japanese fonts support out of the box (中文支持开箱即用)
- Quick fix for [bug](https://github.com/dzhuang/tinymediamanager-docker/issues/13) that image change did not result in changes of version in running containers . Need to test if version change between v3 and v4 works and will submit PR to original repo. (修复image升级/变化后,容器实际运行的tmm版本未变化的[bug](https://github.com/dzhuang/tinymediamanager-docker/issues/13),跨V3和V4的版本切换未测试,请谨慎使用)
- Demo docker compose file that enable container auto upgrade (支持自动升级版本的docker compose示例文件).

The build also fixes the version not updated issue of the
To use this build, please use `dzhuang/tinymediamanager:v5-latest`.

![docker pulls](https://img.shields.io/docker/pulls/dzhuang/tinymediamanager.svg) ![docker stars](https://img.shields.io/docker/stars/dzhuang/tinymediamanager.svg)

Latest versions:

![Docker Image Version (latest semver)](https://img.shields.io/docker/v/dzhuang/tinymediamanager/v5) ![docker size](https://img.shields.io/docker/image-size/dzhuang/tinymediamanager/v5)

Instructions:
- Map any local port to 5800 for web access
- Map any local port to 5900 for VNC access
- Map a local volume to /config (Stores configuration data)
- Map a local volume to /media (Access media files)

Sample run command:

```bash
docker run -d --name=tinymediamanager \
-v /share/Container/tinymediamanager/config:/config \
-v /share/Container/tinymediamanager/media:/media \
-e GROUP_ID=0 -e USER_ID=0 -e TZ=Europe/Madrid \
-p 5800:5800 \
-p 5900:5900 \
dzhuang/tinymediamanager:v5-latest
```
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v5.0
16 changes: 16 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: '3'

services:
tinymediamanager_service:
image: dzhuang/tinymediamanager-docker:v5-latest
container_name: tinymediamanager-v5
ports:
- 5800:5800
- 5900:5900
volumes:
- ./config:/config
- ./media:/media
environment:
GROUP_ID: 1000
USER_ID: 0
TZ: Asia/Hong_Kong
33 changes: 33 additions & 0 deletions rootfs/etc/cont-init.d/tmm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/with-contenv sh

set -e # Exit immediately if a command exits with a non-zero status.
set -u # Treat unset variables as an error.

log() {
echo "[cont-init.d] $(basename $0): $*"
}

# Make sure mandatory directories exist.
mkdir -p /config/logs

if [ ! -f /config/tmm.jar ] || [ ! -f /config/tmm.tar.xz ] || ! cmp /defaults/tmm.tar.xz /config/tmm.tar.xz; then
cp -r /defaults/* /config/
cd /config
tar --strip-components=1 -xJf /config/tmm.tar.xz
fi

# Take ownership of the config directory content.
chown -R $USER_ID:$GROUP_ID /config/*

# Take ownership of the output directory.
#if ! chown $USER_ID:$GROUP_ID /output; then
# Failed to take ownership of /output. This could happen when,
# for example, the folder is mapped to a network share.
# Continue if we have write permission, else fail.
# if s6-setuidgid $USER_ID:$GROUP_ID [ ! -w /output ]; then
# log "ERROR: Failed to take ownership and no write permission on /output."
# exit 1
# fi
#fi

# vim: set ft=sh :
61 changes: 61 additions & 0 deletions rootfs/startapp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/bin/sh

set -u # Treat unset variables as an error.

trap "exit" TERM QUIT INT
trap "kill_tmm" EXIT

log() {
echo "[tmmsupervisor] $*"
}

getpid_tmm() {
PID=UNSET
if [ -f /config/tmm.pid ]; then
PID="$(cat /config/tmm.pid)"
# Make sure the saved PID is still running and is associated to
# TinyMediaManager.
if [ ! -f /proc/$PID/cmdline ] || ! cat /proc/$PID/cmdline | grep -qw "tmm.jar"; then
PID=UNSET
fi
fi
if [ "$PID" = "UNSET" ]; then
PID="$(ps -o pid,args | grep -w "tmm.jar" | grep -vw grep | tr -s ' ' | cut -d' ' -f2)"
fi
echo "${PID:-UNSET}"
}

is_tmm_running() {
[ "$(getpid_tmm)" != "UNSET" ]
}

start_tmm() {
/config/tinyMediaManager > /config/logs/output.log 2>&1 &
}

kill_tmm() {
PID="$(getpid_tmm)"
if [ "$PID" != "UNSET" ]; then
log "Terminating TinyMediaManager..."
kill $PID
wait $PID
fi
}

if ! is_tmm_running; then
log "TinyMediaManager not started yet. Proceeding..."
start_tmm
fi

TMM_NOT_RUNNING=0
while [ "$TMM_NOT_RUNNING" -lt 60 ]
do
if is_tmm_running; then
TMM_NOT_RUNNING=0
else
TMM_NOT_RUNNING="$(expr $TMM_NOT_RUNNING + 1)"
fi
sleep 1
done

log "TinyMediaManager no longer running. Exiting..."

0 comments on commit 141446c

Please sign in to comment.