Code Monkey home page Code Monkey logo

hayaku's Introduction

Hayaku - a lightweight Python utility to generate Dockerfile and distribute tiny python tooling/apps without explicitly including sources

Build Status

Instalation

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

  1. Autodetect of required pypi packages to install
  2. Encode py sources with base64/zip/bzip
  3. Put encoded data into of generated Dockerfile ENV (According to POSIX we can put up to 256Mb into env variable)
ENV PY_LIB "{body}"
  1. Extract it during docker build within the image
RUN python -c "import os,base64;b=os.getenv('PY_LIB');b=base64.b64decode(b);print(b.decode('utf-8'))" | tee app.py
  1. Final generated Dockerfile will looks like
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...

Seriously ?

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.

Limitation

Does not work with multi file modules and local packages (TBD)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.