FROM python:3.7
COPY ./src /data/python
WORKDIR /data/python
RUN pip install --no-cache-dir flask
EXPOSE 8080
CMD ["python", "main.py"]
- main.py
import os
from flask import Flask
app = Flask(__name__)
@app.route('/')
def index():
return {'body': os.environ.items()}
def run():
app.run(host='0.0.0.0', port=8080)
if __name__ == '__main__':
run()
click invoke result
[
"2021-01-29T09:53:30.727847Z stdout: * Serving Flask app \"main\" (lazy loading)",
"2021-01-29T09:53:30.727905Z stdout: * Environment: production",
"2021-01-29T09:53:30.727913Z stdout: WARNING: This is a development server. Do not use it in a production deployment.",
"2021-01-29T09:53:30.727918Z stdout: Use a production WSGI server instead.",
"2021-01-29T09:53:30.727923Z stdout: * Debug mode: off",
"2021-01-29T09:53:30.731130Z stderr: * Running on http://0.0.0.0:8080/ (Press CTRL+C to quit)",
"2021-01-29T09:53:30.747035Z stderr: 172.30.139.167 - - [29/Jan/2021 09:53:30] \"\u001b[33mPOST /init HTTP/1.1\u001b[0m\" 404 -",
"2021-01-29T09:53:30.748Z stderr: The action did not initialize or run as expected. Log data might be missing."
]
I've added the Docker container to IBM Cloud Functions
What would be the best way to approach this?
Docker images which are uploaded to IBM Cloud Functions must implement certain REST interfaces. The easiest way to achieve this is to base your container on the
openwhisk/dockerskeleton
image.Please see How to run a docker image in IBM Cloud functions? and https://github.com/iainhouston/dockerPython for more details