Giter Site home page Giter Site logo

ipunkt / docker-laravel-queue-worker Goto Github PK

View Code? Open in Web Editor NEW
70.0 5.0 20.0 25 KB

A docker image for working with queues being monitored by supervisor as recommended by laravel.

Home Page: https://hub.docker.com/r/ipunktbs/laravel-queue-worker/

License: MIT License

Shell 15.29% Smarty 16.61% Dockerfile 37.73% Python 30.38%
laravel-queues queue redis-queue docker-image supervisor

docker-laravel-queue-worker's Introduction

Laravel Queue Worker

A docker image for working with queues being monitored by supervisor as recommended by laravel.

Environment Configuration

Running with redis you can configure your QUEUE_CONNECTION environment variable to match your redis link. In our case the link is called redis so the default value will be redis.

The default queue name in laravel is called default. So we configured the QUEUE_NAME environment variable to this value.

If you want to use Laravel Horizon then you have to set the environment LARAVEL_HORIZON to true. By default it is false.

Since version v4.1 is it possible to modify the php memory limit. The environment variable PHP_MEMORY_LIMIT is by default set to 512 (MB). For unlimited memory usage just set it to -1. The queue worker command will also be called with the memory limit given to this value to be consistent.

For Laravel Horizon you have to configure your memory limit in your horizon.php configuration. The default php memory limit has to set within the container by setting PHP_MEMORY_LIMIT as well.

Docker Images

php docker image
7.0 ipunktbs/laravel-queue-worker:php7.0-v1.0
7.1 ipunktbs/laravel-queue-worker:php7.1-v2.0
7.2 ipunktbs/laravel-queue-worker:php7.2-v3.0
7.3 ipunktbs/laravel-queue-worker:php7.3-v4.0 - deprecated
7.3 ipunktbs/laravel-queue-worker:php7.3-v4.1
7.3 ipunktbs/laravel-queue-worker:php7.3-v4.2
7.3 ipunktbs/laravel-queue-worker:php7.3-v4.3
7.3 ipunktbs/laravel-queue-worker:php7.3-v4.4 - recommended

Changelog

v4.4

Added:

  • pcntl extension

v4.3

Added:

  • amqp extension

v4.2

Added:

  • bcmath extension for php (to support Laravel Telescope as well)
  • watchdog for supervisord to let the container restart when some of the programs died

docker-laravel-queue-worker's People

Contributors

akmolina28 avatar jordan-akki avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

docker-laravel-queue-worker's Issues

Correct docker-compose.yml file?

Hi. I added an ipunktbs/laravel-queue-worker image to my docker-compose.yml file. Did I set it up correctly?

version: "3"
services:
  #PHP Service
  app:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: app
    restart: unless-stopped
    tty: true
    working_dir: /var/www
    volumes:
      - ./:/var/www
    networks:
      - app-network

  #Queue Service
  queue:
    image: ipunktbs/laravel-queue-worker
    container_name: queue
    restart: unless-stopped
    tty: true
    environment:
      QUEUE_CONNECTION: ${QUEUE_CONNECTION}
    volumes:
      - ./:/var/www/app
    networks:
    - app-network

  #Nginx Service
  webserver:
    image: nginx:alpine
    container_name: webserver
    restart: unless-stopped
    tty: true
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./:/var/www
      - ./docker/nginx/conf.d/:/etc/nginx/conf.d/
    networks:
    - app-network

  #MySQL Service
  db:
    image: mysql:5.7.22
    container_name: db
    restart: unless-stopped
    tty: true
    ports:
      - "3307:3306"
    environment:
      MYSQL_DATABASE: ${DB_DATABASE}
      MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
    volumes:
      - dbdata_price-crawler:/var/lib/mysql
    networks:
      - app-network

#Docker Networks
networks:
  app-network:
    driver: bridge

#Volumes
volumes:
  dbdata_price-crawler:
    driver: local

root role issue

The queue execution process with root permissions, which causes permission problems. What should I do?

thank you!

How i use this in my dockerfile?

HI,
I saw your package i already have dockerfile and i just want to add this feature .

FROM php:7.2-fpm

# Copy composer.lock and composer.json
COPY composer.json /var/www/

COPY docker-entry.sh /
RUN chmod +x /docker-entry.sh

# Set working directory
WORKDIR /var/www
# Install dependencies
RUN apt-get update && apt-get install -y \
    build-essential \
    libpng-dev \
    libpq-dev \
    libjpeg62-turbo-dev \
    libfreetype6-dev \
    locales \
    zip \
    jpegoptim optipng pngquant gifsicle \
    vim \
    unzip \
    git \
    curl \
    nginx \
    libxml2-dev


# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*

# Install extensions
RUN docker-php-ext-install pdo_mysql pdo_pgsql mbstring zip exif pcntl
#RUN docker-php-ext-configure gd --with-gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ --with-png-dir=/usr/include/
RUN docker-php-ext-install soap
RUN docker-php-ext-install gd pdo_mysql pdo_pgsql mbstring zip exif pcntl
# Install composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

# Add user for laravel application
RUN groupadd -g 1000 www
RUN useradd -u 1000 -ms /bin/bash -g www www

RUN adduser --disabled-password --gecos '' hamza
# Copy existing application directory
COPY . /var/www/
RUN ls /var/www
RUN chown hamza:www /var/www/storage/logs

COPY ./configuration/nginx/conf.d/ /etc/nginx/conf.d/
RUN ls /etc/nginx/conf.d

COPY ./configuration/php/local.ini /usr/local/etc/php/conf.d/local.ini
RUN ls /usr/local/etc/php/conf.d
RUN cat /usr/local/etc/php/conf.d/local.ini

RUN rm -rf /etc/nginx/sites-enabled/default
#RUN mkdir -p /etc/nginx/sites-enabled
#COPY ./configuration/nginx/conf.d/default /etc/nginx/sites-enabled


RUN mkdir -p /var/www/storage/app/public/posters
RUN chmod -R 775 /var/www/storage
RUN composer install

# install node
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash
#RUN echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list
RUN apt-get update && apt-get install -y  nodejs

#install node modules and run dev

RUN npm install
RUN npm run production


#RUN php artisan  migrate:fresh
#RUN php artisan  db:seed
RUN php artisan cache:clear

WORKDIR /var/www/public
#RUN rm storage
WORKDIR /var/www/
RUN php artisan storage:link

# Expose port 80 and start php-fpm server
EXPOSE 80

COPY bootstart.sh /
RUN chmod +x /bootstart.sh

#ENTRYPOINT ["/bootstart.sh"]

CMD ["/docker-entry.sh"]

Use variables in Supervisor's config files

From the official page of Supervisor:

Environment variables that are present in the environment at the time that supervisord is started can be used in the configuration file using the Python string expression syntax %(ENV_X)s:

[program:example]
command=/usr/bin/example --loglevel=%(ENV_LOGLEVEL)s

This means that the command line can be directly be written as:

## Suggested
command=php /var/www/app/artisan queue:work %(ENV_QUEUE_CONNECTION)s --queue=%(ENV_QUEUE_NAME)s --memory=%(ENV_MEMORY_LIMIT)s

## Current
command=php /var/www/app/artisan queue:work %%QUEUE_CONNECTION%% --queue=%%QUEUE_NAME%% --memory=%%MEMORY_LIMIT%%

Removing the template "variables" from the current command, would also simplify init.sh.

[Question] Full PHP vs PHP-CLI

Is there any reason you went with full php rather then just php-cli?

I am probably missing something and apologies if I am.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.