ser2net icon indicating copy to clipboard operation
ser2net copied to clipboard

Official Docker container image for ser2net? (Dockerfile + docker-compose)

Open jippi opened this issue 3 years ago • 5 comments

Hey!

Thanks for an amazing project, I've been using it very successfully with zigbee2mqtt's support for remote adapters.

Coming from the ser2net v2 that was bundled with my OS, v4 is a significant improvement across the board so far.

Since I don't like to fill my host system with a bunch of packages and services, I run ser2net within Docker. However, I couldn't find any Docker image of ser2net providing more recent version than v2, so I ended up making one.

I'm sharing it here in case you want to provide official Docker builds for the project or in case someone else in the future happen to have the same need as I do on a Pi or similar (I use it on a QNAP NAS).

I would be happy to help doing some of the work required to ship these Docker images automatically as part of your project, and if you don't want to support this as part of the core project, I would be happy to setup an unofficial Docker image for the project.

I have experience doing this kind of work for other Open Source projects like Pritunl and my work as Platform engineer :)

Dockerfile

FROM debian:bullseye

ARG DEBIAN_FRONTEND=noninteractive
ARG ROOM_ASSISTANT_VERSION=latest
ARG VERSION=4.3.8

RUN set -ex \
    && apt-get update \
    && apt-get install -y libgensio-dev libyaml-dev build-essential wget automake libtool openipmi make pkg-config tini \
    && wget -O /tmp/ser2net.tar.gz https://github.com/cminyard/ser2net/archive/refs/tags/v${VERSION}.tar.gz \
    && tar zxfv /tmp/ser2net.tar.gz -C /tmp \
    && (cd /tmp/ser2net-${VERSION} && ls && ./reconf && ./configure --sysconfdir=/etc && make && make install) \
    && rm -rf \
        /var/lib/apt/lists/* \
        /tmp/ser2net.tar.gz \
        /tmp/ser2net-${VERSION} \
    && apt-get remove -y build-essential wget automake libtool openipmi make pkg-config \
    && apt-get autoremove -y \
    && apt-get clean

ENTRYPOINT ["tini", "--", "ser2net", "-d", "-l", "-c", "/etc/ser2net/ser2net.yaml"]

Docker Compose

version: '3.4'
services:
  ser2net:
    image: $your_image_uri_here
    network_mode: host
    restart: unless-stopped
    volumes:
      - ./ser2net.yaml:/etc/ser2net/ser2net.yaml
    devices:
      - /dev/ttyUSB0

ser2net.yaml

connection: &con01
  accepter: tcp,20108
  connector: serialdev,/dev/ttyUSB0,115200n81,local
  options:
    kickolduser: true

Building multi-arch image with buildx

Using Makefile, the build will look like below, which will build a arm64 and amd64 container image automatically

REGISTRY := $YOUR_REGISTRY
PLATFORMS := linux/arm64/v8,linux/amd64
VERSION := 4.3.8 # note, omit the "v" in the tag name
TAG := $(VERSION)

ser2net:
	docker buildx build --pull --push --platform $(PLATFORMS) \
		--tag $(REGISTRY)/iwisystems/docker/ser2net:$(TAG) \
		--build-arg VERSION=$(VERSION) \
		. # Assuming the Dockerfile exist in the same path as you run the command

jippi avatar Sep 10 '22 16:09 jippi

On Sat, Sep 10, 2022 at 09:43:06AM -0700, Christian Winther wrote:

Hey!

Thanks for an amazing project, I've been using it very successfully with zigbee2mqtt's support for remote adapters.

Coming from the ser2net v2 that was bundled with my OS, v4 is a significant improvement across the board so far.

Yeah, it's gone through a few revisions since then :). Mostly driven by user feedback.

Since I don't like to fill my host system with a bunch of packages and services, I run ser2net within Docker. However, I couldn't find any build of ser2net providing more recent version than v2, so I ended up making one.

I'm sharing it here in case you want to provide official Docker builds for the project or in case someone else in the future happen to have the same need as I do on a Pi or similar (I use it on a QNAP NAS).

I would be happy to help doing some of the work required to ship these Docker images automatically as part of your project, and if you don't want to support this as part of the core project, I would be happy to setup an unofficial Docker image for the project.

I have very little practical experience with docker. The docker on my system doesn't even have the buildx command.

However, I'd be happy for you to support this in the sourceforge or github repositories. How would you like to proceed with this?

-corey

I have experience doing this kind of work for other Open Source projects like Pritunl and my work as Platform engineer :)

Dockerfile

FROM debian:bullseye

ARG DEBIAN_FRONTEND=noninteractive
ARG ROOM_ASSISTANT_VERSION=latest
ARG VERSION=4.3.8

RUN set -ex \
    && apt-get update \
    && apt-get install -y libgensio-dev libyaml-dev build-essential wget automake libtool openipmi make pkg-config tini \
    && wget -O /tmp/ser2net.tar.gz https://github.com/cminyard/ser2net/archive/refs/tags/v${VERSION}.tar.gz \
    && tar zxfv /tmp/ser2net.tar.gz -C /tmp \
    && (cd /tmp/ser2net-${VERSION} && ls && ./reconf && ./configure --sysconfdir=/etc && make && make install) \
    && rm -rf \
        /var/lib/apt/lists/* \
        /tmp/ser2net.tar.gz \
        /tmp/ser2net-${VERSION} \
    && apt-get remove -y build-essential wget automake libtool openipmi make pkg-config \
    && apt-get autoremove -y \
    && apt-get clean

ENTRYPOINT ["tini", "--", "ser2net", "-d", "-l", "-c", "/etc/ser2net/ser2net.yaml"]

Docker Compose

version: '3.4'
services:
  ser2net:
    image: $your_image_uri_here
    network_mode: host
    restart: unless-stopped
    volumes:
      - ./ser2net.yaml:/etc/ser2net/ser2net.yaml
    devices:
      - /dev/ttyUSB0

ser2net.yaml

connection: &con01
  accepter: tcp,20108
  connector: serialdev,/dev/ttyUSB0,115200n81,local
  options:
    kickolduser: true

Building multi-arch image with buildx

Using Makefile, the build will look like below, which will build a arm64 and amd64 container image automatically

REGISTRY := $YOUR_REGISTRY
PLATFORMS := linux/arm64/v8,linux/amd64
VERSION := latest
TAG := $(VERSION)

ser2net:
	docker buildx build --pull --push --platform $(PLATFORMS) \
		--tag $(REGISTRY)/iwisystems/docker/ser2net:$(TAG) \
		--build-arg VERSION=$(VERSION) \
		repositories/jippi/ser2net

-- Reply to this email directly or view it on GitHub: https://github.com/cminyard/ser2net/issues/75 You are receiving this because you are subscribed to this thread.

Message ID: @.***>

cminyard avatar Sep 10 '22 17:09 cminyard

@cminyard This is what I whipped up tonight :) https://github.com/jippi/docker-ser2net

It will build amd64, arm64 and armhf multi architecture Docker image that should work on all modern hardware as well as most Raspberry Pi and other mini-ARM devices (and of course Apple Silicon / M1 / M2 / MX)

Need a bit of testing, but once its in place, I can run a nightly script to build any new tags like I've done with Pritunl :)

jippi avatar Sep 10 '22 23:09 jippi

@cminyard, what are your thoughts on the above? is it an acceptable solution to you? should the build flags or other adjustments be made for it to be in a solid delivery and stable quality?

jippi avatar Sep 15 '22 18:09 jippi

On Thu, Sep 15, 2022 at 11:43:17AM -0700, Christian Winther wrote:

@cminyard, what are your thoughts on the above? is it an acceptable solution to you? should the build flags or other adjustments be made for it to be in a solid delivery and stable quality?

Those should be good. My goal has been to make the defaults the right thing for the most part.

It does depend on what is installed in the container, especially openssl.

-corey

cminyard avatar Sep 15 '22 23:09 cminyard

Great! I love good defaults.

The container image should be bundled with all the latest versions of all packages from debian:bullseye

jippi avatar Sep 15 '22 23:09 jippi