https://github.com/f1nnix/docker-enfetch
A tiny tools to pull existing Docker compose' environmental variables to re-usable YAML config
https://github.com/f1nnix/docker-enfetch
docker docker-compose docker-environment dockerfiles
Last synced: about 2 months ago
JSON representation
A tiny tools to pull existing Docker compose' environmental variables to re-usable YAML config
- Host: GitHub
- URL: https://github.com/f1nnix/docker-enfetch
- Owner: f1nnix
- Created: 2017-07-02T08:47:38.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2022-12-08T02:50:08.000Z (over 3 years ago)
- Last Synced: 2025-02-04T18:42:35.661Z (over 1 year ago)
- Topics: docker, docker-compose, docker-environment, dockerfiles
- Language: Python
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# docker-enfetch
A tiny script to restore existing Docker containers' environmental variables to re-usable YAML config.
## Why?
Deploying an app with Docker-compose, you often split `compose`-file into several ones. Like:
```
docker-compose \
-f docker-compose.base.yml \ <== base file with common containers config
-f docker-compose.live.yml \ <== production-specific options
-f docker-compose.cred.yml \ <== credentials, like passwords, AWS keys,etc
up -d
```
File `docker-compose.cred.yml` is not commited into repository. But to update app, or deploy a new version, you need exactly the same `docker-compose.cred.yml`-file, which you initially deployed your app with.
**This small tool analyzes existing docker containers and restores original `compose` -files with environent variables.**
## Install
Just install deps:
```sh
cd
pip install -r requirements.txt
```
## Usage
Env into current docker-host // docker-mahcine profile like:
```
docker-machine env
eval $(docker-machine env )
```
After this, your docker env vars will be set (`DOCKER_TLS_VERIFY`, `DOCKER_HOST`, `DOCKER_CERT_PATH`, `DOCKER_MACHINE_NAME`, etc).
Start docker-enfetch:
```sh
python ~/docker-enfetch/enfetch.py
```
An output wiil be like:
```yml
version: 2
services:
db:
environment:
POSTGRES_PASSWORD:
web:
environment:
APP_URL:
DBPASS:
DEVISE_SECRET_KEY:
PORT: 80
RACK_ENV: production
RAILS_ENV: production
RAILS_SERVE_STATIC_FILES: 1
SECRET_KEY_BASE:
```
Obviously, insted of `` you'll get real creds from containers' env var.
So, pipe output into real file:
```sh
python ~/docker-enfetch/enfetch.py > live/docker-compose.creds.yml
```
And you'll done!
## LICENSE
(C) 2017, f1nnix, [WTFPL](https://en.wikipedia.org/wiki/WTFPL) license.