Last active
September 13, 2015 03:46
-
-
Save benwilber/f45aa2dbbd4ef18498d0 to your computer and use it in GitHub Desktop.
self-contained, executable app slug creator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ mkdir helloworld | |
$ cd helloworld | |
$ git init . | |
$ virtualenv .venv | |
$ .venv/bin/pip install Flask | |
$ echo "*.pyc" > .gitignore | |
$ cat <<EOF > app.py | |
from os import getenv | |
from flask import Flask | |
app = Flask(__name__) | |
@app.route("/") | |
def root(): | |
return "Hello World!" | |
if __name__ == '__main__': | |
app.run( | |
port=int(getenv('PORT', 5000)), | |
debug=getenv('DEBUG') == "true") | |
EOF | |
$ git add . | |
$ git commit -m "initial commit" | |
$ slugify.sh . | |
$ ./run | |
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# | |
cat <<- "EOF" > run | |
#!/bin/bash | |
SKIP="$(awk '/^__COMPRESSED__/ { print NR + 1; exit 0; }' $0)" | |
cd "$(dirname $1)" | |
rm -rf extract | |
mkdir -p extract | |
tail -n +"$SKIP" "$1" | tar -zx -C extract | |
exec extract/.venv/bin/python app.py | |
__COMPRESSED__ | |
EOF | |
git archive HEAD | gzip >> run | |
chmod +x run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment