xirixiz / dsmr-reader-docker

DSMR Reader in Docker.
https://hub.docker.com/r/xirixiz/dsmr-reader-docker
112 stars 33 forks source link

Update base image to python:3-alpine3.17 #319

Closed stejoo closed 1 year ago

stejoo commented 1 year ago

Alpine 3.17 points metapkg postgresql-client to postgresql15-client. Adds support for Postgresql 15 databases.

Other important changes in the Alpine 3.17 release announcement: https://alpinelinux.org/posts/Alpine-3.17.0-released.html

Significant change might be the use of OpenSSL 3.0 as a default, which drops OpenSSL 1.1. Nginx in the current image is built against OpenSSL 1.1, which switches over to OpenSSL 3.0 in this 3.17 variant. This shouldn't change anything from a configuration perspective, so users shouldn't notice this. But I also haven't tested it myself.

xirixiz commented 1 year ago

Hi @stejoo, did you validate a build with this image? I've tested it a while ago, but there were some issues with Python library dependencies....

If not tested, I can test it.

stejoo commented 1 year ago

I did not test a build with this change. I would have liked to, but was unable. Building the container image using the Dockerfile failed because of these COPY statements:

https://github.com/xirixiz/dsmr-reader-docker/blob/f08ee1283106a7e5722fdc314e844c0cfd95cae6/Dockerfile#L40-L42

I was doing this inbetween talks at a conference and it wasn't immediately clear to me how you prepared your /tmp beforehand. So I thought maybe some automated testing is set up to kick off when there is a PR. :wink: And left it at that for the moment.

I came home a short while ago, had a second look and found build_release.yml contains various preparations that populate /tmp.

I would like to test and try to iron out any kinks if I can. Perhaps I could try to replicate the actions described in the build_release.yml file on my system by hand. Or do you have some easier way to perform the required actions locally?

stejoo commented 1 year ago

I created a build.sh script from your Github Actions to locally build and test the container image. (If anybody is interested in that I could put it in a gist or pastebin somewhere).

What happened first is a conflict between openssl and libressl. The packages touch the same files and therefor come in conflict with eachother. Alpine 3.17 upgraded OpenSSL to version 3.x up from (legacy) v1.1.x. LibreSSL seemed to have been present to add various functionalities OpenSSL v1.1 did not offer. Removing libressl-dev as a package allowed me to successfully build the container image.

Running it is where it goes wrong now:

2023/02/20 13:14:18 [emerg] 312#312: "upstream" directive is not allowed here in /etc/nginx/conf.d/dsmr-webinterface.conf:1
nginx: [emerg] "upstream" directive is not allowed here in /etc/nginx/conf.d/dsmr-webinterface.conf:1

I started to compare the Nginx configurations. The ones I compared matter are the main nginx.conf and the dsmr-webinterface.conf file.

Maybe a difference in the nginx version?

No difference in version. Could be in build options, haven't dug that deep yet.

When I find the time I will try to dig deeper. Currently, where I am at: nginx isn't starting because of a configuration issue.

xirixiz commented 1 year ago

Great! This is indeed where I also bumped into and never spend time on it to solve this. Ill create a dev branch so dev builds will be created for testing. If you like, you could also work on the dev branch and use the github pipelines instead. Ill check it this week.

stejoo commented 1 year ago

I think I've got it. :smile:

Got rid of LibreSSL. Did make an assumption it is not needed anymore, because OpenSSL now offers the same functionality. But that will require testing of different configurations and use cases I guess.

The nginx configuration went awry because the /etc/nginx/conf.d was a symlink to /etc/nginx/http.d. Nginx includes configuration files from both, but those are loaded in different context. Small snippet of the nginx.conf:

[..]
# Include files with config snippets into the root context.
include /etc/nginx/conf.d/*.conf;

http {
[..]
    # Includes virtual hosts configs.
    include /etc/nginx/http.d/*.conf;
}

The http.d/dsmr-webinterface.conf contains an upstream { } and a server { } block, which need to exist within a http{} block and not outside it. The first include would find them and there the story would end. I turned /etc/nginx/conf.d in a real, empty, directory. Causing dsmr-webinterface.conf to be include within the http{ } block.

Performed a quick test: it seems to now be working for me :stuck_out_tongue_winking_eye:

xirixiz commented 1 year ago

Great job! Thanks for helping out. I'll validate the changes as well and if all is good, I can merge it to a new release!

Thanks again for your contribution! Very much appreciated 🎉

xirixiz commented 1 year ago

Sorry, I have been quiet busy. I wlll respond asap!

stejoo commented 1 year ago

Maak je niet druk, ik weet hoe dat gaat; er zijn belangrijkere dingen in het leven. Het is maar een update van het spul. Er loopt geen bloed uit :wink:

No worries! I know what it's like; some things in life are more important. It is just an update. Not something of utmost importance. :wink: