chkuendig / tvhProxy

📡 Connect Plex DVR with tvheadend (incl. EPG)
https://christian.kuendig.info/posts/2020-02-tvhproxy/
Other
43 stars 9 forks source link

Docker file update #10

Open Doodles2000 opened 1 year ago

Doodles2000 commented 1 year ago

Hi All,

Newbie to git and docker here.

After much docker learning, here is a modified Dockerfile I us. It sets/includes applicable environment variables to make container control a little easier (for me anyhow).

In addition made some tweaks to the python script that will build the connection url based upon environment variables

Rather than create a fork of the entire project, happy to share here. If this is incorrect, please let me know the correct way.

{start Dockerfile}

FROM python:3-slim ENV DEVICE_ID=12345678 ENV TVH_PROXY_HOST='' ENV TVH_PROXY_PORT=5004 ENV TVH_BINDADDR='' ENV TVHUSER='[username]_' ENV TVHPASSWORD='[password]_' ENV TVHHOST='[tvheadend ip/name]_' ENV TVH_PORT=9981 ENV TVH_TUNER_COUNT=1 ENV TVH_WEIGHT=300 ENV TVH_CHUNK_SIZE=1048576 ENV TVH_PROFILE='mp4' ENV TZ='Australia/Sydney' WORKDIR /usr/src/app/templates COPY templates/device.xml . WORKDIR /usr/src/app COPY requirements.txt . COPY tvhProxy.py . COPY ssdp.py . RUN pip3 install --no-cache-dir -r requirements.txt EXPOSE $TVH_PROXY_PORT CMD [ "python3", "./tvhProxy.py" ]

{end Dockerfile}

Edits to tvhProxy.py (immediately above config= line)

{start insert} if (os.environ.get('TVH_USER') == '' or os.environ.get('TVH_PASSWORD') == '') or (os.environ.get('TVH_USER') == '' and os.environ.get('TVH_PASSWORD') == '') : u_combined = '' else : u_combined = str(os.environ.get('TVH_USER')) + ':' +str(os.environ.get('TVH_PASSWORD')) + '@' {end insert}

Change tvhURL line in config section to:

'tvhURL': 'http://' + u_combined + (os.environ.get('TVH_HOST') or 'localhost') + ':' + (os.environ.get('TVH_PORT') or '9981'),