Skip to content

Instantly share code, notes, and snippets.

@mmautner
Created December 17, 2017 07:05
Show Gist options
  • Select an option

  • Save mmautner/b0821fa054cf584db6275f6253e740ca to your computer and use it in GitHub Desktop.

Select an option

Save mmautner/b0821fa054cf584db6275f6253e740ca to your computer and use it in GitHub Desktop.
celery docker-compose example
from os import environ
from celery import Celery
environ.setdefault('CELERY_CONFIG_MODULE', 'celery_config')
app = Celery()
app.config_from_envvar('CELERY_CONFIG_MODULE')
@app.task
def add(x, y):
return x + y
@app.task
def tsum(*args, **kwargs):
print(args)
print(kwargs)
return sum(args[0])
from os import environ
broker_url = environ['BROKER_URL']
result_backend = environ['RESULT_BACKEND']
version: '2'
services:
rabbitmq:
image: rabbitmq:3.6.6
ports:
- "5672:5672"
environment:
- RABBITMQ_DEFAULT_USER=admin
- RABBITMQ_DEFAULT_PASS=mypass
redis:
image: redis
ports:
- "6379:6379"
worker:
build:
context: .
dockerfile: Dockerfile
image: madefire/chordtest
command: ['celery', 'worker', '-A', 'app.app', '-l', 'info']
environment:
- BROKER_URL=amqp://admin:mypass@rabbitmq:5672//
- RESULT_BACKEND=redis://redis:6379/0
- C_FORCE_ROOT=true
volumes:
- ./:/app/
depends_on:
- rabbitmq
- redis
FROM python:3.4
ADD . /app/
WORKDIR /app/
RUN pip install -r requirements.txt
CMD ["echo", "hello"]
celery[redis]==4.0.2
ipython==6.0.0
@TheAurovind
Copy link
Copy Markdown

how to run give the detailed explanantion with localhost

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment