xirixiz / dsmr-reader-docker

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

Support for docker secrets #353

Closed frankforpresident closed 2 months ago

frankforpresident commented 2 months ago

Request

The official Postgres docker image supports docker secrets to set the database password. This seems not to be possible with this image?

If it is not yet available, I would awesome to have all env vars supported with a _FILE alternative or at least the list below:

Additional information

No response

xirixiz commented 2 months ago

Hi @frankforpresident, this is an out of the box feature of Docker, and not related to this image specifically.

Maybe this helps: https://medium.com/@laura_67852/docker-secrets-an-introductory-guide-with-examples-d25be5fc8e50

frankforpresident commented 2 months ago

Ah ok cool, thanks!

frankforpresident commented 2 months ago

@xirixiz,

Are you sure this is an out of the box feature?

https://docs.docker.com/engine/swarm/secrets/#build-support-for-docker-secrets-into-your-images.

I've tried it on an image of my own but it does not seem to populate the regular variable with the content of the _FILE variable.

xirixiz commented 2 months ago

Hi @frankforpresident, yes I`m 100% certain about this 😄

Maybe this link helps in a better way https://earthly.dev/blog/docker-secrets/

Are you running Docker in swarm mode? Are you using Docker, or are you using Podman? Podman support it, but it works differently (config).

frankforpresident commented 2 months ago

I'm using docker swarm with docker compose. I had a look at the blog post but they reference to the same

To make use of the secret, your application should read the contents from the in-memory, the temporary filesystem created under /run/secrets/secure-key

I was hoping that docker would store the contents of DJANGO_DATABASE_PASSWORD_FILE in DJANGO_DATABASE_PASSWORD in-memory but it doesn't seem to work this way? I hope I'm doing something wrong because I would like to enable this for every container in my deployment

When I have some time this weekend I will give it another shot with the image of this repo including a reproduction scenario. I will check Podman as well 👍

frankforpresident commented 2 months ago

FYI, it looks like i'm not the only one with this issue. https://stackoverflow.com/a/70006074

xirixiz commented 2 months ago

Yeah, I was checking it out, and it's a poor implementation of Docker I notice 😂, hence the solution in the link you've send. I'll have a look later, but as there isn't much demand for secrets, I'm not sure if it's valuable spending effort on this.

frankforpresident commented 2 months ago

@xirixiz,

I've implemented Docker secrets support in PR 354. Could you kindly review and confirm the modifications? I've conducted local testing, and the functionality appears to be functioning as expected.

xirixiz commented 2 months ago

Hi @frankforpresident ik heb jou PR gemerged in de main branch.

Omdat ik voor de dev branch over bent gestapt naar s6-verlay v3 zijn er een aantal wijzigingen doorgevoerd. Ik heb zojuist nog eea aangepast. Zou jij het eens kunnen testen met de development image en even willen laten weten of de Docker secrets nu nog naar behoren werkt. Beste test zou zijn:

Wanneer bovenstaande werkt, dan komt er maandag of dinsdag een nieuwe DSMR Reader Docker release met:

Thanks!

Build pipeline: https://github.com/xirixiz/dsmr-reader-docker/actions/runs/8678690182 Image: ghcr.io/xirixiz/dsmr-reader-docker:development

frankforpresident commented 2 months ago

Goed dat ik het even nakijk want de scripts zitten er niet in. Zal het gelijk even terug toevoegen en nog wat documentatie schrijven.

xirixiz commented 2 months ago

Nee, die zitten er wel in, alleen heb ik het onderdeel gemaakt van S6-overlay, anders gaat het niet goed samen. rootfs/etc/s6-overlay/s6-rc.d/docker-entrypoint

En dit deel: https://github.com/xirixiz/dsmr-reader-docker/blob/8bbc39196b4b4d873f425c5bfae751656540440a/rootfs/etc/s6-overlay/s6-rc.d/docker-entrypoint/run#L335-L356

frankforpresident commented 2 months ago

@xirixiz ,

Dockerfile was ook aangepast, zit dit ook ergens in de s6-overlay?

Wat moet ik uit mijn PR halen?

frankforpresident commented 2 months ago

Net even met de development tag getest en daar werkt het niet zoals verwacht

xirixiz commented 2 months ago

@xirixiz ,

Dockerfile was ook aangepast, zit dit ook ergens in de s6-overlay?

Wat moet ik uit mijn PR halen?

Hi Frank, ik zal even kijken of ik het kan fixen. S6-overlay (meer info: https://github.com/just-containers/s6-overlay). Je hoeft idd in de Dockerfile niets aan te passen.

Ik zie wel dit voorbij komen in de development tag:

[ INFO ] /etc/s6-overlay/s6-rc.d/docker-entrypoint/docker-entrypoint.d/ is not empty, will attempt to perform configuration
[ INFO ] Looking for shell scripts in /etc/s6-overlay/s6-rc.d/docker-entrypoint/docker-entrypoint.d/
[ INFO ] Ignoring Docker secret /etc/s6-overlay/s6-rc.d/docker-entrypoint/docker-entrypoint.d/.gitkeep
[ INFO ] Ignoring Docker secret /etc/s6-overlay/s6-rc.d/docker-entrypoint/docker-entrypoint.d/.env-from-docker-secrets
[ INFO ] Docker secrets configuration complete; ready for start up...

Dus ik denk dat het eenvoudig is op te lossen 👍

xirixiz commented 2 months ago

Hoi @frankforpresident , ik heb even de docu erop nageslagen en volg graag het pad dat linuxserver.io ook gebruikt:

In de baseimage is een script voor het uitlezen van de secrets:

In een andere image staat uitgelegd hoe daar gebruik van te maken (readme):

Ik heb het zojuist geimplementeerd in de development image en ben nu een nieuwe image aan het bouwen zodat het getest kan worden.

xirixiz commented 2 months ago

Getest en toegevoegd aan de nieuwe release.