Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jen-soft/pydocker
Easy generator Dockerfile for humans
https://github.com/jen-soft/pydocker
deploy docker docker-image dockerfile for-humans pydocker python
Last synced: 4 days ago
JSON representation
Easy generator Dockerfile for humans
- Host: GitHub
- URL: https://github.com/jen-soft/pydocker
- Owner: jen-soft
- License: mit
- Created: 2019-04-29T13:11:30.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-01-03T23:36:07.000Z (about 3 years ago)
- Last Synced: 2024-03-14T22:23:52.927Z (10 months ago)
- Topics: deploy, docker, docker-image, dockerfile, for-humans, pydocker, python
- Language: Python
- Size: 31.3 KB
- Stars: 33
- Watchers: 5
- Forks: 61
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.Apache-2.0
Awesome Lists containing this project
README
# pydocker
Easy generator Dockerfile for humansLet's use power of python for generate dockerfile!
Advantages:
- all features from python: variables, multiline strings, code reuse.
- keep all your code in one file [bash, python, conf, ...]
- generate many docker files from one template [testing, production, ]
- generate sequence [Dockerfile.debian => Dockerfile.python => Dockefile.yourapp, ...]
- or if you not expert in sed, awk - you can use python for modify conf files : )
easy code, easy costomize# Install
# sudo apt-get install python-setuptools && sudo easy_install pip
pip install -U pydocker# Using
# Dockerfile.py
```python
import sys
import logging
import pydocker # github.com/jen-soft/pydockerlogging.getLogger('').setLevel(logging.INFO)
logging.root.addHandler(logging.StreamHandler(sys.stdout))class DockerFile(pydocker.DockerFile):
""" add here your custom features """d = DockerFile(base_img='debian:8.2', name='jen-soft/custom-debian:8.2')
d.RUN_bash_script('/opt/set_repo.sh', r'''
```
```bash
cp /etc/apt/sources.list /etc/apt/sources.list.copycat >/etc/apt/sources.list <_ console:
python3 Dockerfile.py
docker images
```## Alternative uage:
- install from repo (without pip)
```bahs
F=$(python -c "import site; print(site.getsitepackages()[0]+'/pydocker.py')")
sudo wget -v -N raw.githubusercontent.com/jen-soft/pydocker/master/pydocker.py -O $F
```- without any installation:
```python
try: from urllib.request import urlopen # python-3
except ImportError: from urllib import urlopen # python-2
exec(urlopen('https://raw.githubusercontent.com/jen-soft/pydocker/master/pydocker.py').read())
#
d = DockerFile(base_img='debian:8.2', name='jen-soft/custom-debian:8.2')
# ...
```
* Helpful if you need just build img
- not required installation
```python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
try:
from pydocker import DockerFile # pip install -U pydocker
except ImportError:
try:
from urllib.request import urlopen # python-3
except ImportError:
from urllib import urlopen # python-2
#
exec(urlopen('https://raw.githubusercontent.com/jen-soft/pydocker/master/pydocker.py').read())
#
import sys
import logginglogging.getLogger('').setLevel(logging.INFO)
logging.root.addHandler(logging.StreamHandler(sys.stdout))class MyDockerFile(DockerFile):
""" add here your custom features """
#d = MyDockerFile(base_img='debian:8.2', name='jen-soft/debian:8.2')
# ...
```
* Helpful if you need share your Dockerfile.py## License
This work is dual-licensed under **Apache License 2.0** and **MIT License**.
You can choose between one of them if you use this work.