Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker-compose: no gunicorn when trying "up" container

I'm facing with issue when I try to "up" my container on DigitalOcean env. I have Ubuntu Docker 1.7.1 on 14.04 as env droplet. There is the next error.

mysite | ./docker-entrypoint: line 8: exec: gunicorn: not found

This is my Dockerfile where I tried to add gunicorn setup by (apt-get, pip). Sadly but it doesn't work I have the same issue with missed gunicorn module.

Dockerfile

FROM python:2.7.7

RUN curl -sL https://deb.nodesource.com/setup | bash -
RUN apt-get -y install nodejs
RUN apt-get -y install libpango1.0-0 libgdk-pixbuf2.0-0

RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY . /usr/src/app

VOLUME /usr/src/app/venv
VOLUME /usr/src/app/node_modules
VOLUME /usr/src/app/static

ENTRYPOINT ["./docker-entrypoint"]

Additionally I tried to add gunicorn setup to the entry point file which also didn't work there is "no gunicorn module" error still. I guess it wasn't a great idea to add it here but anyway I've checked.

Docker entry point

#!/bin/bash
set -e

if [[ -e venv/bin/activate ]]; then
    source venv/bin/activate
fi

exec "$@"

docker-compose.yml

source:
  extends:
    file: docker-compose-common.yml
    service: prod
  build: .
  command: bin/install

redis:
  image: redis:latest
  command: redis-server --appendonly yes

mysite:
  extends:
    file: docker-compose-common.yml
    service: prod
  image: mysitecatalogweb_source
  volumes_from:
    - source
  environment:
    - SITE_ID=1
  command: gunicorn -k gevent -b 0.0.0.0:8000 --access-logfile - --error-logfile - mysite.wsgi

docker-compose-common.yml

dev:
  environment:
    - PYTHONUNBUFFERED=1
    - ENV=DEV
    - POSTGRES_HOST=host
    - POSTGRES_USER=user
  env_file: dev.env

prod:
  environment:
    - ENV=PROD
  env_file: prod.env

Maybe I need to add gunicorn setup to the bin/install directly (which should be called from source task) but this is also can be found in the requirements.txt EDITED: I've tried to add gunicorn here and it is still mysite | ./docker-entrypoint: line 8: exec: gunicorn: not found

bin/install

set -e

pip install virtualenv
if [[ ! -e venv/bin/activate ]]; then
  virtualenv venv
  source venv/bin/activate
fi

pip install -r requirements.txt

mkdir -p static/js
npm install
npm run browserify

Also check my requirements.txt https://gist.github.com/alexnodejs/3789b4eb7621687e010b

Maybe someone already bumped with similar issue with unicorn? Please advise where I should dig.

like image 658
Alexander Vasileyko Avatar asked Jul 21 '15 14:07

Alexander Vasileyko


1 Answers

The main problem I see is that you're using image: mysitecatalogweb_source for your mysite service, and expecting that to include the committed result of running bin/install, which wasn't actually committed to the mysitecatalogweb_source image -- it's sitting in a container instead, so the virtualenv was never created in the second mysite container, and is thus not activated and gunicorn is not available. From just the snippet here, it appears that you ought to add RUN bin/install to your Dockerfile so that the virtualenv is set up before the attempt to use it.

like image 79
tianon Avatar answered Nov 15 '22 01:11

tianon