I'm trying to get gunicorn working with nginx in a docker compose file. My python code is just a flask CRUD app.
The entry point for my flask app is at ./flask_app/app.py and I've got the following for a docker compose yaml file
version: '3'
services:
flask_app:
container_name: flask_app
restart: always
build: ./flask_app
ports:
- "8000:8000"
command: gunicorn -w 1 -b :8000 app:server
nginx:
container_name: nginx
restart: always
build: ./nginx
ports:
- "80:80"
depends_on:
- flask_app
and here's my app file
from flask import Flask
from flask_marshmallow import Marshmallow
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.config.from_pyfile('config.py')
db = SQLAlchemy(app)
ma = Marshmallow(app)
if __name__ == '__main__':
app.run(host='0.0.0.0', port=6000, debug=True)
However when I run the above I'm getting the following error
Recreating ce38627418c1_ce38627418c1_ce38627418c1_ce38627418c1_ce38627418c1_flask_app ... error
ERROR: for ce38627418c1_ce38627418c1_ce38627418c1_ce38627418c1_ce38627418c1_flask_app Cannot start service flask_app: OCI runtime create failed: container_linux.go:296: starting container process caused "exec: \"gunicorn\": executable file not found in $PATH": unknown
ERROR: for flask_app Cannot start service flask_app: OCI runtime create failed: container_linux.go:296: starting container process caused "exec: \"gunicorn\": executable file not found in $PATH": unknown
ERROR: Encountered errors while bringing up the project.
As far as I can tell it doesn't seem my app = Flask(__name__)
variable and I'm not sure why. I'm basing my approach on this working example https://github.com/sladkovm/docker-flask-gunicorn-nginx.
Does anyone have any ideas?
EDIT: In my flask_app directory I have a Dockerfile that the docker_compose file is pointing to. Here is what it looks like:
FROM python:3.6.2
RUN mkdir -p /flask_app/app
WORKDIR /flask_app/app
COPY . /flask_app/app
RUN pip install --no-cache-dir -r requirements.txt
COPY . /flask_app/app