Hofbr
Hofbr

Reputation: 1010

Combine Pulsar and Python into docker-compose.yaml

Background:

I've setup up a standalone Pulsar locally and used Pulsar's python api docs to execute a simple consumer and producer modules.

Problem:

Transfer basic workflow into docker-compose.yaml

  1. Setup up standalone Pulsar locally.
  2. Install requirements.txt with needed for consumer.py and producer.py modules
  3. Run consumer.py
  4. Run producer.py

What I've done so far:

I've figured out how to compose the Pulsar standalone with the following yaml configuration

Current pulsar image:

version: '3.8'
services:
  standalone:
    image: apachepulsar/pulsar:2.8.1
    ports:
      - 8080:8080
      - 6650:6650
    command: bin/pulsar standalone

Where I'm lost

But I'm struggling conceptually with how I add Python 3.8 and the requirements need in the API docs to then be able to run the python commands python consumer.py and python producer.py

Upvotes: 1

Views: 336

Answers (1)

OneCricketeer
OneCricketeer

Reputation: 191738

You don't really need another image. You should keep your code running locally and point it at pulsar image.

If you really wanted to run a python docker image, you could do something like this, where example_default is a network name created by compose...

docker run --network=example_default -v /path/to/code:/app python:3 /app/producer.py

You will also need to modify your code to not use localhost as the Pulsar server address

Upvotes: 1

Related Questions