NestJs Queue not working in docker container

144 Views Asked by At

I have a NestJs application that uses Redis and Bull package for message broker,

The application works as the consumer, thus retrieving data published by the producer at the other end of the queue and processing them.

All works fine until I tried to dockerize the application,

Running the application in a Docker container throw up an error no queue with the provided name was found

Here's my Docker-compose file

version: '3'
services:
    app:
        # image: 'application:auth'
        build:
            dockerfile: Dockerfile
            context: .
        ports:
            - '4576:3000' # Adjust the port mapping as needed
        # links:
        #   - postgres
        depends_on:
            postgres:
                condition: service_started
            redis:
                condition: service_started
                # migration:
                # condition: service_completed_successfully
        environment:
            # see the .env.exmple in the repository for details of the environment variables
            - PORT=3000
            - DATABASE_URL=postgres://username:password@postgres:5432/database
            - REDIS_HOST=redis
            - REDIS_PORT=6379
            - REDIS_PASSWORD=your_redis_password
            - JWT_SECRET=your_jwt_secret
             - EMAIL_QUEUE_NAME=some-email-queue-name
            - SMTP_TRANSPORTER=smtps://[email protected]:[email protected]
            - AUTH_EMAIL_QUEUE_NAME= email-queue
             - CONTACT_US_EMAIL_QUEUE_NAME= contact-us-queue

    redis:
        image: 'redis:6-alpine'
        ports:
            - '7370:6379' # Adjust the port mapping as needed

    postgres:
        image: 'postgres:15-alpine'
        restart: always
        ports:
            - '45797:5432' # Adjust the port mapping as needed
        environment:
            POSTGRES_USER: username
            POSTGRES_PASSWORD: password
            POSTGRES_DB: database
    migration:
        build:
            dockerfile: Dockerfile
            context: .
        links:
            - postgres
        depends_on:
            postgres:
                condition: service_started
        environment:
            - DATABASE_URL=postgres://username:password@postgres:5432/database
            - DATABASE_HOST=postgres
            - DATABASE_USERNAME=username
            - DATABASE_PASSWORD=password
            - DATABASE_NAME=database
        command: npx typeorm migration:run -d dist/config/typeorm.config.js
0

There are 0 best solutions below