Hayaku - tooling for generating dockerfile
Project description
Hayaku - lightweight Python utility to generate Dockerfile and distribute tiny python apps without including sources
[![Build Status](https://travis-ci.org/msoedov/hayaku.svg?branch=master)](https://travis-ci.org/msoedov/hayaku)
## Instalation
```shell
pip install hayaku
```
## Why?
Disclaimer this repo being made just for fun in certain circumstances and have non opinionated approach for doing things.
The purpose of this is to wrap your existing tooling written in python into containers and then ship/distribute it without complicated
workflow around git repo's.
## Approach
0. Autodetect of required pip packages which needs to be installed
1. Encode py sources with base64/zip/bzip
2. Put encoded data into of generated `Dockerfile` ENV (According to POSIX we can put up to 256Mb into env variable)
```shell
ENV PY_LIB "{body}"
```
3. Extract it during docker build
```shell
RUN python -c "import os,base64;b=os.getenv('PY_LIB');b=base64.b64decode(b);print(b.decode('utf-8'))" | tee app.py
```
4. So the final generated Dockerfile will looks like this
```shell
hayaku app.py
FROM python:3.6
MAINTAINER Erlich Bachman
WORKDIR /app
RUN pip install requests
ENV PY_LIB "aW1wb3J0IGJhc2U2NAppbXBvcnQgb3MKZnJvbSB...."
RUN python -c "import os,base64;b=os.getenv('PY_LIB');b=base64.b64decode(b);print(b.decode('utf-8'))" | tee app.py
CMD python app.py
```
which you can ship as a file, build and push image to private docker registry, etc...
## Seriosly ?
It's up to you. It worked for my limited usecase and I hope it might be helpfull for somebody else. As it said in disclamer: this repo being made just for fun in certain circumstances and have non opinionated approach for doing such things.
[![Build Status](https://travis-ci.org/msoedov/hayaku.svg?branch=master)](https://travis-ci.org/msoedov/hayaku)
## Instalation
```shell
pip install hayaku
```
## Why?
Disclaimer this repo being made just for fun in certain circumstances and have non opinionated approach for doing things.
The purpose of this is to wrap your existing tooling written in python into containers and then ship/distribute it without complicated
workflow around git repo's.
## Approach
0. Autodetect of required pip packages which needs to be installed
1. Encode py sources with base64/zip/bzip
2. Put encoded data into of generated `Dockerfile` ENV (According to POSIX we can put up to 256Mb into env variable)
```shell
ENV PY_LIB "{body}"
```
3. Extract it during docker build
```shell
RUN python -c "import os,base64;b=os.getenv('PY_LIB');b=base64.b64decode(b);print(b.decode('utf-8'))" | tee app.py
```
4. So the final generated Dockerfile will looks like this
```shell
hayaku app.py
FROM python:3.6
MAINTAINER Erlich Bachman
WORKDIR /app
RUN pip install requests
ENV PY_LIB "aW1wb3J0IGJhc2U2NAppbXBvcnQgb3MKZnJvbSB...."
RUN python -c "import os,base64;b=os.getenv('PY_LIB');b=base64.b64decode(b);print(b.decode('utf-8'))" | tee app.py
CMD python app.py
```
which you can ship as a file, build and push image to private docker registry, etc...
## Seriosly ?
It's up to you. It worked for my limited usecase and I hope it might be helpfull for somebody else. As it said in disclamer: this repo being made just for fun in certain circumstances and have non opinionated approach for doing such things.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
hayaku-0.1.2.tar.gz
(2.6 kB
view details)
File details
Details for the file hayaku-0.1.2.tar.gz
.
File metadata
- Download URL: hayaku-0.1.2.tar.gz
- Upload date:
- Size: 2.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e746d63b5a5d3904767ae4fad90b012fcc8f996a550452e9d5fb5c9c4592e661 |
|
MD5 | 2e24a7f88e7428a28ab1edcfd1dfa87f |
|
BLAKE2b-256 | 62176011908ddf35abc1d1b23e827a7e67f0726d9745761851010c9d0f03a861 |