<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by David Claeys on Medium]]></title>
        <description><![CDATA[Stories by David Claeys on Medium]]></description>
        <link>https://medium.com/@davidclaeys?source=rss-f09a088813e5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*8GActBDocZ3-zoH8SV6GqA.png</url>
            <title>Stories by David Claeys on Medium</title>
            <link>https://medium.com/@davidclaeys?source=rss-f09a088813e5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 01:37:00 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@davidclaeys/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Migrating from Gitea to Forgejo]]></title>
            <link>https://medium.com/@davidclaeys/migrating-from-gitea-to-forgejo-fabda0bdaea0?source=rss-f09a088813e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/fabda0bdaea0</guid>
            <category><![CDATA[cicd]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[forgejo]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <dc:creator><![CDATA[David Claeys]]></dc:creator>
            <pubDate>Wed, 11 Nov 2026 18:15:18 GMT</pubDate>
            <atom:updated>2026-11-19T10:30:48.085Z</atom:updated>
            <content:encoded><![CDATA[<p>I migrated because I was becoming increasingly worried about the future of Gitea.</p><p>I already wasn’t happy with how the company behind Gitea handled the takeover of the community project. However, I had been using Gitea for a long time, it worked well, and migrating everything wasn’t something I wanted to do without a good reason.</p><p>That changed when I came across a post from one of Gitea’s lead developers describing Gitea as essentially a hobby project. That raised all kinds of red flags for me and finally pushed me to jump ship to what I consider the spiritual successor to Gitea: Forgejo.</p><p>Forgejo itself was created in response to the changes surrounding Gitea in 2022. It originally started as a soft fork of Gitea, with the goal of keeping the project community-driven. In 2024, Forgejo became a hard fork and has since followed its own development path.</p><p>For me, that’s an important distinction. Forgejo represents many of the things I originally appreciated about Gitea: a project built by the community, for the community, where the community remains in control of its direction.</p><h3><strong>Migrating the repositories</strong></h3><p>Unfortunately, the version of Gitea I was running was already too new to perform a straightforward database migration to Forgejo.</p><p>Instead, I migrated my repositories individually using Forgejo’s built-in migration functionality. This took a little more work, but also gave me the opportunity to start with a clean Forgejo installation rather than carrying the entire old Gitea installation over.</p><p>There was, however, one important thing that didn’t come along for the ride: container images.</p><h3><strong>Migrating the container registry</strong></h3><p>I host several container images in my Git registry, and some of them are publicly available and used by other people. Simply abandoning the images in the old Gitea registry therefore wasn’t really an option.</p><p>Forgejo’s repository migration didn’t migrate those images, so I needed another way to transfer them.</p><p>I ended up writing a small script using skopeo and jq that discovers all tags for an image in the old registry and copies them directly to the new Forgejo registry.</p><pre>gitea_instance=&#39;gitea.example.com&#39;<br>gitea_token=&#39;gitea_token&#39;<br>forgejo_instance=&#39;forgejo.example.com&#39;<br>forgejo_token=&#39;forgejo_token&#39;<br>owner=$1<br>package_name=$2<br><br>for t in $(skopeo list-tags docker://$gitea_instance/$owner/$package_name --creds $owner:$gitea_token | jq -r &#39;.Tags[]&#39;); do<br>  skopeo copy --all --src-creds $owner:$gitea_token --dest-creds $owner:$forgejo_token --dest-tls-verify=false docker://$gitea_instance/$owner/$package_name:$t docker://$forgejo_instance/$owner/$package_name:$t<br>done</pre><p>The script requires skopeo and jq and can be run as:</p><pre>./package.sh owner package_name</pre><p>It enumerates all tags for the specified package and uses skopeo copy — all to transfer each image directly between the two registries, including all available architectures.</p><h3><strong>Setting up a Forgejo Actions runner</strong></h3><p>The other part of the migration that required considerably more work than I expected was Forgejo Actions.</p><p>Forgejo Runner puts more thought into isolating Actions jobs from the underlying Docker host.</p><p>While this is much better from a security perspective, it does make things a bit more complicated to set up.</p><p>The first step we need to take is to go to Site Administration/Actions/Runners.</p><p>When we press the <strong>Create new runner</strong> button we’ll get to see the runner <em>UUID</em> and <em>token</em>. Note these down, since we’re going to need them.</p><p>The Docker Compose stack for the runner needs two directories: ./data and ./cert.</p><p>Inside the ./data directory, we’re going to create a <em>runner-config.yml</em> file with the following contents:</p><pre>log:<br>  level: info<br>  job_level: info<br>runner:<br>  # Where to store the registration result.<br>  file: .runner<br>  # Execute how many tasks concurrently at the same time.<br>  capacity: 4<br>  # Extra environment variables to run jobs.<br>  envs:<br>    DOCKER_HOST: tcp://docker:2376<br>    DOCKER_CERT_PATH: /certs/client<br>    DOCKER_TLS_VERIFY: &quot;1&quot;<br>  env_file: .env<br>  timeout: 3h<br>  shutdown_timeout: 3h<br>  insecure: false<br>  fetch_timeout: 30s<br>  fetch_interval: 2s<br>  report_interval: 1s<br>  labels: []<br><br>cache:<br>  enabled: true<br>  port: 0<br>  dir: &quot;&quot;<br>  external_server: &quot;&quot;<br>  secret: &quot;&quot;<br>  secret_url: &quot;&quot;<br>  host: &quot;&quot;<br>  proxy_port: 0<br>  actions_cache_url_override: &quot;&quot;<br>container:<br>  network: &quot;host&quot;<br>  enable_ipv6: false<br>  privileged: false<br>  options: --volume /certs/client:/certs/client:ro<br>  workdir_parent:<br>  valid_volumes: <br>    - &quot;/certs/client&quot;<br>  force_pull: false<br>  force_rebuild: false<br>host:<br>  workdir_parent:<br>server:<br>  connections:<br>    forgejo:<br>      url: https://forgejo.example.com<br>      uuid: runner_uuid<br>      token: runner_token<br>      labels:<br>         -  ubuntu-latest:docker://ghcr.io/catthehacker/ubuntu:act-24.04</pre><p>Your <em>compose.yaml</em> should be something like this:</p><pre>services:<br>  docker:<br>    image: data.forgejo.org/oci/docker:dind<br>    privileged: true<br>    environment:<br>      DOCKER_TLS_CERTDIR: /certs<br>    volumes:<br>      - ./cert:/certs<br>    restart: unless-stopped<br>    networks:<br>      - forgejo-runner<br>  runner:<br>    image: data.forgejo.org/forgejo/runner:13<br>    depends_on:<br>      docker:<br>        condition: service_started<br>    environment:<br>      DOCKER_HOST: tcp://docker:2376<br>      DOCKER_CERT_PATH: /certs/client<br>      DOCKER_TLS_VERIFY: &quot;1&quot;<br>    user: &quot;1001:1001&quot;<br>    volumes:<br>      - ./data:/data<br>      - ./cert:/certs<br>    restart: unless-stopped<br>    command: forgejo-runner daemon --config runner-config.yml<br>    networks:<br>      - forgejo-runner<br>networks:<br>  forgejo-runner:<br>    name: forgejo-runner</pre><p>I know this is quite a lot to unpack, so I’ll do my best to explain what’s going on.</p><p>First of all, this setup doesn’t give the Forgejo Runner direct access to the Docker daemon of the host machine. Instead, we’re running a separate Docker daemon using Docker-in-Docker (DinD), and the runner connects to that daemon.</p><p>This is an important distinction. Giving a CI runner access to /var/run/docker.sock effectively gives jobs a very high level of control over the Docker host. By using a separate Docker daemon, we’re adding a layer of isolation between our Actions jobs and the machine hosting the runner.</p><p>The <em>runner-config.yml</em> file contains the configuration for the Forgejo Runner itself.</p><h4><strong>Runner labels</strong></h4><p>Let’s first have a look at the labels section:</p><pre>labels:<br>  - ubuntu-latest:docker://ghcr.io/catthehacker/ubuntu:act-24.04</pre><p>A label tells Forgejo which runner can execute a job and which environment should be used for it.</p><p>In this example, jobs targeting ubuntu-latest will run inside the <em>ghcr.io/catthehacker/ubuntu:act-24.04</em> container image.</p><p>Forgejo recommends the images from the <a href="https://github.com/catthehacker/docker_images">catthehacker/docker_images repository</a>, although you can use another suitable container image if you prefer.</p><h4><strong>Connecting jobs to Docker</strong></h4><p>Our Forgejo Runner already runs inside a Docker container and uses the separate docker service to start the containers in which our Actions jobs run.</p><p>However, there’s another problem. What if one of those Actions jobs itself needs to use Docker?</p><p>The job container doesn’t automatically know how to reach our Docker-in-Docker daemon. That’s why we add the following environment variables to the runner configuration:</p><pre>runner:<br>  envs:<br>    DOCKER_HOST: tcp://docker:2376<br>    DOCKER_CERT_PATH: /certs/client<br>    DOCKER_TLS_VERIFY: &quot;1&quot;</pre><p>These are intentionally similar to the values used by the runner container in our <em>compose.yaml</em>, but they serve a different purpose.</p><p>The variables in <em>compose.yaml</em> configure the Forgejo Runner container itself:</p><pre>services:<br>....<br>   runner:<br>     ...<br>      environment:<br>        DOCKER_HOST: tcp://docker:2376<br>        DOCKER_CERT_PATH: /certs/client<br>        DOCKER_TLS_VERIFY: &quot;1&quot;</pre><p>The variables under the runner service are passed to the runner container, allowing it to connect to our Docker-in-Docker daemon. Instead of using the physical host’s Docker daemon to create job containers, the runner uses this separate daemon, keeping those operations isolated from the host’s Docker environment.</p><p>Without the variables in our <em>runner-config.yml</em>, the runner would still be able to communicate with our Docker-in-Docker daemon, but commands such as <em>docker build</em> inside an Actions job wouldn’t know where to find it. The Docker client would try to connect to a local Docker daemon instead and fail because there isn’t one running inside the job container.</p><p>The Docker-in-Docker service is configured to use TLS. This means that a client certificate is required to establish a connection.</p><p>The Docker-in-Docker service generates these certificates in <em>/certs</em>, which we’ve mounted into both the docker and runner containers.</p><p>But remember that our Actions jobs run inside their own containers. They don’t automatically inherit the runner container’s filesystem.</p><p>That’s where the following configuration becomes important:</p><pre>container:<br>  network: &quot;host&quot;<br>  options: --volume /certs/client:/certs/client:ro --volume /workspace:/workspace<br>  valid_volumes:<br>    - &quot;/certs/client&quot;</pre><p>The <em>network: “host”</em> setting might look a bit odd at first. Don’t worry, it doesn’t mean that the Actions job is being attached directly to the physical host’s network.</p><p>Remember that the Forgejo Runner itself is running inside a container. From the perspective of the Actions job container, the runner is its host. The runner is attached to our forgejo-runner Docker Compose network, which is also where our Docker-in-Docker service lives.</p><p>Using <em>network: “host”</em> here therefore allows the job container to use the runner’s network environment, making it possible to reach our Docker-in-Docker service at docker:2376.</p><p>Being able to reach the Docker daemon isn’t enough, though. Since the connection uses TLS, the job also needs access to the client certificates we mentioned earlier.</p><p>The <strong>options</strong> setting tells the runner to mount <em>/certs/client</em> inside the Actions job container.</p><pre> options: --volume /certs/client:/certs/client:ro --volume /workspace:/workspace</pre><p>This makes the client certificates available inside the job container at /certs/client, which is the location we specified earlier using <strong>DOCKER_CERT_PATH</strong>. The :ro suffix mounts the certificates as read-only, since the job only needs to use them to establish the TLS connection.</p><p>The second mount makes /workspace available inside the job container. This is important for jobs that start their own Docker containers, as it gives those containers access to files from the shared workspace.</p><p>Finally, we explicitly allow both mounts using valid_volumes:</p><pre>valid_volumes:<br>  - &quot;/certs/client&quot;<br>  - &quot;/workspace&quot;</pre><p>The <strong>valid_volumes </strong>setting defines which host paths the runner is permitted to mount into job containers. In our case, we allow the TLS client certificates and the shared workspace used by our Actions jobs.</p><p>With this setup, the Forgejo Runner and Actions jobs can both use Docker without getting direct access to the Docker daemon of the physical host. Instead, the separate Docker-in-Docker daemon handles the containers used by our Actions jobs, with TLS securing the connections to it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fabda0bdaea0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting up smart shutters]]></title>
            <link>https://medium.com/@davidclaeys/setting-up-smart-shutters-21592a6cc0df?source=rss-f09a088813e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/21592a6cc0df</guid>
            <category><![CDATA[window-shutters]]></category>
            <category><![CDATA[zigbee2mqtt]]></category>
            <category><![CDATA[home-assistant]]></category>
            <dc:creator><![CDATA[David Claeys]]></dc:creator>
            <pubDate>Tue, 06 Oct 2026 15:11:42 GMT</pubDate>
            <atom:updated>2026-10-06T15:11:42.697Z</atom:updated>
            <content:encoded><![CDATA[<p>A while ago we bought our first house.<br>As many houses in Spain (and in a lot of European countries) it came with shutters.<br>Normally you’re supposed to just use a belt to raise and lower them.</p><p>Operating them manually isn’t the end of the world, but it does become a little annoying after a while.<br>In addition when being out for a couple of days, the shutters would just stay how you left them.<br>So people could easily see whether you were home or not. Not particularly secure, I would say.</p><p>For these two reasons we decided we wanted smart shutters.<br>For some reason information about shutters is not so readily available as I had hoped.<br>I suspect that’s because most of the content I consume is in English, and exterior shutters aren’t nearly as common in English-speaking countries.</p><p>Honestly I didn’t need this project to turn into a whole ordeal.I was more than happy to buy an off-the-shelf solution and call it a day.</p><p>However, I had a few requirements (yes, here we go again): I wanted local integration with Home Assistant and physical controls. If there was a cloud component, that was fine, as long as Home Assistant could still control the shutters when the internet connection was unavailable.</p><p>The first solution I looked at was Somfy. They’re one of the best-known manufacturers of motorized blinds and shutters, so they seemed like an obvious place to start.<br>They have a smart hub that connects to the cloud.<br>However, the smart hub uses a proprietary protocol to communicate with their motors and you’re only able to gather data from that hub through the cloud.<br>On top of that, it was expensive. I was quoted around €2,000 for the motors, hub, and switches alone.</p><p>I did some further research and found several shutter motors from Chinese manufacturers. These products are sold under a variety of brand names and can be found on popular online marketplaces as well as through some major retailers.<br>However, the smart functionality is typically based on the Tuya ecosystem, often requiring the use of a vendor-specific app.<br>The whole setup felt like a security nightmare. It would have required installing an app from a manufacturer I had never heard of and connecting a device from that same vendor to my home Wi‑Fi network.<br>Since these devices appear to be Tuya-based, I could probably have integrated them with Home Assistant through <a href="https://github.com/make-all/tuya-local">Tuya Local</a> .<br>However, that would have been an entire project in its own right, with no guarantee of success.<br>It was a level of effort and risk I wasn’t willing to take.</p><p>My next discovery was that they sold some relay modules that were intended to drive shutter motors.<br>They’re a bit difficult to find, but they sell shutter motors that only include power and control wires.<br>Normally they’re intended to be hooked up to a wall switch, but it was perfectly feasible to hook a relay module into it.<br>However, the installation could be a bit tricky. European wall boxes aren’t that deep and fitting a wall switch and a relay module seemed a bit difficult.</p><p>Right at that time SONOFF launched their Fusion Series.<br>It is a whole set of wall switches paired with relay modules.<br>This article is not sponsored so later on you’ll hear my complaints about the product line, but I have to admit it pretty much solved the physical installation part.<br>The product line includes the SONOFF Fusion Series Orb-ZBRBS which is a wall plate together with a Zigbee module. Pretty much the dream setup.</p><p>So I went ahead and bought the smart relays and the shutter motors.<br>At this point I had seen some videos on the internet, but they were with other products.<br>It took quite some effort to convince my electrician (who also happens to be my father) that this was a feasible approach. Most shutter installations are just a wall switch connected directly to the motor, so the idea of mixing a motor, a smart relay and a wall plate seemed quite daunting at first.</p><p>The installation process isn’t that complicated, but it’s messy. Here I have a gripe with house builders: is it really that difficult to run a power cable near the windows? Does it really save that much money?</p><p>Thanks to that rather questionable design decision, we had to open sections of the ceiling in order to route power cables from the electrical cabinet to each window. Once the wiring was in place, connecting the smart relays to the motors was actually fairly straightforward.<br>We were lucky because our house uses drywall instead of brick, which is common in many houses here. Dealing with drywall creates enough dust already; I can’t imagine how much more disruptive this project would have been with traditional brick walls.</p><p>Although the relay itself is a Zigbee device, SONOFF seems very keen on directing customers towards their own application. I had to do a bit of digging online before I found the pairing instructions.<br>Once paired with <a href="https://github.com/Koenkk/zigbee2mqtt">Zigbee2MQTT</a>, however, everything worked exactly as I had hoped. The shutters appeared in Home Assistant and from that point on I was free to build whatever automations I wanted.</p><p>After a couple of months living with the solution, I’ve developed a few opinions.<br>But before I get to the complaints, I should mention that I’m generally very happy with the result. The system works exactly as intended and has been completely reliable.</p><p>My first gripe has to do with the physical format SONOFF chose for the Fusion Series. In many ways, they have the perfect product, but for some reason they decided not to follow standard European wall switch dimensions.</p><p>I understand why they chose this design. The round button assembly aligns directly with the contact pins on the relay module. If a more traditional square design had been used, there would be a much greater risk of the button not making proper contact with the relay when pressed.<br>Even so, it would probably have been possible to offer an adapter plate that allows the round Fusion mechanism to be used with standard European wall switch frames.<br>Doing so would have made the product significantly more flexible and far easier to integrate into existing installations.<br>If you want to combine a Fusion switch with a traditional light switch in the same frame, you’re largely out of luck.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*twpPKTu85yebEnTM05PlBg.png" /></figure><p>They even provide a list of compatible frames and 3D models on their website. A whole list of manufacturers, a whole list of products… but which one is supposed to be the standard? Your guess is as good as mine.<br>And is it really that difficult to sell a few frames that let you combine standard wall switches with the Fusion Series?</p><p>My second complaint concerns the reported shutter position. According to discussions on the SONOFF forums, I am far from the only person experiencing this problem.<br>The reported position simply doesn’t make sense. Even after performing the calibration procedure multiple times, the values remain inaccurate. For example, setting a shutter to 30% openness often results in something much closer to 60% in reality.<br>For something that should be a fairly basic feature, it is surprisingly unreliable. Months later, it still hasn’t been properly resolved.</p><p>My final complaint concerns the physical controls themselves.<br>While they generally work, they can be surprisingly finicky. More often than I would like, pressing a button doesn’t immediately trigger any action and I need to press it a second time before the shutter responds.</p><p>Would I choose the same product again?</p><p>I’m annoyed to say that I probably would.</p><p>For all my complaints, I still haven’t found another solution that solves the physical installation problem this well. The hardware is solid, Zigbee2MQTT integration works nicely, and Home Assistant has no trouble controlling the shutters.</p><p>You’ll just have to accept a few quirks along the way. You’ll need to live with double frames and SONOFF’s custom switch format, unless SONOFF suddenly decides to embrace standard European wall switch dimensions, of course.</p><p>As an added bonus, here’s an example of how I ended up automating the shutters in Home Assistant.</p><pre>alias: Shutter automation<br>triggers:<br>  - trigger: sun<br>    event: sunrise<br>    offset: 0<br>  - trigger: time<br>    at: &#39;08:30:00&#39;<br>  - trigger: sun<br>    event: sunset<br>    offset: &#39;0:10:0&#39;<br>conditions:<br>  - condition: or<br>    conditions:<br>      - condition: and<br>        conditions:<br>          - condition: sun<br>            after: sunrise<br>          - condition: time<br>            after: &#39;08:30:00&#39;<br>      - condition: sun<br>        after: sunset<br>actions:<br>  - choose:<br>      - conditions:<br>          - condition: and<br>            conditions:<br>              - condition: sun<br>                after: sunrise<br>              - condition: sun<br>                before: sunset<br>        sequence:<br>          - action: cover.open_cover<br>            metadata: {}<br>            data: {}<br>            target:<br>              entity_id: cover.shutter<br>      - conditions:<br>          - condition: sun<br>            after: sunset<br>        sequence:<br>          - action: cover.close_cover<br>            metadata: {}<br>            data: {}<br>            target:<br>              entity_id: cover.shutter<br>mode: single</pre><p>This automation does two simple things.</p><p>The shutters will only open after sunrise if it is already past 08:30. During the summer, sunrise can happen surprisingly early, and neither of us enjoys being woken up at six in the morning by a room suddenly filling with sunlight.</p><p>In the evening, the shutters close automatically ten minutes after sunset. This provides a bit more privacy, and makes the house appear occupied even when we’re away for a couple of days.</p><p>I’m quite surprised that figuring this out took me this much work.<br>I expected to find generic solutions all over the place, but I found mostly expensive and proprietary solutions.<br>Luckily I’ve managed to find a solution that just works.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=21592a6cc0df" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Selfhosted Live TV the easy way]]></title>
            <link>https://medium.com/@davidclaeys/selfhosted-live-tv-the-easy-way-bda2fce4ed39?source=rss-f09a088813e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/bda2fce4ed39</guid>
            <category><![CDATA[dispatcharr]]></category>
            <category><![CDATA[jellyfin]]></category>
            <category><![CDATA[epg]]></category>
            <dc:creator><![CDATA[David Claeys]]></dc:creator>
            <pubDate>Tue, 22 Sep 2026 15:01:04 GMT</pubDate>
            <atom:updated>2026-09-22T15:01:04.536Z</atom:updated>
            <content:encoded><![CDATA[<p>A while ago I made a <a href="https://medium.com/@davidclaeys/watching-live-tv-on-all-your-devices-a8141c3a35c6">post</a> about setting up Live TV.</p><p>Since then, a couple of things have changed:</p><ul><li>setting up EPG has become much easier</li><li>Threadfin has been abandoned and basic functionality isn’t there anymore</li><li>I’ve learned from my mistakes and discovered some new interesting things</li></ul><p>Before getting started, I feel obliged to include the following disclaimer :<br><em>This article describes a technical setup for aggregating and managing television streams. It is not intended to encourage piracy or circumvent licensing restrictions.</em></p><h3><strong>Getting icons for channels</strong></h3><p>One of the things that bothered me is that not all IPTV providers supply up-to-date channel icons or any icons at all.<br>For that I found the <a href="https://github.com/tv-logo/tv-logos">tv logos</a>.<br>It provides free, high-quality logos for thousands of television channels from around the world.</p><h3><strong>EPG</strong></h3><h4><strong>Existing EPG sources</strong></h4><p>If you live in Spain, <a href="https://github.com/davidmuma/EPG_dobleM">dobleM </a>is amazing.<br>It provides EPG information for nearly all television channels available in Spain.</p><p>There are also several other EPG providers available. Some are free, while others require a subscription.<br>For example <a href="https://www.open-epg.com/app/index.php">Open EPG</a> seems to provide information for a whole lot of channels.</p><h4><strong>EPG grabber</strong></h4><p>You can also set up your own EPG grabber. This <a href="https://medium.com/@davidclaeys/epg-the-easy-way-2763d4686ae0">article</a> explains it well.</p><p>Since writing that article, I have stopped maintaining the custom fixes, so I recommend leaving them disabled.</p><p>It boils down to this:</p><pre>version: &#39;3.3&#39;<br>services:<br>  epg:<br>    image: git.claeyscloud.com/david/epg-info:latest<br>    #image: ghcr.io/davidclaeysquinones/epg-info:latest<br>    #image: davidquinonescl/epg-info:latest<br>    #image: lavaforge.org/davidquinonescl/epg-info:latest<br>    volumes:<br>      # add a mapping in order to add the channels file<br>      - /docker/epg:/config<br>    ports:<br>      - 6080:3000<br>    environment:<br>      # specify the time zone for the server<br>      - TZ=Etc/UTC<br>    restart: unless-stopped</pre><p>These are some providers you could use:</p><ul><li><a href="https://github.com/iptv-org/epg/tree/master/sites/telenet.tv">telenet.tv</a> (Belgium)</li><li><a href="https://github.com/iptv-org/epg/tree/master/sites/pickx.be">pickx.be</a> (Belgium)</li><li><a href="https://github.com/iptv-org/epg/tree/master/sites/orangetv.orange.es">orangetv.orange.es</a> (Spain)</li><li><a href="https://github.com/iptv-org/epg/tree/master/sites/tvgids.nl">tvgids.nl</a> (Netherlands)</li><li><a href="https://github.com/iptv-org/epg/tree/master/sites/tv24.co.uk">tv24.co.uk</a> (UK)</li><li><a href="https://github.com/iptv-org/epg/tree/master/sites/tvtv.us">tvtv.us</a> (US)</li><li><a href="https://github.com/iptv-org/epg/tree/master/sites/chaines-tv.orange.fr">chaines-tv.orange.fr</a> (France)</li></ul><h3><strong>Setting up Live TV</strong></h3><p>Setting up Live TV can be done in many ways.</p><p>At a high level, every Live TV setup consists of two components: a frontend (the user interface) and a backend (the TV source and management layer).</p><p>There are many UIs available, such as: <a href="https://github.com/jellyfin/jellyfin">Jellyfin</a>, <a href="https://www.plex.tv/">Plex</a>, <a href="https://emby.media/">Emby</a> and so on.</p><p>Each UI has its own advantages and disadvantages, but comparing them is outside the scope of this article. In this guide we will use Jellyfin as the user interface.</p><p>There are also many backends available: <a href="https://github.com/Dispatcharr/Dispatcharr">Dispatcharr </a>, <a href="https://github.com/Threadfin/Threadfin">Threadfin</a>, <a href="https://github.com/xteve-project/xTeVe">xTeVe</a> , <a href="https://github.com/carlreid/StreamMaster">StreamMaster </a>and so on.</p><p>At the time of writing, most of these backends are either abandoned, lightly maintained, or in an uncertain state. Dispatcharr is currently the only option I can confidently recommend. While you can choose almost any frontend you like, Dispatcharr is currently the only backend I would recommend.</p><p>Depending on your IPTV provider and local regulations, you may want to route Dispatcharr through a VPN. In my setup I use <a href="https://github.com/passteque/gluetun">Gluetun </a>together with Mullvad.</p><p>Your compose stack should look like this :</p><pre>version: &quot;3.5&quot;<br>services:<br>  jellyfin:<br>    image: linuxserver/jellyfin:latest<br>    network_mode: host<br>    volumes:<br>      - /docker/jellyfin/jellyfin/config:/config<br>      - /docker/jellyfin/jellyfin/cache:/cache<br>      # add this volume mapping in order to enable recordings<br>      - /Recordings:/recordings<br>    restart: unless-stopped<br>    environment:<br>      - PUID=${PUID}<br>      - PGID=${PGID}<br>      - JELLYFIN_PublishedServerUrl=#your jellyfin URL#<br>    devices:<br>      - /dev/dri:/dev/dri<br>  vpn:<br>    image: qmcgaw/gluetun<br>    healthcheck:<br>      test: wget -O - https://am.i.mullvad.net/connected | grep -q &quot;You are connected&quot;<br>    cap_add:<br>      - NET_ADMIN<br>    devices:<br>      - /dev/net/tun:/dev/net/tun<br>    sysctls:<br>      - net.ipv6.conf.all.disable_ipv6=0<br>    environment:<br>      - TZ=${TIME_ZONE}<br>      # example setup for mullvad, have a look at https://github.com/qdm12/gluetun-wiki/tree/main/setup/providers to see all available providers<br>      - VPN_SERVICE_PROVIDER=mullvad<br>      - VPN_TYPE=wireguard<br>      - WIREGUARD_PRIVATE_KEY=${VPN_PRIVATE_KEY}<br>      - WIREGUARD_ADDRESSES=10.67.83.197/32<br>      - SERVER_CITIES=${VPN_CITY}<br>      # adapt this value according to your network topology<br>      - FIREWALL_OUTBOUND_SUBNETS=192.168.0.0/24<br>      - DNS_UPSTREAM_RESOLVER_TYPE=doh<br>      - DNS_UPSTREAM_RESOLVERS=cloudflare<br>    ports:<br>      #dispatcharr<br>      - 9191:9191<br>    volumes:<br>      - /docker/jellyfin/vpn:/config<br>    restart: unless-stopped<br>  dispatcharr:<br>    image: ghcr.io/dispatcharr/dispatcharr:latest<br>    network_mode: service:vpn<br>    volumes:<br>      - /docker/jellyfin/dispatcharr:/data<br>    environment:<br>      - DISPATCHARR_ENV=aio<br>      - REDIS_HOST=localhost<br>      - CELERY_BROKER_URL=redis://localhost:6379/0<br>      - DISPATCHARR_LOG_LEVEL=info<br>    cap_add:<br>      - SYS_NICE<br>    devices:<br>      # this is used for Intel/AMD GPU acceleration (VA-API)<br>      - /dev/dri:/dev/dri</pre><p>And you should provide values for the following variables :</p><ul><li>TIME_ZONE</li><li>VPN_PRIVATE_KEY</li><li>VPN_CITY</li><li>PUID=1000</li><li>PGID=1000</li></ul><h4><strong>Setting up Dispatcharr</strong></h4><p><em>TL;DR:<br></em>Dispatcharr sits between your TV provider(s) and Jellyfin. It lets you manage channel numbering, assign logos, match EPG data, filter unwanted channels, and combine multiple sources into a single, clean TV lineup that can be consumed by the frontend of your choice.</p><p><strong>Setting up M3U</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/352/1*xSohGZDbo8jCIxdDokwMrA.png" /><figcaption>Menu bar</figcaption></figure><p>First, open the <strong>M3U &amp; EPG Manager</strong> from the menu bar.</p><p>After that click the <em>Add M3U</em> button and a popup should appear.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*grpKA7sDn2nANcD0HcWKKA.png" /><figcaption>M3U popup</figcaption></figure><p>Here you’re supposed to enter a M3U playlist or Xtream user credentials.<br>Acquiring a playlist is usually the most challenging part of the setup.<br>Depending on where you live, legitimate IPTV providers may be available or in other cases you might need to sail the seven seas.<br>Another option is to receive DVB-T or DVB-S broadcasts and redistribute them through TvHeadend.<br>That’s a topic on its own, but be aware that in some places it’s a perfectly reasonable option.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5kNckqVP3s6wegLf3JhFIg.png" /><figcaption>Group filter</figcaption></figure><p>Normally you will be asked to select which groups you want to include.<br>Some providers offer thousands of channels. Filtering them here reduces clutter, simplifies channel management, and can improve performance.</p><p><strong>Setting up EPG</strong></p><p>We’re still in the <strong>M3U &amp; EPG Manager</strong> and this time we’re going to click <em>Add EPG &gt; Standard EPG Source</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dlhs4JO52QQmr9dQBUHfkg.png" /><figcaption>EPG source popup</figcaption></figure><p>Give the source a descriptive <em>name</em> and enter the <em>URL</em> of your chosen EPG feed.</p><p><strong>Matching channels</strong></p><p>At this point we have added channel and EPG sources, but Dispatcharr is not yet publishing any channels.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/367/1*ETFw7I_jP8pJC3Fx9x3dHg.png" /><figcaption>Menu bar</figcaption></figure><p>To do that, open <strong>Channels</strong> from the menu bar.</p><p>The interface may look a little intimidating at first, but the workflow is actually quite straightforward.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kOzXkEVeeC1qgZfx2tjMow.png" /><figcaption>Channels</figcaption></figure><p>When you open this for the first time, the left half will be empty, which is normal because this section shows the channels that are being published by Dispatcharr.</p><p>If you’ve added a playlist in the previous steps, its channels should appear on the right side of the screen.</p><p>Looking more closely, you’ll notice that each channel has a <strong>Create New Channel</strong> button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/211/1*cDgfXMES5ZFfIYftNoUBtQ.png" /><figcaption>Create New Channel button</figcaption></figure><p>When you click that button, the following dialog will appear.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*FgFJiMDfeFEWpxdLxvK4Bg.png" /><figcaption>Create New Channel dialog</figcaption></figure><p>I usually select <strong>Use Specific Number</strong> and assign a channel number myself. This number determines the order in which channels will appear later in Jellyfin, making it easy to create a lineup that matches your preferences.</p><p>Normally, a channel should now appear on the left side of the screen. This means the channel has been added to your output lineup and will be exposed to Jellyfin through Dispatcharr.<br>At this stage, however, the channel information is still fairly limited. The channel does not yet have an EPG source assigned, a logo configured, or a channel group associated with it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f6CYGxHxaf0e7D2NC_ZbKg.png" /><figcaption>Created channel</figcaption></figure><p>We need to click the <strong>Edit</strong> button for the newly created channel.</p><p>This opens the channel configuration dialog.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RN0ZKqxeIZmAcnkiCPvZwQ.png" /><figcaption>Edit channel dialog</figcaption></figure><p>From here, the process is fairly straightforward:</p><ul><li>Adjust the channel name if necessary</li><li>Assign the channel to a group</li><li>Configure a channel logo</li><li>Select the appropriate EPG entry</li></ul><p>Once you’re happy with the configuration, save the channel and repeat the process for any other channels you want to make available.</p><p><strong>Setting the M3U Hash Key</strong></p><p>This step is not strictly necessary, but it’s a setting I learned about the hard way.</p><p>For a long time, I experienced channels randomly becoming unavailable every couple of hours. This meant I had to rematch channels multiple times a day.</p><p>After more troubleshooting than I’d like to admit, I discovered that changing the M3U hash key can solve these issues.</p><p>You can find this setting under <strong>Settings &gt; Stream Settings</strong>.</p><p>You can set it to whatever works best for your provider. In my case, I use <strong>TVG-ID + Group</strong>, which has proven to be stable and prevents the need to rematch every time the playlist is refreshed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5whLCLjkSMo03kbyrPmEJg.png" /><figcaption>Stream Settings</figcaption></figure><p><strong>Setting up Stream and Output profiles</strong></p><p>Under <strong>Settings</strong>, you’ll find both <strong>Stream Profiles</strong> and <strong>Output Profiles</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/370/1*Brw8abJk8XIgpoFXveJ9cQ.png" /><figcaption>Stream profiles and output profiles in settings</figcaption></figure><p>My understanding is that Stream Profiles mainly control how the video stream is processed and transmitted, while Output Profiles affect the audio format.</p><p>There is a lot more to these settings than I cover here, but for most users it is enough to know that they can have a significant impact on compatibility and playback stability.</p><p>Again, this is not strictly necessary, but if you want smooth video playback, you’ll definitely want to choose profiles that work well with your clients. Some clients can be a bit picky about which formats they are willing to play.</p><p><strong>Stream profiles</strong></p><p>The stream profile I’m going to provide is not of my own making. It originally came with the <em>Embyfin Stream Cleanup</em> plugin. However, at the time of writing, that plugin appears to have been deprecated. The profile itself has been a lifesaver, though.</p><p>The stream profile is called <em>Jellyfin-built-in</em> and uses FFmpeg.</p><pre>-user_agent {userAgent} -i {streamUrl} -c:v h264_qsv -b:v 3000k -c:a aac -b:a 128k -ac 2 -ar 48000 -f mpegts pipe:1</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*ON1xQE1s1p21unosftLINg.png" /></figure><p><strong>Output profiles</strong></p><p>Now let’s look at Output Profiles.</p><p>The profile I’m going to provide is the result of issues I encountered with streams coming from TvHeadend. Some channels expose multiple audio tracks, for example different languages, and that’s not something Jellyfin always handles particularly well.</p><p>You might sit down expecting Spanish dubbing, only to discover that the channel is playing the original audio track instead. Some people may prefer that, but it wasn’t the experience I wanted for my users.</p><p>The output profile is called mp3 and uses FFmpeg behind the scenes:</p><pre>-fflags +discardcorrupt+genpts+nobuffer -probesize 512K -analyzeduration 0 -i pipe:0 -map 0:v -map 0:a:1? -map 0:a:0? -c:v copy -c:a mp3 -b:a 192k -ac 2 -af aresample=async=100:min_hard_comp=0.100:first_pts=0 -muxdelay 1 -muxpreload 1 -f mpegts pipe:1</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/654/1*_s2lq63w5HqxVeHlmSAX8A.png" /><figcaption>MP3 output profile</figcaption></figure><p>The important part here is:</p><pre>-map 0:a:1? -map 0:a:0?</pre><p>These parameters tell FFmpeg which audio stream should be used. FFmpeg will first attempt to use audio stream 1. If that stream does not exist, it will automatically fall back to audio stream 0.</p><p>Whether this solves your problem depends entirely on how the source stream is structured. Your provider might only expose a single audio track, or the available tracks may appear in a completely different order.</p><p>The important takeaway is not the exact values I use, but understanding that FFmpeg allows you to explicitly select a preferred audio track and define fallback behaviour when multiple tracks are available.</p><p><strong>Tying everything together</strong></p><p>As a final step, I recommend setting these profiles as the defaults. Later on I’ll show how individual profiles can be selected for specific channels, but having sensible defaults is a good starting point.</p><p>We’ll want to return to the <strong>Stream Settings</strong> page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5whLCLjkSMo03kbyrPmEJg.png" /><figcaption>Stream Settings</figcaption></figure><p>This time we want to adjust the <strong>Default Stream Profile</strong> and <strong>Default Output Profile</strong> to the profiles we configured earlier.</p><p>Doing so ensures that, when we later add Dispatcharr as a Live TV source in Jellyfin, Jellyfin will consume the channels using these output profiles.</p><h4><strong>Setting up Jellyfin</strong></h4><p>Honestly, Jellyfin is a world of its own. This article is already getting quite long, and there are thousands of guides available that explain the basics of setting up Jellyfin.</p><p>Instead of covering Jellyfin in detail, I’ll focus on the part that matters for this guide: connecting Jellyfin to Dispatcharr.</p><p>You’ll want to log in with an administrator account and open the administrator dashboard.</p><p>It is available through the user profile dropdown.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/334/1*s0QF8PJMYrZyzj2o5_9FRw.png" /><figcaption>User profile dropdown</figcaption></figure><p>On the left navigation panel you’ll notice the Live TV section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/367/1*vqluIKd_AqNSNwpHWrNtPw.png" /><figcaption>Live TV section</figcaption></figure><p>Open the Live TV section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/699/1*PmZ79pHz30wG9OqwojbLOQ.png" /><figcaption>Jellyfin Live TV config</figcaption></figure><p>The first time you open this page, it will be empty.</p><p>You’ll want to return to Dispatcharr to the <strong>Channels</strong> page.</p><p>On top of the page you’ll notice <em>HDHR</em> and <em>EP</em>G.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*ovqYjoQWSF1-Rl2TExOFQA.png" /><figcaption>HDHomeRun export</figcaption></figure><p>You can see that an Output Profile can be selected. Normally, the System Default profile is used, but you can override it if needed.</p><p>Click on the Copy button in order to have our URL ready to be pasted into Jellyfin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/733/1*gM_fgX43IuBZEstfZP1v4w.png" /><figcaption>EPG export</figcaption></figure><p>Return to jellyfin and click <strong>Add Tuner Device</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RJGl7Owq6g4-I7mkbPELDQ.png" /><figcaption>Tuner Setup</figcaption></figure><p>Choose HD HomeRun as tuner type and paste the URL from Dispatcharr in the <em>Tuner IP Address</em> field. Also check the <em>Allow hardware transcoding</em> box in order to have smooth playback on all your devices.</p><p>For the EPG, click the <strong>Add Provider</strong> button</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/1*XFyEamSSHU7e_FeJhOLwmQ.png" /><figcaption>Add Provider dropdown</figcaption></figure><p>Choose XMLTV and the following dialog will appear.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OS4LADWMV2OYFTeEqdLMMQ.png" /><figcaption>XMLTV Setup</figcaption></figure><p>Paste the EPG URL from Dispatcharr into the <em>File or URL</em> field.</p><p>Click Save and you’re done.</p><p>If everything went as planned, your TV guide should look similar to this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ujLLac5u-E-p2ByAXlcrGw.png" /><figcaption>Tv guide</figcaption></figure><p>There are still a lot of things we could cover, such as recordings, series recording schedules, EPG categories, but those topics are outside the scope of this article.</p><p>For now we’ve got functional Live TV through Jellyfin.</p><h4><strong>Conclusion</strong></h4><p>At this point we’ve successfully set up Live TV that is accessible from all our devices.</p><p>No more dependence on apps from your TV provider that insist on collecting telemetry along the way. ;)</p><p>We’ve done a great deal of work, but we’ve only scratched the surface. Some topics I briefly touched on, such as receiving and distributing your own DVB signals, require very specific hardware, knowledge, and often region-specific considerations.</p><p>Still, we’ve built a solid foundation. With Dispatcharr handling channel management and Jellyfin acting as the frontend, we now have a flexible, self-hosted Live TV platform that can be expanded and refined over time.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bda2fce4ed39" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Blogging as a self hoster]]></title>
            <link>https://medium.com/@davidclaeys/blogging-as-a-self-hoster-5cdcf437475a?source=rss-f09a088813e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/5cdcf437475a</guid>
            <category><![CDATA[self-hosted]]></category>
            <category><![CDATA[blogging]]></category>
            <dc:creator><![CDATA[David Claeys]]></dc:creator>
            <pubDate>Thu, 10 Sep 2026 13:58:41 GMT</pubDate>
            <atom:updated>2026-09-10T13:58:41.251Z</atom:updated>
            <content:encoded><![CDATA[<p>For most people, blogging is simply a matter of creating content.</p><p>And to be clear, creating high-quality content is no easy task.</p><p>That’s exactly how I started. I created a WordPress blog, tweaked the design to my liking, and began writing.</p><p>However, a lot of time has passed since then. I’ve gained a few kilos, lost a bit of hair, and somehow ended up deep in the self-hosting rabbit hole.</p><p>For a while, I self-hosted my blog using WriteFreely while mirroring my articles to Medium. I would write everything in Markdown on WriteFreely and then manually adapt each article on Medium to achieve a reasonably decent layout.</p><p>This setup worked well enough. I owned my content and had a place to publish it, while Medium helped new readers discover my articles.</p><p>When I started the blog, I intended to write concise articles. That’s how I ended up choosing WriteFreely.</p><p>However, as time passed, I noticed that my articles weren’t nearly as short as I had expected. As I published more and more content, browsing the blog became increasingly difficult.</p><p>For a long time I searched for alternatives that would suit my needs.</p><p>The platform had to be self-hosted, have a modern design, and support Markdown.</p><p>Markdown is the format that WriteFreely uses. At first, I saw it as a limitation, but over time I realized it was actually one of its greatest strengths. Markdown is simple, portable, and non-proprietary. Unlike content locked away in a database or a proprietary editor, a Markdown file can be opened, edited, and migrated almost anywhere.</p><p>As a self-hoster, that realization became increasingly important to me. I didn’t just want to own the platform that hosted my content; I wanted my content to be platform-agnostic and independent of any particular piece of software.</p><p>As a content creator, I had another issue: WriteFreely didn’t provide any analytics.</p><p>Don’t worry, I wasn’t planning to become the next advertising giant. Still, after spending several hours writing an article, it’s nice to know whether it was read by hundreds of people or just by a few friends and a couple of search engine bots.</p><p>That’s how I ended up with <a href="https://github.com/tryghost/ghost">Ghost</a> and <a href="https://github.com/umami-software/umami)">Umami</a>.</p><p>Yes, Ghost offers a native integration with <a href="https://www.tinybird.co/">Tinybird</a>, but Tinybird is not open source and requires significantly more resources than I was willing to dedicate to a personal blog.</p><p>Umami, on the other hand, is lightweight, open source, and easy to deploy. After tweaking a few settings in Ghost (Code Injection), I had self-hosted analytics up and running in just a few minutes.</p><p>For the curious, this is what my Docker Compose stack looks like:</p><pre>services:<br>  ghost:<br>    image: ghost:latest<br>    restart: unless-stopped<br>    ports:<br>      - &quot;2368:2368&quot;<br>    environment:<br>      url: https://blog.example.com<br>      database__client: mysql<br>      database__connection__host: db<br>      database__connection__user: ${MYSQL_USER}<br>      database__connection__password: ${MYSQL_PASSWORD}<br>      database__connection__database: ${MYSQL_DATABASE}<br>      security__staffDeviceVerification: &quot;false&quot;<br>    volumes:<br>      - /docker/ghost/content:/var/lib/ghost/content<br>    depends_on:<br>      - db<br>  db:<br>    image: mysql:8<br>    restart: unless-stopped<br>    environment:<br>      MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}<br>      MYSQL_DATABASE: ${MYSQL_DATABASE}<br>      MYSQL_USER: ${MYSQL_USER}<br>      MYSQL_PASSWORD: ${MYSQL_PASSWORD}<br>    volumes:<br>      - /docker/ghost/db:/var/lib/mysql<br>  umami:<br>    image: docker.umami.is/umami-software/umami:latest<br>    restart: unless-stopped<br>    depends_on:<br>      - postgres<br>    environment:<br>      DATABASE_URL: postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}<br>    ports:<br>      - &quot;3085:3000&quot;<br>  postgres:<br>    image: postgres:16<br>    restart: unless-stopped<br>    environment:<br>      POSTGRES_DB: ${POSTGRES_DB}<br>      POSTGRES_USER: ${POSTGRES_USER}<br>      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}<br>    volumes:<br>      - /docker/ghost/umami:/var/lib/postgresql/data</pre><p>At this point, I had the software stack figured out. All that remained was “just” migrating from WriteFreely to Ghost.</p><p>Initially, copying the Markdown from one platform to the other seemed perfectly reasonable. After all, I only had a handful of articles.</p><p>A few articles later, the process started to become rather cumbersome, and I came to a somewhat uncomfortable realization.</p><p>If I got rid of WriteFreely, I would lose access to the original Markdown version of my articles. Ghost allows Markdown to be imported, but once an article is converted into Ghost’s editor format, there is no straightforward way to export it back to Markdown.</p><p>Suddenly, the format that I had come to appreciate for its portability was at risk of being replaced by content stored inside a CMS. While I would still own the platform, I would no longer have a convenient, platform-agnostic copy of my work.</p><p>That’s how I landed on my current setup: I write all my articles in Markdown and store them in a Git repository. From there, I can import or publish them to whichever platform I choose.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/1*32vGMYwRpxvYp66MRMjK9w.png" /><figcaption><em>Screenshot of my git repository structure*</em></figcaption></figure><p>For Ghost, it’s as simple as copying and pasting the Markdown into the editor. Medium is a little more involved, but the important part is that my content remains independent of any particular platform.</p><p>Whether I use Ghost, Medium, WriteFreely, or something else in the future, I still own the original source. My articles live as Markdown files under version control, while publishing platforms become little more than presentation layers.</p><p>Applications will come and go, but my content remains mine.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5cdcf437475a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to host your code: methods and philosophy]]></title>
            <link>https://medium.com/@davidclaeys/how-to-host-your-code-methods-and-philosophy-56f7dccb5b05?source=rss-f09a088813e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/56f7dccb5b05</guid>
            <category><![CDATA[selfhost]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[David Claeys]]></dc:creator>
            <pubDate>Wed, 11 Mar 2026 11:48:06 GMT</pubDate>
            <atom:updated>2026-03-11T11:48:06.934Z</atom:updated>
            <content:encoded><![CDATA[<p>When reading the title you might think that the answer is pretty obvious: you just put your code repositories in <a href="https://github.com/">GitHub</a> and that’s it.</p><p>However, when you think about what happened to <a href="https://github.com/schlagmichdoch/PairDrop">PairDrop</a> or <a href="https://github.com/spotizerr-dev/spotizerr">spotizerr</a> it becomes obvious that the answer is not so simple.<br>On one hand you want to put your code in a place that is easy to reach and where your project will have exposure.<br>On the other you don’t want to rely on Big Tech to determine the future of your project.<br>One false positive from an AI tool or one malicious DMCA request and all your hard work can just disappear.<br>Unless your project has a big audience, nobody at Big Tech will listen to you and even then it can take weeks or months until everything comes back to normal.</p><h3>Mitigating risks</h3><p>How do you mitigate this risk?<br>The answer is self-hosting, before you draw the conclusion that such a thing is not feasible hear me out!</p><p>Everyone who is into self-hosting knows that it comes with its set of challenges.</p><p>By example your own domain will never have the exposure of GitHub. So you might think that self-hosting your code will reduce the exposure and viability of your project.<br>Luckily such a thing as a push mirror exists! <br>This means the following : first you commit your code on your self-hosted repository and then automatically the code gets pushed to another git repository. The mirror repositories can be hosted on any platform you want, like GitHub.<br>This way you still have the exposure you want while your code is under your control.</p><p>Another challenge associated with self-hosting is managing security.<br>If you don’t want to take any risk you don’t have to expose your self-hosted instance to the public.<br>You just put the software locally and setup a push mirror to a provider that’s publicly available, job done.<br>Although with tools like <a href="https://github.com/fosrl/pangolin">pangolin</a> exposing self-hosted services has become a breeze.</p><p>Maybe the last challenge is choosing the right software but that’s what we are for.</p><h3>Choosing the right software</h3><p>Basically there are two options : <a href="https://github.com/go-gitea/gitea">gitea</a> and <a href="https://codeberg.org/forgejo/forgejo">forgejo</a>. Personally, I use gitea so, this article only will include examples for that software. However due to the actions of the company behind it I would recommend to have a look at forgejo if you’re starting out. Someday I will make the switch, but for now I’m holding out on that pending transition.</p><h3>Build actions</h3><p>Gitea provides a run agent that is very similar to GitHub actions. However there are some differences that need to be worked around.</p><h4>Install docker</h4><p>By default the gitea runner doesn’t have Docker installed, in order to be able to do anything with Docker you need to install it yourself.</p><p>This can be done in the following way :</p><pre>- name: Install Docker<br> run: |<br> echo &quot;Checking docker installation&quot;<br> if command -v docker &amp;&gt; /dev/null; then<br> echo &quot;Docker installation found&quot;<br> else<br> echo &quot;Docker installation not found. Docker will be installed&quot;<br> curl -fsSL https://get.docker.com | sh<br> fi</pre><h4>Update docker hub description</h4><p>There is <a href="https://github.com/peter-evans/dockerhub-description">this</a> action that enables you to automatically update descriptions on docker hub. However it requires some extra dependencies to be installed.</p><pre>- name: Install npm dependencies<br> run: |<br> echo &quot;Installing fetch&quot;<br> install_node=$false<br> if ! command -v node &amp;&gt; /dev/null; then<br> echo &quot;No version of NodeJS detected&quot;<br> install_node=true<br> else<br> node_version=$(node -v)<br> node_version=${node_version:1} # Remove &#39;v&#39; at the beginning<br> node_version=${node_version%\.*} # Remove trailing &quot;.*&quot;.<br> node_version=${node_version%\.*} # Remove trailing &quot;.*&quot;.<br> node_version=$(($node_version)) # Convert the NodeJS version number from a string to an integer.<br> if [ $node_version -lt 24 ]; then<br> echo &quot;node version : &quot; $node_version <br> echo $&quot;removing outdated npm version&quot;<br> install_node=true<br> apt-get update<br> apt-get remove nodejs npm<br> apt-get purge nodejs<br> rm -rf /usr/local/bin/npm <br> rm -rf /usr/local/share/man/man1/node* <br> rm -rf /usr/local/lib/dtrace/node.d <br> rm -rf ~/.npm <br> rm -rf ~/.node-gyp <br> rm -rf /opt/local/bin/node <br> rm -rf opt/local/include/node <br> rm -rf /opt/local/lib/node_modules <br> rm -rf /usr/local/lib/node*<br> rm -rf /usr/local/include/node*<br> rm -rf /usr/local/bin/node*<br> fi<br> fi<br>if $install_node; then<br> NODE_MAJOR=24<br> echo &quot;Installing node ${NODE_MAJOR}&quot;<br> if test -f /etc/apt/keyrings/nodesource.gpg; then<br> rm /etc/apt/keyrings/nodesource.gpg<br> fi<br> if test -f /etc/apt/sources.list.d/nodesource.list; then<br> rm /etc/apt/sources.list.d/nodesource.list<br> fi<br> apt-get update<br> apt-get install -y -q ca-certificates curl gnupg<br> mkdir -p /etc/apt/keyrings<br> curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg - dearmor -o /etc/apt/keyrings/nodesource.gpg<br> echo &quot;deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_${NODE_MAJOR}.x nodistro main&quot; | tee /etc/apt/sources.list.d/nodesource.list<br> apt-get update<br> apt-get install -y -q nodejs<br> npm install npm - global<br> fi<br>echo &quot;node version : &quot; $(node -v)<br> <br> package=&#39;node-fetch&#39;<br> if [ `npm list -g | grep -c $package` -eq 0 ]; then<br> npm install -g $package<br> fi<br>- name: Docker Hub Description<br> uses: peter-evans/dockerhub-description@v5<br> with:<br> username: ${{ secrets.DOCKER_HUB_USERNAME }}<br> password: ${{ secrets.DOCKER_HUB_PASSWORD }} <br> repository: ${{ repostitory }}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=56f7dccb5b05" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploy front-end applications with Docker]]></title>
            <link>https://medium.com/@davidclaeys/deploy-front-end-applications-with-docker-c6a7746c253d?source=rss-f09a088813e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/c6a7746c253d</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[David Claeys]]></dc:creator>
            <pubDate>Thu, 17 Oct 2024 11:12:17 GMT</pubDate>
            <atom:updated>2024-10-17T11:19:47.730Z</atom:updated>
            <content:encoded><![CDATA[<p>In a previous article we explained how you could deploy a .NET application with Docker.<br>The content of this article will be applicable whether you use a .NET backend or not.</p><h3>Possible pitfalls</h3><p>A possible issue is that you only want to make your backend available for use to your front-end.<br>This is quite nice since it significantly decreased the possible attack surface.<br>But at a first glance this is not possible since the clients running the application wouldn’t be able to perform any API call.</p><p>Or maybe as per convention you host all your backends at <em>api.example.com/apiName</em> while you want to give your front-end applications a more recognizable domain.<br>If you’ve tried to just point your client requests to a different domain you’ve probably noticed the following problems :<br>- it’s quite annoying to hardcode domains since these can change over time<br>- CORS on won’t let you do it</p><h3>The solution</h3><p>These problems can both be solved through building a Docker image.<br>The proposed example is based on <a href="https://nodejs.org/en/">Node</a> but with some creativity you could tweak it with any front-end solution. To be clear since we’re using Node we can build any framework based on it (like React or Angular).</p><p>We will split up the building process in two stages.</p><h4>First build stage : Compiling</h4><p>The first stage is intended to build or node application.<br>If you want to build an application that’s not based on Node this is where you would change the base image. If for some reason your build process requires multiple steps this is the place where you would do it.</p><pre>FROM node:22-alpine AS builder<br># all subsequent commands will be performed in the /app directory<br>WORKDIR /app/<br># copy all the source code into the current directory<br>COPY . .<br># update the system ,after that install all dependencies and run build<br>RUN apk update &amp;&amp; apk upgrade - available &amp;&amp; npm install \<br> &amp;&amp; npm run build</pre><h4>Second build stage : Hosting</h4><p>The following stage will be responsible for running a http server (Nginx) hosting the application and also will proxy requests to the backend.</p><p>The contents of this stage would be something like this :</p><pre>FROM nginx:mainline-alpine<br># define environment variables for later subsitution<br>ENV API_PROTOCOL=&quot;https&quot;<br>ENV API_HOST=&quot;localhost&quot;<br>ENV API_PORT=&quot;80&quot;<br># change the working directory to the main nginx directory<br>WORKDIR /usr/share/nginx/html<br># update and adding system dependencies<br># default nginx configurations are also wiped out<br>RUN apk update &amp;&amp; apk upgrade - available \<br> &amp;&amp; apk add envsubst \<br> &amp;&amp; rm -rf ./*<br># copy the build output to the current folder<br>COPY - from=builder /app/build .<br># add nginx configuration template file<br>COPY nginx.conf.template /etc/nginx/nginx.conf<br># add script for variable substitution at runtime<br>COPY entrypoint.sh /docker-entrypoint.d/05-docker-entrypoint.sh<br># set correct file permissions and remove files that are not needed<br>RUN chmod +x /docker-entrypoint.d/05-docker-entrypoint.sh \<br> &amp;&amp; apk del envsubst \<br> &amp;&amp; rm -rf /var/cache/apk/* \<br> &amp;&amp; rm -rf /etc/nginx/conf.d</pre><p><strong>Nginx configuration overview</strong><br>Let’s take a look at a file we will call <em>nginx.conf.template</em>.</p><pre>user nginx;<br>worker_processes auto;<br>error_log /var/log/nginx/error.log notice;<br>pid /var/run/nginx.pid;<br>events {<br> worker_connections 1024;<br>}<br>http {<br>map $http_upgrade $connection_upgrade {<br> default upgrade;<br> &#39;&#39; close;<br> }<br>include /etc/nginx/mime.types;<br> default_type application/octet-stream;<br>log_format main &#39;$remote_addr - $remote_user [$time_local] &quot;$request&quot; &#39;<br> &#39;$status $body_bytes_sent &quot;$http_referer&quot; &#39;<br> &#39;&quot;$http_user_agent&quot; &quot;$http_x_forwarded_for&quot;&#39;;<br>access_log /var/log/nginx/access.log main;<br>sendfile on;<br> keepalive_timeout 65;<br>server{<br> listen 80;<br> <br> location / {<br> root /usr/share/nginx/html;<br> }<br>location /hubs {<br> allow all;<br> # App server url<br> proxy_pass $API_PROTOCOL://$API_HOST:$API_PORT;<br># Configuration for WebSockets<br> proxy_set_header Upgrade $http_upgrade;<br> proxy_set_header Connection $connection_upgrade;<br> proxy_cache off;<br> proxy_cache_bypass $http_upgrade;<br># WebSockets were implemented after http/1.0<br> proxy_http_version 1.1;<br># Configuration for ServerSentEvents<br> proxy_buffering off;<br># Configuration for LongPolling or if your KeepAliveInterval is longer than 60 seconds<br> proxy_read_timeout 100s;<br>proxy_ssl_server_name off;<br> proxy_ssl_verify off;<br>proxy_set_header Host $host;<br> proxy_set_header X-Real-IP $remote_addr;<br> proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;<br> proxy_set_header X-Forwarded-Proto $scheme;<br> }<br> }<br>}<br>```<br>Discussing locations<br>The first thing to note is that we define two locations : `/` (web location) and location `/hubs` (proxy location).<br>The `/` location will host the build output of our application, while the `/hubs` location is the location of the requests that will be proxied. It&#39;s important that in order for the web location to work the build files must be present in the indicated root directory.<br>The reason that we did not call the proxy location `/api` is that our front-end application uses SignalR to communicate to the backend. The configuration provided in this example enables features like web sockets and long polling. However you can tweak the example provided to meet your needs.<br>If you look deeper into the proxy configuration you probably will notice `$API_PROTOCOL://$API_HOST:$API_PORT`. If you would try this configuration directly in nginx it will fail pointing out your configuration is incorrect.<br>Don&#39;t worry though since these are simply placeholders (that&#39;s the reason we&#39;ve called this file a template) that will be replaced later on. Our front-end application can simply point API communication to `/hubs/whatever` and our proxy will take care of it.<br>Variable substitutions<br>Let me ask you a question : When do you replace the placeholders with it&#39;s final value ?<br>If you do it at build time each time a domain changes you&#39;ll be forced to rebuild.<br>Or worse if you host multiple instances this means you&#39;ll need to build a separate image for each instance. I think it&#39;s obvious this method is not desirable at all.<br>Instead of performing variable substitutions at build time they should be performed at run time.<br>Modifying the entry point of an existing Docker image can be quite tricky, luckily we won&#39;t need to.<br>The nginx image provides a feature that when you put scripts into the `/docker-entrypoint.d ` folder of the container it will run these scripts at startup time.<br>We will substitute the following variables : _API_PROTOCOL_, _API_HOST_ and _API_PORT_.<br>Let&#39;s have a look at our `entrypoint.sh` file :<br>```<br>#!/usr/bin/env sh<br>set -eu<br>echo &quot;$(envsubst &#39;${API_PROTOCOL},${API_HOST},${API_PORT}&#39; &lt; /etc/nginx/nginx.conf)&quot; &gt; /etc/nginx/nginx.conf<br>exec &quot;$@&quot;</pre><p>This script is quite easy, it uses the <em>envsubst</em> command in order to read and substitute the contents of <em>/etc/nginx/nginx.conf</em>` and writes them afterwards into the same file.<br>So during our docker image process we will need to locate our template file at <em>/etc/nginx/nginx.conf </em>and at runtime this script will substitute the contents of the file with the provided environment variables.</p><h3>Considerations and thoughts</h3><p>In this example we used Nginx as our http server, however you can use the server that best fits your use-case. However if you choose so you will need to figure out how to setup a proxy on your own.<br>To be honest most common http servers provide plentiful documentation, so it really shouldn’t be a problem.</p><p>You might have noticed the use of <em>envsubst</em>. The placeholder substitution at runtime has been one of the parts where I struggled most. For some reason it has been quite tricky to get the values of the environment variables in a bash script and putting them in the configuration file.<br>The most annoying part is that you specify the variables you want to substitute. If you have a large amount of placeholders to replace this can become quite cumbersome.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c6a7746c253d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Epg, the easy way]]></title>
            <link>https://medium.com/@davidclaeys/epg-the-easy-way-2763d4686ae0?source=rss-f09a088813e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/2763d4686ae0</guid>
            <category><![CDATA[epg-guides]]></category>
            <category><![CDATA[epg]]></category>
            <dc:creator><![CDATA[David Claeys]]></dc:creator>
            <pubDate>Wed, 09 Oct 2024 12:23:35 GMT</pubDate>
            <atom:updated>2024-10-09T12:23:48.796Z</atom:updated>
            <content:encoded><![CDATA[<h3>The problem</h3><p>In a previous post I went through the process of setting up your own epg provider with <a href="https://github.com/iptv-org/epg">iptiv-org/epg</a>. That process is still valid but it has some important drawbacks.<br>First of all the setup process is quite lengthy, which may scare potential users away.<br>Secondly the installation process is performed directly on the host.<br>Which might be a dealbreaker if you like hosting applications through Docker.</p><h3>The solution</h3><h4>Introduction</h4><p>This is where one of my personal projects comes into place <a href="https://git.claeyscloud.com/david/epg-info-docker">epg-info-docker</a>.<br>The purpose of this repository is to take the code in <a href="https://github.com/iptv-org/epg">iptiv-org/epg</a> and to build a Docker image out of it.</p><p>If you want to take a look at it, the code is available through my <a href="https://git.claeyscloud.com/david/epg-info-docker">git server</a> or <a href="https://github.com/davidclaeysquinones/epg-info-docker">github</a>.<br>You obviously can take this code and build it yourself, but this is not the most convenient.</p><p>For your convenience images are made available at different registries :<br>- git.claeyscloud.com/david/epg-info<br>- ghcr.io/davidclaeysquinones/epg-info<br>- docker.io/davidquinonescl/epg-info</p><p>Each of these images is the same, so you can pick the image from where you prefer.</p><h4>Setup</h4><p>You can use this image in the following way :</p><pre>version: &#39;3.3&#39;<br>services:<br> epg:<br> image: git.claeyscloud.com/david/epg-info:latest<br> #image: ghcr.io/davidclaeysquinones/epg-info:latest<br> #image: davidquinonescl/epg-info:latest<br> volumes:<br> # add a mapping in order to add the channels file<br> - /docker/epg:/config<br> ports:<br> - 6080:3000<br> environment:<br> # specify the time zone for the server<br> - TZ=Etc/UTC<br> # uncomment the underlying line if you want to enable custom fixes<br> #- ENABLE_FIXES=true<br> restart: unless-stopped</pre><p>In order to setup the program you need a channels.xml file.<br>This files describes which providers and channels you want the program to generate epg information.<br>An example of the contents for this file looks like this :</p><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br>&lt;channels&gt;<br> &lt;channel site=&quot;movistarplus.es&quot; lang=&quot;es&quot; xmltv_id=&quot;24Horas.es&quot; site_id=&quot;24H&quot;&gt;24 Horas&lt;/channel&gt;<br>&lt;/channels&gt;</pre><p>In the <a href="https://github.com/iptv-org/epg/tree/master/sites">repo</a> you can look for all available providers. Each provider has a list with it’s available channels.</p><p>And that’s it ! You’ve just setup your own epg provider.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2763d4686ae0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Watching Live TV on all your devices]]></title>
            <link>https://medium.com/@davidclaeys/watching-live-tv-on-all-your-devices-a8141c3a35c6?source=rss-f09a088813e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/a8141c3a35c6</guid>
            <category><![CDATA[epg]]></category>
            <category><![CDATA[threadfin-http]]></category>
            <category><![CDATA[jellyfin]]></category>
            <category><![CDATA[iptv]]></category>
            <dc:creator><![CDATA[David Claeys]]></dc:creator>
            <pubDate>Wed, 26 Jun 2024 12:35:18 GMT</pubDate>
            <atom:updated>2026-09-10T13:50:24.035Z</atom:updated>
            <content:encoded><![CDATA[<p>In recent years streaming services have gained a lot of popularity. However for a multiple of reasons sometimes we might want to watch Live TV.</p><p>Depending on the place you live your ISP or cable provider might (or not) provide some kind of app to watch TV on your mobile devices. However some apps are crappy, other are limited in the channels you can watch or other might have a very limited feature set. For these reasons you might want to watch Live Tv on your own terms.</p><p>In this article we will look at how you would go about setting up Live Tv on your own infrastructure. In the end you’ll be able to stream Tv through web, mobile devices in a very convenient way.</p><p>In order to reach our end goal we will perform the following steps:</p><ul><li>Installing and setting up <a href="https://github.com/iptv-org/epg">iptiv-org/epg</a> to acquire EPG data</li><li>Installing and setting up <a href="https://github.com/Threadfin/Threadfin">Threadfin</a></li><li>Installing and setting up <a href="https://github.com/jellyfin/jellyfin">Jellyfin</a></li></ul><p><em>Disclaimer :</em> This article’s assumption is that you have some knowledge about the Linux network stack and Docker.</p><h3>Setting up EPG</h3><p>Getting schedules for the channels you want is quite essential in order to have a good experience. However depending on the country where you live getting EPG (Electronic Programme Guide) can be very easy or almost impossible.</p><p>By example if you live in Spain <a href="https://github.com/davidmuma/EPG_dobleM">dobleM</a> provides EPG information for almost any channel you can imagine.</p><p>However if you live in Belgium getting decent EPG information is very challenging. I’ve looked through forums and not found any source available.</p><h3>Setting up your own EPG provider</h3><p>So what do you do there are no EPG sources available for your country or for a particular channel ?</p><p>This is where <a href="https://github.com/iptv-org/epg">iptiv-org/epg</a> comes to the rescue.</p><p>Let’s get through the necessary steps in order to set it up.</p><p>First of all you’ll want a system with a static IP address. We will be using Ubuntu 22.04 in order to perform the setup process. As always feel free to use any Linux flavor you like but be aware that you might get through some roadblocks (or not) if you do so.</p><h4>Updating and installing dependencies</h4><p>First of all we want to make sure all our system dependencies are up to date and and we will install our necessary dependencies.</p><pre>sudo apt-get update \<br>  &amp;&amp; sudo apt-get upgrade -y -q \<br>  &amp;&amp; sudo apt-get install curl -y \<br>  &amp;&amp; sudo apt-get install git -y</pre><h4>Installing Nodejs</h4><p>In order to install the latest supported NodeJs version we will be using <a href="https://github.com/nodesource/distributions">NodeSource</a>. There are other ways you could do the same but this is the most convenient way to do it.</p><p><em>Note :</em> At the moment NodeJS 22 is not compatible with the software we’re installing.</p><pre>curl -fsSL https://deb.nodesource.com/setup21.x -o nodesourcesetup.sh<br>sudo -E bash nodesource_setup.sh<br>sudo apt-get install -y nodejs</pre><p>Once you’ve performed these steps the command node -v should return v21.x.x.</p><h4>Installing iptiv-org/epg</h4><p>Now we can proceed to the actual installation of our EPG provider. First we will make a directory where we will perform the installation</p><pre>mkdir /bin/epg -p</pre><p>Now we want to go into the directory we just made by typing cd /bin/epg</p><p>At this point we are ready to clone the git repository into our server.</p><pre>git -C /bin clone --depth 1 -b master https://github.com/iptv-org/epg.git</pre><p>Once the source code is on our machine we can install the necessary dependencies.</p><pre>npm install</pre><p>In order to serve our files over the network we also want to install an npm module called <a href="https://www.npmjs.com/package/pm2">pm2</a></p><pre>npm install pm2 -g</pre><p>Now we will create two scripts that will enable us to start our EPG provider at startup. <em>start.sh :</em></p><pre>#!/bin/bash<br> <br>pm2 --name epg start npm -- run serve<br>npm run grab -- --channels=channels.xml --cron=&quot;0 0,12 * * *&quot; --maxConnections=10 --days=14 --gzip</pre><p><em>stop.sh :</em></p><pre>#!/bin/bash<br> <br>pm2 delete 0</pre><p>To use these scripts we need to create our service file typing nano /etc/systemd/system/epg.service Put the following content in the file :</p><pre>[Unit]<br>Description=Epg<br>After=network.target<br> <br>[Service]<br>ExecStart=/bin/epg/start.sh<br>ExecStop=/bin/epg/stop.sh<br>WorkingDirectory=/bin/epg<br> <br>[Install]<br>WantedBy=default.target</pre><p>As a last step we need to tell the system is should reload it’s services by typing systemctl daemon-reload.</p><p>We’ve just completed the installation of our own EPG provider but in order to get actual EPG information we need to tell it which channels we want information for.</p><p>We do this by creating a file called channels.xml by typing nano channels.xml. An example of the contents for this file looks like this :</p><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br>&lt;channels&gt;<br> &lt;channel site=&quot;movistarplus.es&quot; lang=&quot;es&quot; xmltvid=&quot;24Horas.es&quot; siteid=&quot;24H&quot;&gt;24 Horas&lt;/channel&gt;<br>&lt;/channels&gt;</pre><p>The contents of this file depend on which providers and channels you want to use. In the <a href="https://github.com/iptv-org/epg/tree/master/sites">repo</a> you can look for all available providers. Each provider has a list with it’s available channels.</p><p>Be aware that not all providers are equal. For example <a href="https://github.com/iptv-org/epg/tree/master/sites/telenet.tv">telenet.tv</a> is rock solid but lacks program thumbnails for most channels. And in contrast <a href="https://github.com/iptv-org/epg/tree/master/sites/pickx.be">pickx.be</a> keeps breaking because of intentional API changes but most programs have thumbnails.</p><p>Finding the right providers for the right channels is a process of trial and error and also depends on what you’re willing to deal with.</p><p>These some providers you could use :</p><ul><li><a href="https://github.com/iptv-org/epg/tree/master/sites/telenet.tv">telenet.tv</a> (Belgium)</li><li><a href="https://github.com/iptv-org/epg/tree/master/sites/pickx.be">pickx.be</a> (Belgium)</li><li><a href="https://github.com/iptv-org/epg/tree/master/sites/movistarplus.es">movistarplus.es</a> (Spain)</li><li><a href="https://github.com/iptv-org/epg/tree/master/sites/programacion-tv.elpais.com">programacion-tv.elpais.com</a> (Spain)</li><li><a href="https://github.com/iptv-org/epg/tree/master/sites/tvgids.nl">tvgids.nl</a> (Netherlands)</li><li><a href="https://github.com/iptv-org/epg/tree/master/sites/tv24.co.uk">tv24.co.uk</a> (UK)</li><li><a href="https://github.com/iptv-org/epg/tree/master/sites/tvtv.us">tvtv.us</a> (US)</li><li><a href="https://github.com/iptv-org/epg/tree/master/sites/chaines-tv.orange.fr">chaines-tv.orange.fr</a> (France)</li></ul><p>This list is by any means extensive and if you’re looking for other countries you should check which providers are available</p><h3>Setting up Live Tv streams</h3><p>The next piece of the puzzle is getting the streams for the channels you want. The options you have depend a lot on where you live and on your goals.</p><p>For example in the US you could use a <a href="https://www.silicondust.com/hdhomerun/">HD HomeRun</a>. In some countries (like Spain) you could install a <a href="https://www.amazon.es/gp/product/B09KQM9NQ8/ref=ppx%3Cem%3Eyo_dt_b_search_asin%3C/em%3Etitle?ie=UTF8&amp;psc=1">DVB-T2 decoder</a> into your system and setup <a href="https://github.com/tvheadend/tvheadend">tvheadend</a> to stream over the network. However if you live in countries where open standards were purposely not adopted (like Belgium) you’re only option is to resort to an IPTV provider.</p><p>There are some IPTV list available like <a href="https://github.com/iptv-org/iptv">iptv-org/iptv</a> or <a href="https://github.com/LaQuay/TDTChannels">TDTChannels</a> that just list publicly available streams and that are completely legal.</p><p>If you still choose to use an IPTV provider that infringes copyright please be aware that depending on legislation you could be sanctioned for just being a customer. Be also aware that getting scammed while sourcing an IPTV provider is a real possibility. I don’t want to encourage neither recommend you to source an IPTV provider that infringes copyright. If you make that decision you do so under your own responsibility. Please be careful and try to minimize risks as much as possible.</p><p>Some pieces of software (like Jellyfin) offer a direct integration to the HD HomeRun. If you have such a device you can directly integrate it. However I would recommend to use <a href="https://github.com/Threadfin/Threadfin">Threadfin</a> as an intermediate layer in order to manage EPG and channel numbering. If you’re using an m3u stream from tvheadend or an IPTV provider you can’t get around using this piece of software.</p><h4>Installing Threadfin</h4><p>This is how a Docker compose file would look like for Threadfin without any additional precaution :</p><pre>version: &quot;3.5&quot;<br>services:<br>  threadfin:<br>    image: fyb3roptik/threadfin<br>    environment:<br>      - PUID=${PUID}<br>      - PGID=${PGID}<br>      - TZ=${TIME_ZONE}<br>    volumes:<br>      - ${THREADFINCONFIGDIR}:/home/threadfin/conf<br>    ports:<br>      - 34400:34400<br>    restart: unless-stopped</pre><p>If you would like to take some precaution <a href="https://github.com/qdm12/gluetun">gluetun</a> is a very good option. This is basically a Docker image that allows you to configure almost any VPN provider.</p><p>In the <a href="https://github.com/qdm12/gluetun-wiki/tree/main/setup/providers">wiki</a> you can find information about how to setup your particular VPN provider.</p><p>So if you would like to take precautions your compose file would look like this :</p><pre>version: &quot;3.5&quot;<br>services:<br>  vpn:<br>    image: qmcgaw/gluetun<br>    cap_add:<br>      - NET_ADMIN<br>    devices:<br>      - /dev/net/tun:/dev/net/tun<br>    sysctls:<br>      - net.ipv6.conf.all.disable_ipv6=0<br>    environment:<br>      - TZ=${TIME_ZONE}<br>      - VPNSERVICE_PROVIDER=${YOURPROVIDER}<br>      ....<br>      # some provider specific variavles<br>      ....<br>      - FIREWALLOUTBOUND_SUBNETS=${YOURSUBNET}/24<br>    ports:<br>      - 34400:34400<br>    volumes:<br>      -  ${VPNCONFIGDIR}:/config<br>    restart: unless-stopped<br>  threadfin:<br>    image: fyb3roptik/threadfin<br>    environment:<br>      - PUID=${PUID}<br>      - PGID=${PGID}<br>      - TZ=${TIME_ZONE}<br>    depends_on:<br>      - vpn<br>    network_mode: service:vpn<br>    volumes:<br>         - ${THREADFINCONFIGDIR}:/home/threadfin/conf<br>    restart: unless-stopped</pre><h4>Setting up Threadfin</h4><p>Once Threadfin is installed we need to set it up.</p><p>Basic settings</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WTOwsHyUSF3q67Zy.png" /></figure><p>Before we continue we want to open the settings page. We want to change the following things :</p><ul><li>EPG Source to XEPG</li><li>Replace missing program images should be checked</li><li>Stream Buffer: to VLC</li></ul><p>If you notice that your streams are stuttering you can experiment with increasing Buffer Size.</p><p>The Number of Tuners setting sets a system wide maximum number of streams. Choose a realistic number based on your needs and system performance. This setting can also be overridden at playlist level to a lower value.</p><p>If you’re going to use TVHeadend the Ignore Filters setting will make things easier later on.</p><p>Playlist settings</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*n0A7_sF_7Uwu7vDP.png" /></figure><p>The first time you open this page you will be greeted by an empty page.</p><p>When you press on the new button you will be greeted by the following dialog.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*G4YWQOQ6H_-rYQBj.png" /></figure><p>Choose M3U if you&#39;re using an stream (IPTV or TvHeadend) or choose HdHomeRun if you&#39;re using that particular device.</p><p>Depending on your choice you will see once of these dialogs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7uxvYZL3atk8PjCL.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qWqFe39b8bj4d3gn.png" /></figure><p>The M3U file or HDHomeRun IP fields are the most crucial part. Fill in the address to the M3U file or your HDHomeRun device on your local network.</p><p>You also want to set the Tuner/Streams amount to a reasonable amount. If you&#39;re using TV Headend, a public IPTV list or HdHomeRun this will be hardware constrained (number or tuners and general system performance. If you&#39;re using a IPTV provider this will be whatever their general policy permits.</p><p>XMLTV settings</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*C9rOgEk8lV1j4ZF5.png" /></figure><p>This page will also be empty when you open it up for the first time. In my opinion this is one of the strengths of Threadfin. Regardless of whether you have any EPG information you can mix and match different sources to the combination you like.</p><p>When you press on the new button you will be greeted by the following dialog.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PjUkl0KZkv6xGY6g.png" /></figure><p>You can give it whatever name and description you like. The XMLTV File field is the part that really matters. If you want to use a publicly available source you just fill in the corresponding URL according to their documentation. If you followed along and set up your own EPG provider the address will be &lt;EPG IP ADDRESS&gt;:3000/guide.xml.</p><p>Filter settings</p><p>If you plan to use TvHeadend and enabled the Ignore Filters setting you can skip this section.</p><p>Otherwise open this page and since we’re getting started it will be empty. The general idea of this page is that in most cases IPTV lists contain hundreds if not thousands of streams. In order to not affect system performance and keep things manageable we need to choose the categories we’ll want to map later on. Choosing one particular category doesn’t mean we are forced to map all channels in it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZGuHrsCBEnnhF2Cw.png" /></figure><p>Threadfin offers two different filter types <em>M3U</em> and <em>custom filters</em>. The M3U type is pretty basic and limits itself to the categories contained in group titles contained in the M3U file. The custom filter is powerful because it enables to make filters on specific patterns.</p><p>Now I need to be honest, at some point I’ve tried to use custom filters but I didn’t figure it out. I think that depending on playlist size it might take quite some time to process since it needs to check for a pattern for each stream in the playlist. However that’s just an assumption since I’ve not really used this feature. Feel free to try it out but I won’t go into any more dept since I’m not able to.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VhEDR3mQF_QjYQ8l.png" /></figure><p>The field we want to look for is group title. This will make the chosen group title available in the mapping tab. You can have a look at the include/exclude settings if you want so but it&#39;s not strictly necessary.</p><p>Mapping settings</p><p>When opening the mappings page you won’t be greeted by an empty list. Most probably you’ll be greeted with a list with unmapped/inactive channels. You can make the distinction because of the red line on the left end of the table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5ugyFyGXZOKKa7Cf.png" /></figure><p>Before activating a channel you should first assign it the number of your liking. You do this by typing the desired value in the text field.</p><p>In order to continue click on the desired channel in order to open the map channel popup.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zUOovJ2fKCrDLfzc.png" /></figure><p>The most important settings are :</p><ul><li>Active to activate the channel</li><li>Channel name to edit the channel name</li><li>Logo Url to assign the channel a logo</li><li>Group title to group the channel to your liking</li><li>XMLTV File in order to choose the XMLTV file you want to use</li><li>XMLTV Channel to choose the right channel in the XMLTV file</li></ul><p>Once you’ve chosen your desired settings click on the <em>done</em> button. Now there also should be a list with active/mapped channels. You can make the distinction because of the green line on the left end of the table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PIrAW2TDx7gek8LQ.png" /></figure><p>Mapping all desired channels can be a repetitive task but as you’ll see in the end the effort is worth it.</p><p><em>Note :</em> In the next steps we’ll be talking about setting up and installing <a href="https://github.com/jellyfin/jellyfin">Jellyfin</a>. However you can use Threadfin with any software that supports the HD HomeRun since it functions as an emulation layer. Other software of the likes of <a href="https://www.plex.tv/es/media-server-downloads/">Plex Media Server</a>, <a href="https://kodi.tv/">Kodi</a> and <a href="https://emby.media/">Emby</a> exist that enables you to do the same. However Jellyfin is the only open source solution that enables this feature without any paid plan and on the server side (Kodi is a client application).</p><h4>Installing Jellyfin</h4><p>This is how a compose file for a Jellyfin installation looks like :</p><pre>version: &quot;3.5&quot;<br>services:<br>  jellyfin:<br>    image: jellyfin/jellyfin<br>    user: ${PUID}:${PGID}<br>    ports:<br>      - 8096:8096<br>    volumes:<br>      - ${CONFIG_FOLDER}:/config<br>      - ${CACHE_FOLDER}:/cache<br>      - ${MOVIES_FOLDER}:/Movies<br>      - ${TVSHOWSFOLDER}:/Tv Shows<br>      - ${RECORDINGS_FOLDER}:/recordings:/recordings<br>    restart: unless-stopped<br>    depends_on:<br>    environment:<br>      #use this variable if you want to access your Jellyfin server through a domain name<br>      - JELLYFIN_PublishedServerUrl=http://jellyfin.yourdomain.com</pre><p>Once you deploy this compose file Jellyfin will be available through port 8096 or through the domain you’ve set up. Complete the setup wizard and setup your libraries.</p><p>After this click on your user icon and open the <em>administration panel</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*auaIrp-Pu8-4srw8.png" /></figure><p>We want to go to the <em>Live Tv</em> section of the admin panel. Click on the + button under <em>Tuner Device</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XCQ4gDRIqoAQmlX3.png" /></figure><p>Select HD Homerun as the <em>Tuner Type</em> and check the <em>Allow hardware transcoding</em> checkbox. Under <em>Tuner IP Address</em> you should type http://&lt;THREADFIN IP ADDRESS&gt;/. Once that&#39;s done click on the save button.</p><p>Last but not least click on the + button under <em>TV Guide Data Providers</em> and choose XMLTV.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MLx7dCaV8D9g4CbV.png" /></figure><p>The only thing you need to do is type http://&lt;THREADFIN IP ADDRESS&gt;:34400/xmltv/threadfin.xml under <em>File or URL</em>. Click on the save button and you&#39;re all set. Jellyfin will need some time in order to gather all necessary information but after a while live tv will be available.</p><p>Jellyfin is available through the web interface and different apps. The UI is pretty straightforward so we won’t go into detail on this topic. You’ve just setup up live tv on your server on your terms.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a8141c3a35c6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploying .NET containers in Docker]]></title>
            <link>https://medium.com/@davidclaeys/deploying-net-containers-in-docker-463fc9e0a84e?source=rss-f09a088813e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/463fc9e0a84e</guid>
            <category><![CDATA[microsoft]]></category>
            <category><![CDATA[dockerfiles]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[net-core]]></category>
            <dc:creator><![CDATA[David Claeys]]></dc:creator>
            <pubDate>Wed, 24 Apr 2024 10:59:19 GMT</pubDate>
            <atom:updated>2024-10-18T12:04:42.561Z</atom:updated>
            <content:encoded><![CDATA[<h3>Deploying .NET containers in Docker</h3><p>Since Microsoft started to transition .NET they also started offering Docker images to package your applications. To be more specific at <a href="https://hub.docker.com/_/microsoft-dotnet">Docker Hub</a> Microsoft lists their images and intended purposes.</p><p>I wanted to take myself up for a challenge and try to package a .NET API project into a Docker container.<br>The purpose of this article isn’t to tell you how to build an API project since this topic is broadly covered on the web. I want to tell you one of the roadblocks I ran against and how I managed to solve it.</p><p>If you want to get started the following tutorials could be useful :<br>- <a href="https://learn.microsoft.com/en-us/dotnet/core/docker/build-container?tabs=windows&amp;pivots=dotnet-8-0">Containerize a .NET app</a><br>- <a href="https://medium.com/@ersen/step-by-step-dockerizing-net-core-api-a2490752a3d2">Step By Step Dockerizing .NET Core API</a><br>- <a href="https://itnext.io/smaller-docker-images-for-asp-net-core-apps-bee4a8fd1277">Smaller Docker Images for ASP.NET Core Apps</a></p><h3>Slim Docker images</h3><p>It’s best practice to make the Docker images you publish as slim as possible. <br>The main benefit of doing this is that consuming your image will take less space on your host if you do so.<br>There are many ways to make your image slimmer but one of the most effective ways is picking the right base image with the right tag.</p><p>For example if we look at the tags for the <a href="https://hub.docker.com/_/microsoft-dotnet-aspnet/">ASP.NET Core Runtime</a> we see among others the following sections : <em>Linux amd64</em>, <em>Nano Server 2022 amd64</em> , <em>Windows Server Core 2022 amd64</em> and so on.<br>If you want to make your Docker image multi platform compatible (one of the main benefits of .NET and Docker) you should automatically discard the tags representing a Windows environment.<br>First of all it’s probably not the most lightweight base OS to build your image but more importantly Windows Docker containers can’t run on any system that isn’t Windows based.</p><p>This limits our choice to Linux based images, but even there we have lots of choice.<br>By example at this moment in time we can choose among others between 8.0-bookworm-slim (<a href="https://www.debian.org/releases/bookworm/">Debian</a>), 8.0-alpine-amd64 (<a href="https://www.alpinelinux.org/posts/Alpine-3.18.0-released.html">Alpine</a>) and 8.0-jammy (<a href="https://releases.ubuntu.com/jammy/">Ubuntu</a>).<br>Microsoft marks the Debian variant with the latest `tag` since this distribution is pretty lightweight and also is quite widespread. However if we want to take things up a notch we should go for alpine since this is a lightweight no frills distribution.</p><h3>The roadblock</h3><p>When publishing a .NET API it is served by <a href="https://learn.microsoft.com/en-us/aspnet/core/fundamentals/servers/kestrel?view=aspnetcore-8.0">Kestrel</a>.<br>When making an API it is recommended to use HTTPS for security reasons. Furthermore when making a production build it is even required.</p><p>When reading the <a href="https://learn.microsoft.com/en-us/dotnet/core/additional-tools/self-signed-certificates-guide#create-a-self-signed-certificate">documentation</a> we see we should use the following commands :</p><pre>dotnet dev-certs https -ep $env:USERPROFILE\.aspnet\https\aspnetapp.pfx -p crypticpassword<br>dotnet dev-certs https - trust</pre><p>This is simple enough, what’s the problem then? Well the second of those command is only supported on Windows based systems.</p><h3>The solution</h3><p>After a lot of trial and error I came to the following solution :</p><pre># Password for the certificate<br>ARG CERT_PASSWORD_ARG=SUPERSECRET<br># this image contains the entire .NET SDK and is ideal for creation the build<br>FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine-amd64 AS build-env<br>ARG CERT_PASSWORD_ARG<br>ENV CERT_PASSWORD=$CERT_PASSWORD_ARG<br>WORKDIR /App<br>COPY . ./<br># Restore dependencies for your application<br>RUN dotnet restore<br># Build your application<br>RUN dotnet publish test.csproj --no-restore --self-contained false -c Release -o out /p:UseAppHost=false <br># Make the directory for certificate export<br>RUN mkdir /config<br># Generate certificate with specified password<br>RUN dotnet dev-certs https --export-path /config/aspnetapp.pem --password &quot;$CERT_PASSWORD&quot; --format PEM<br><br># this image contains the ASP.NET Core and .NET runtimes and libraries <br>FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine-amd64<br>ARG CERT_PASSWORD_ARG<br>ENV CERT_PASSWORD=$CERT_PASSWORD_ARG<br>WORKDIR /App<br># add dependency in system to setup certificates<br>RUN apk add ca-certificates <br># create directory to store certificate config<br>RUN mkdir /config <br># create necessary config directory<br>RUN mkdir -p /usr/local/share/ca-certificates/<br># copy compiled files to runtime<br>COPY --from=build-env /App/out . <br># copy generated certificate<br>COPY --from=build-env /config /config<br># Disable Big Brother<br>ENV DOTNET_CLI_TELEMETRY_OPTOUT=1<br># Set the environment to production<br>ENV ASPNETCORE_ENVIRONMENT=Production<br># Set the urls where Kestrel is going to listen<br>ENV ASPNETCORE_URLS=http://+:80;https://+:443<br># location of the certificate file<br>ENV ASPNETCORE_Kestrel__Certificates__Default__Path=/usr/local/share/ca-certificates/aspnetapp.crt<br># location of the certificate key<br>ENV ASPNETCORE_Kestrel__Certificates__Default__KeyPath=/usr/local/share/ca-certificates/aspnetapp.key<br># specify password in order to open certificate key<br>ENV ASPNETCORE_Kestrel__Certificates__Default__Password=$CERT_PASSWORD<br># copy certificate files to config directory<br>RUN cp /config/aspnetapp.pem $ASPNETCORE_Kestrel__Certificates__Default__Path <br>RUN cp /config/aspnetapp.key $ASPNETCORE_Kestrel__Certificates__Default__KeyPath<br># set file permisions for certificate file<br>RUN chmod 755 $ASPNETCORE_Kestrel__Certificates__Default__Path <br>RUN chmod +x $ASPNETCORE_Kestrel__Certificates__Default__Path<br># change file ownership for certificate file<br># add generated certificate to trusted certificate list on the system<br>RUN cat $ASPNETCORE_Kestrel__Certificates__Default__Path &gt;&gt; /etc/ssl/certs/ca-certificates.crt<br># set file permissions for key file<br>RUN chmod 755 $ASPNETCORE_Kestrel__Certificates__Default__KeyPath<br>RUN chmod +x $ASPNETCORE_Kestrel__Certificates__Default__KeyPath<br># change file ownership for key file<br>RUN update-ca-certificates<br><br>ENTRYPOINT [&quot;dotnet&quot;, &quot;test.dll&quot;]<br>EXPOSE 80 <br>EXPOSE 443</pre><p>The above file is for demonstration purposes, in practice you shouldn’t use consecutive <em>RUN</em> instructions, you should update system dependencies and perform some cleanup. I’ve excluded those steps in order to focus on this article’s subject.</p><h4>Deep dive</h4><p>The first step I want to focus on is the following :</p><pre>RUN dotnet dev-certs https --export-path /config/aspnetapp.pem --password &quot;$CERT_PASSWORD&quot; --format PEM</pre><p>By default the command to generate certificates generates a certificate in the <a href="https://learn.microsoft.com/en-us/windows-hardware/drivers/install/personal-information-exchange---pfx--files">PFX</a> format.<br>While it is theoretically possible to use that format on Linux systems it’s an overly complicated mess. So in order to make things easier we tell the generator tool to use the PEM format. <br>This way of using certificates is much better supported in Linux and much easier to setup.<br>This command will generate two files : a certificate file and a key file.<br>The key file is encrypted with the password that is specified in <em>CERT_PASSWORD_ARG</em>.</p><p>The next important part is :</p><pre># location of the certificate file<br>ENV ASPNETCORE_Kestrel__Certificates__Default__Path=/usr/local/share/ca-certificates/aspnetapp.crt<br># location of the certificate key<br>ENV ASPNETCORE_Kestrel__Certificates__Default__KeyPath=/usr/local/share/ca-certificates/aspnetapp.key<br># specify password in order to open certificate key<br>ENV ASPNETCORE_Kestrel__Certificates__Default__Password=$CERT_PASSWORD</pre><p>These environment variables tell the Kestrel server where it needs to look for the certificate files.<br>The <em>ASPNETCORE_Kestrel__Certificates__Default__Password</em> is key, since if it is not specified or correctly populated Kestrel won’t be able to use the certificate and will crash.<br>This variable isn’t anywhere to be found on Microsoft’s documentation and I only was able to find it looking at the .NET source code published on GitHub.</p><p>The next important part is :</p><pre>RUN cat $ASPNETCORE_Kestrel__Certificates__Default__Path &gt;&gt; /etc/ssl/certs/ca-certificates.crt<br>RUN update-ca-certificates</pre><p>This tells the system to trust the certificate we generated. If we wouldn’t do that Kestrel also wouldn’t be able to run and would crash.</p><h3>Security implications</h3><p>Maybe the elephant in the room is that in this setup we are using a self signed certificate in order to serve our application in a container. Many might be eager to discard this whole setup for this reason.<br>But before doing that hear me out.<br> <br>To start with, it’s bad practice to hardcode the certificate you’ll deploy in production environments in code.<br>So in fact your Docker image should always use a development certificate.<br>Yes, this example also contains a hardcode password at the beginning but this shouldn’t be an issue.</p><p>In theory we could use the <em>ASPNETCORE_Kestrel__Certificates__Default__Path</em>, <em>ASPNETCORE_Kestrel__Certificates__Default__KeyPath</em> and <em>ASPNETCORE_Kestrel__Certificates__Default__Password</em> environment variables in order to setup our production certificates at deployment.<br>This would allow us to run the image in a container while developing and use a securely stored certificated at deployment.<br>However this solution is discouraged since Microsoft doesn’t recommend directly exposing the Kestrel server in Production environments.</p><p>This leads to what in my opinion is the preferable solution : using a proxy.<br>You can setup IIS, <a href="https://www.nginx.com/">Nginx</a>, <a href="https://httpd.apache.org/">Apache</a>, <a href="https://traefik.io/traefik/">Traefik</a> and so on, with the certificate you want to use.<br>Clients using the deployed application will have a secure connection and you don’t need to deal with the complexities of setting up a “real” certificate at the image level.</p><p>Using Docker is amazing, and being able to use it with .NET even more.<br>If you stumbled on the same roadblock I hope this article proved useful.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=463fc9e0a84e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ScanservJs : make your own scan server]]></title>
            <link>https://medium.com/@davidclaeys/scanservjs-make-your-own-scan-server-21539f64265c?source=rss-f09a088813e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/21539f64265c</guid>
            <category><![CDATA[hp]]></category>
            <category><![CDATA[scanner]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[scanserverjs]]></category>
            <dc:creator><![CDATA[David Claeys]]></dc:creator>
            <pubDate>Thu, 17 Nov 2022 11:25:03 GMT</pubDate>
            <atom:updated>2026-06-15T07:49:32.053Z</atom:updated>
            <content:encoded><![CDATA[<h3>ScanservJs : make your own scan server</h3><p>Printers and scanners…, I have a love/hate relationship with them. They are very handy when they work, but sometimes they cause a lot of struggle.</p><p>I recently set myself up for a challenge. Since a couple of months I own an HP Envy Pro 6442, a printer/scanner combo. While not horrible, the experience using this device as a scanner leaves a lot to be desired. By default, you are limited to use the Windows scanner utility or to installing HP’s app on your phone. I thought the experience could be much better if somehow you could scan images through a webpage.</p><p>Admittedly, this device in particular provides a web interface that allows scanning from the web browser. But this interface is not really user friendly and requires authentication (which is rather burdensome for home use). So I looked up the web for a solution and through sheer luck I stumbled upon <a href="https://github.com/sbs20/scanservjs">ScanservJs</a>. The purpose of this article is to guide you through the setup for this particular device but it can be done on other devices.</p><p><em>Edit :<br></em>Since I wrote the article I’ve also set everything up with an HP Envy Inspire 7200. I’ve expanded the examples to adapt a bit more to this model.</p><p>ScanserveJs has been recently updated to version 3.<br>The new version has some breaking changes, the article has been updated to accomodate for these changes. If you already have it installed pull the latest image and take a look at the directory mappings.</p><h3>Disclaimer</h3><p>This is not by any means an entry-level tutorial. I omit some details that will not be easy to figure out if you have no prior experience.</p><p>These are the details I skipped (as far as I’m aware) :</p><ul><li>Setting up the scanner over the network (<a href="https://support.hp.com/us-en/document/ish_1780623-1698506-16">docs</a> for HP Envy Pro 6442)</li><li>Accessing the scanner web UI</li><li>Setting up the server OS</li><li>Assigning your server a static IP to your server so that users can access it (and specifying a domain name for your server)</li><li>Testing this setup with other other devices than mine (other models from HP or any other manufacturer)</li></ul><h3>Setting up the scanner</h3><p>Based on my experience I recommend assigning a static IP address. You can achieve this from your router making a static DHCP assignment. If you aren’t able to do this you can do this from the scanner web interface.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EEbyrAADhPxEoUtjo8LQjQ.png" /></figure><p>Under <strong>Network &gt; Wireless &gt; Network Address (IPv4)</strong> you can choose <strong>Manual IP</strong> and choose the IP address you wish.</p><h3><strong>Setting up the server</strong></h3><p>Since the scanner is setup over the network, it doesn’t need to be physically connected to the server. You can setup the server on bare metal or a hypervisor such as <a href="https://www.proxmox.com/en/proxmox-ve">Proxmox VE</a>, <a href="https://xcp-ng.org/">XCP-ng</a> or even <a href="https://learn.microsoft.com/en-us/virtualization/hyper-v-on-windows/about/">Hyper-V</a>. I personally used <a href="https://www.synology.com/en-global/dsm/feature/virtual_machine_manager">Virtual Machine Manager</a> on my Synology NAS to make a VM. If you have a QNAP NAS you could also use <a href="https://www.qnap.com/en-me/software/virtualization-station">Virtualization Station</a>. Since this detail is not really relevant for our purposes I won’t go into details. Use whatever suits your needs.</p><p>For my OS I used <a href="https://ubuntu.com/download/server">Ubuntu 22.04 Server</a>. You might be able to use other flavors of LINUX but no success is guaranteed. First of all we want to make sure our OS has the latest updates.</p><p><em>Note <br></em>At the time I did some testing on Ubuntu 22.10 and the install of hplib failed due to an unavailable dependency (python3-pyqt4).<br>Right now hplib is also installable on Ubuntu 24.04 but you’ll need to perform some additional steps.</p><pre>sudo apt-get update<br>sudo apt-get upgrade</pre><h4>Installing HP drivers</h4><p>This part of the guide depends mainly on the device manufacturer of your scanner. The following steps are only applicable if you own a HP scanner/printer. If you have another one you’ll need to figure this out on your own.</p><p><em>Edit :<br></em>The current version of the hplip software is 3.26.4.</p><p>On my server package updates broke my existing installation.<br>I had to install the latest driver version in order to get everything working again. Needless to say you need to be very careful when applying updates with your package manager, since it won’t automatically update your hplip installation.</p><p><em>Drivers for other manufacturers<br></em><a href="https://epson.com/Support/wa00821">Epson </a><br><a href="https://www.canon-europe.com/support/consumer_products/operating_system_information/#linux">Canon</a><br><a href="https://help.brother-usa.com/app/answers/detail/a_id/52188/~/install-drivers-%28deb-or-rpm%29-using-the-driver-install-tool---linux">Brother</a><br><a href="https://www.bchemnet.com/suldr/">Samsung</a></p><p>Luckily HP provides a LINUX driver for their devices. Although they just worked fine the documentation and installation process is a bit flaky.</p><p>First of all go to <a href="https://developers.hp.com/hp-linux-imaging-and-printing/gethplip">https://developers.hp.com/hp-linux-imaging-and-printing/gethplip</a> and select your server’s distro. If you followed along the distro we’re using is ubuntu.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C-dgg8_kvKL4ZZSoiN0zBw.png" /><figcaption>Hp driver downloader page</figcaption></figure><p>Then just click the download button and the download should start through SourceForge.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1HACkx4NEQnzbd8hZmQOjg.png" /><figcaption>Driver download starting</figcaption></figure><p>Once the download is completed you should get a file called <em>hplip-3.22.10.run</em>. Please note that the version might change over time as well the download source.</p><p>Before we attempt to install the driver we need to install some required packages on the server. You can find the required packages on <a href="https://developers.hp.com/hp-linux-imaging-and-printing/install/manual/distros/ubuntu">https://developers.hp.com/hp-linux-imaging-and-printing/install/manual/distros/ubuntu</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jAIiaIqWb8QWuQP7DFUCMA.png" /><figcaption>HP requirements documentation</figcaption></figure><pre>sudo apt-get install --assume-yes libcups2 cups libcups2-dev cups-bsd cups-client avahi-utils libavahi-client-dev libavahi-core-dev libavahi-common-dev libcupsimage2-dev libdbus-1-dev build-essential gtk2-engines-pixbuf ghostscript openssl libjpeg-dev libatk-adaptor libgail-common libsnmp-dev snmp-mibs-downloader libtool libtool-bin libusb-1.0-0-dev libusb-0.1-4 wget policykit-1 policykit-1-gnome automake1.11 python3-dbus.mainloop.pyqt5 python3-reportlab python3-notify2 python3-pyqt5 python3-dbus python3-gi python3-lxml python3-dev python3-pil python-is-python3 libsane libsane-dev sane-utils xsane -yq</pre><p>This command should do the trick but please be aware that this could change over time. Check the documentation to make sure you have all the requirements.</p><p>Now it’s time to install the driver on the server. At this stage I stumbled upon a hurdle. I was trying to get the installer file into my server but since I had a headless server I couldn’t figure out how to get the installer file into my server. Finally I settled with downloading it on my Windows machine and transferring the file to my server through sftp. I used a program called FileZilla to do this.</p><p>I made a new directory called <em>HP</em> where I put this file.</p><pre>mkdir hp</pre><p>Then I went into this directory.</p><pre>cd hp</pre><p>Once you are in the directory you can proceed with this command<br>(Please be aware of the version number).</p><pre>sh hplip-3.22.10.run</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pMUGko-1vateMhCqpMVwkw.png" /><figcaption>Screenshot of the driver installation process</figcaption></figure><p>This is the point where you need a lot of patience because depending on your system this step might take a while.</p><p>Once the installation is completed you can proceed setting up the scanner. You can do this with the following command. Please be aware that you will need to adapt the IP address depending on whatever you set up previously.</p><pre>sudo hp-setup -i 192.168.0.70</pre><h4>Important changes for Ubuntu 24.04</h4><p>Ubuntu 24.04 is listed as a compatible OS in newer versions of hplib. However I’ve experienced important issues when running the install script (some issues with qt-4 dependencies). If you’re running Ubuntu 24.04 and the install script fails these are the steps you need to follow.</p><p>First we tell the install script to prepare the source files without executing anything.</p><pre>sh hplip-3.26.4.run --noexec --target hplip-src</pre><p>Then we need to go into the folder we specified.</p><pre>cd hplip-src</pre><p>Then we need to run the install but without the qt-4 dependencies that cause the install issue.</p><pre>python3 install.py --no-qt4</pre><p>Once this is completed you can check if everything is working with this command.</p><pre>scanimage -L</pre><p>This command should give the following output. If you don’t see anything at this point your driver is not working.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uqfQ16agWWvk8reKCU_9fg.png" /><figcaption>Example of output</figcaption></figure><h4>Installing docker</h4><p>The most easy way to get the <a href="https://github.com/sbs20/scanservjs">ScanservJs </a>software working is through docker. I performed the install with the following command. Please be aware that this might change over time and read the documentation on <a href="https://docs.docker.com/engine/install/ubuntu/">https://docs.docker.com/engine/install/ubuntu/</a>.</p><pre>sudo apt-get install \<br>    ca-certificates \<br>    curl \<br>    gnupg \<br>    lsb-release<br>sudo mkdir -p /etc/apt/keyrings<br>curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg<br>echo \<br>  &quot;deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \<br>  $(lsb_release -cs) stable&quot; | sudo tee /etc/apt/sources.list.d/docker.list &gt; /dev/null<br>sudo apt-get update<br>sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zsYuLDRvwzmYMu2qX5THKQ.png" /><figcaption>Screenshot of the official Docker documentation</figcaption></figure><h4>Setup the server environment for the docker container</h4><p>Before spinning up the container there are a couple of things we want to do. <br>First make a folder containing all our docker configurations. Be aware that you should change your user and user groups to yours in my example. It’s also possible to use other folders to store the configuration, if you do so you also will need to adapt the container setup later on.</p><pre>sudo mkdir /docker<br>sudo chown sane:sane /docker</pre><p>Now make a folder containing the container we are about to spin up.</p><pre>mkdir -p /docker/sane/config<br>mkdir -p /docker/sane/images</pre><p>Now make a file containing the configuration.</p><pre>nano /docker/sane/config/config.local.js</pre><p>Paste the following contents into the file. This example is based on the documentation on <a href="https://github.com/sbs20/scanservjs/blob/master/docs/10-configuration.md#example-file">github</a>.</p><p>The device id is derived from the <em>AIRSCAN_DEVICES</em> environment variable of the docker container. The device name can be whatever you want.</p><p>If you look carefully you can see I specified the resolutions for my scanner. In case you have another scanner than mine, read the documentation in order to figure how to change the them for yours.</p><pre>/* eslint-disable no-unused-vars */<br><br>module.exports = {<br>  afterDevices(devices) {<br> const deviceNames = {<br>      /*<br>        &#39;device id&#39;:&#39;device name&#39;<br>      */<br>      &#39;airscan:e0:Hp Envy Pro 6442&#39;: &#39;Hp Envy Pro 6442&#39;<br>    };<br> <br>/*<br>  replace the id in the filter<br>*/<br> devices<br>      .filter(d =&gt; d.id == &#39;airscan:e0:Hp Envy Pro 6442&#39;)<br>      .forEach(device =&gt; {<br>        device.features[&#39;--resolution&#39;].default = 400;<br>        device.features[&#39;--resolution&#39;].options = [100, 150, 200, 300, 400, 600];<br>        /*<br>          Disable batch modes if they are not available on your printer<br>        */<br>         device.settings.batchMode.options = [&#39;none&#39;, &#39;manual&#39;];<br>         /*<br>         Specify the default pipeline<br>         */<br>         device.settings.pipeline.default = [&#39;PNG&#39;];<br>      });<br> <br>  devices<br>      .filter(d =&gt; d.id in deviceNames)<br>      .forEach(d =&gt; d.name = deviceNames[d.id]);<br>  }<br>};</pre><p><strong>Scantopl pipeline for uploading to Paperles-ng</strong></p><p>With this additional configuration you can automatically upload scanned documents to Paperless</p><pre>const options = { paths: [&#39;/usr/lib/scanservjs&#39;] };<br>const Process = require(require.resolve(&#39;./server/classes/process&#39;, options));<br><br>afterConfig(config) {<br>    const pipelines = [<br>      {<br>        extension: &#39;pdf&#39;,<br>        description: &#39;Paperless&#39;,<br>        commands: [<br>        &#39;convert @- -quality 100 tmp-%04d.png &amp;&amp; ls tmp-*.png&#39;,<br>        &#39;convert @- scan-0000.pdf&#39;,<br>        &#39;ls scan-*.*&#39;<br>        ],<br>        afterAction: &#39;Rename for paperless&#39;<br>      }<br>    ];<br><br>    config.pipelines.splice(0, 0, ...pipelines);<br>  },<br>  actions: [<br>    {<br>      name: &#39;Rename for paperless&#39;,<br>      async execute(fileInfo) {<br>        return await Process.spawn(`mv &#39;${fileInfo.fullname}&#39; &#39;${fileInfo.path}/pl_${fileInfo.name}&#39;`);<br>      }<br>    }<br>  ]</pre><h4>Spin up the docker container</h4><p>Now it’s finally time to setup our awesome scan server through docker.</p><p>You should read the documentation on <a href="https://github.com/sbs20/scanservjs/blob/master/docs/02-docker.md">github </a>about this topic if you have any issues.</p><p>In the example command you should change the <em>SANED_NET_HOSTS</em> and <em>AIRSCAN_DEVICES</em> to fit the settings of your scanner. If you change the device id in the <em>AIRSCAN_DEVICES</em> variable you’ll need to adjust the provided configuration file.</p><p>I also deviated a bit from the suggested configuration changing the web port mapping. In my opinion it’s better to use the default web port, so that users can type the address of the server without specifying any port.</p><p>Docker command</p><pre>docker run -d \<br>  -e SANED_NET_HOSTS=&quot;192.168.0.70&quot; \<br>  -e AIRSCAN_DEVICES=&#39;&quot;Hp Envy Pro 6442&quot; = &quot;http://192.168.0.70/eSCL&quot;&#39; \<br>  -p 80:8080 \<br>  -v /var/run/dbus:/var/run/dbus \<br>  -v /docker/sane/config:/etc/scanservjs \<br>  -v /docker/sane/images:/var/lib/scanservjs/output \<br>  --restart unless-stopped \<br>  --name scanservjs-container \<br>  --privileged sbs20/scanservjs:latest</pre><p>Docker compose</p><pre>version: &quot;3&quot;<br>services:<br>  scanservjs:<br>    image: sbs20/scanservjs:latest<br>    privileged: true<br>    environment:<br>      - UID=${UID}<br>      - GID=${GID}<br>      - SANED_NET_HOSTS=${SANED_NET_HOSTS}<br>      - AIRSCAN_DEVICES=${AIRSCAN_DEVICES}<br>    volumes:<br>      - /docker/sane/images:/var/lib/scanservjs/output<br>      - /docker/sane/config:/etc/scanservjs<br>      - /var/run/dbus:/var/run/dbus<br>    ports:<br>      - ${WEB_PORT}:8080<br>    restart: unless-stopped<br>  scantopl:<br>    image: ghcr.io/celedhrim/scantopl:master<br>    environment:<br>      - PLURL=http://paperless.instance<br>      - PLTOKEN=paperless_token<br>    volumes:<br>      - /docker/sane/images:/output</pre><p>Once you execute this command you’ve setup your own scan server ! <br>This web interface is just awesome.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9syP6JpIVOlGaZH_aExeNA.png" /><figcaption>Screenshot of the scan server</figcaption></figure><h3>Remarks</h3><p>You could set up the scan server with multiple devices. If you have scanners from different manufacturers (or maybe different models) you will need to figure out the driver situation for each of them.</p><p>I also noted some issues with my particular scanner. When trying to scan with some resolutions my scanner would crash (that’s why I specified them in the configuration file). If you have a different device than mine you should make sure you test this.</p><p>Another issue that I found out is with the combination of scanner source and batch selection. By example if you choose the flatbed and the automatic batch selection the scanner would crash.<br>Choosing the ADF source with a manual batch selection will have the same effect. This is the only hurdle that I wasn’t able to figure out. This is not so user friendly since every time this happens the scanner needs to be restarted. If you figure this one out please let me know how figured this one out.</p><h3>Further suggestions</h3><h4>Network scanner</h4><p>Do you want to make your scans available over the network ?<br>Then you should need to map <em>/docker/sane/images</em> to a network share.<br>I won’t provide the detailed instructions since this write-up is already long enough. But I’ll give you some hints. (<a href="https://linuxhint.com/mount-smb-shares-ubuntu/">extra documentation</a>)</p><pre>sudo apt install smbclient -yq<br>sudo apt install cifs-utils<br>sudo nano /etc/fstab<br><br>#add this line to the fstab file<br>//fileserver/Scans /docker/sane/images/ cifs username=guest,iocharset=utf8,file_mode=0777,dir_mode=0777<br><br>sudo reboot</pre><h4>Setup print server</h4><p>This is another write-up on its own and it might not be related to this topic.<br>But since you went to the trouble of setting up a scan server, you could also setup <a href="http://www.cups.org/">CUPS</a> to have your own print server, which by the way is much easier than what we just did.</p><h4>Setting up Portainer</h4><p>Since we setup Docker we could also install <a href="https://www.portainer.io/">Portainer</a> to have a nice management interface for docker. You can find the official setup guide on this <a href="https://docs.portainer.io/start/install/server/docker/linux">page</a>.</p><p>If you have any remarks or suggestions please let me know …</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=21539f64265c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>