Skip to content

Instantly share code, notes, and snippets.

@cellularmitosis
Last active October 15, 2019 07:31
Show Gist options
  • Save cellularmitosis/a5ffa13236548d36a2d89bef0725faef to your computer and use it in GitHub Desktop.
Save cellularmitosis/a5ffa13236548d36a2d89bef0725faef to your computer and use it in GitHub Desktop.
A Dockerized Flask "Hello, World!"

Blog 2019/8/16

<- previous | index | next ->

A Dockerized Flask "Hello, World!"

cobbled together from a few tutorials online.

Just run make.

FROM python:3-alpine
WORKDIR /opt/hello-flask
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
CMD ["python", "./hello-flask.py"]
#!/usr/bin/env python
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_flask():
return "Hello, Flask!"
if __name__ == '__main__':
# enable debug mode by setting the env var FLASK_ENV=development
app.run(host='0.0.0.0', port=80)
run: build
docker run -it --rm -p 5000:80 -e FLASK_ENV='development' hello-flask
build:
docker build -t hello-flask .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment