I’ve migrated off of Portainer to standard docker compose recently so that I can script some major tasks like updating all the containers or restarting all of them. I also liked the idea of being able to put the compose files into a git repo and push it up so that they are automatically backed up. I hope to be able to turn this into more of infrastructure as code implementation where I can edit the repo and have it auto push to my server and redeploy. That’s a bit further down the line though.

That said, with the compose files living in their remote, they currently still have their secrets on them, either in a corresponding .env file or in the compose file itself. I really don’t like this since if someone ever gains access to the repo they have all my services’ secrets. What is the best way to use a git repo for compose files while not exposing a bunch of secrets potentially?

I know podman supports secrets, though I guess I’d have to manually ssh into the server to create them in the session. Currently these services are all through docker however.

  • Rikudou_Sage
    link
    fedilink
    English
    141 year ago

    I usually use a .env.example file which contains all non-secret variables filled and all secret variables defined with no value.

    The secrets are stored in the secret store of GitHub/GitLab (depending on what I’m using). During deploy the .env.example file is copied to .env and all the secret variables are written into the file (which itself is in .gitignore to avoid accidentally committing the local version on my machine).