How to setup laravel-docker+swoole without sail

1k Views Asked by At

I am trying to migrate my website to docker, but the problem arrives when I need to add it octane+swoole, I cant find a good tutorial, most of them uses laravel sail, but sail is not for production, for example this tutorial: https://github.com/DevLAN-io/laravel-boilerplate/ here it is using sail in the docker-compose.yml

# For more information: https://laravel.com/docs/sail
version: '3'
services:
    laravel.test:
        build:
            context: ./docker/8.0
            dockerfile: Dockerfile
            args:
                WWWGROUP: '${WWWGROUP}'
        image: sail-8.0/app
        ports:
            - '${APP_PORT:-80}:80'
        environment:
            WWWUSER: '${WWWUSER}'
            LARAVEL_SAIL: 1
        volumes:
            - '.:/var/www/html'
        networks:
            - sail
        depends_on:
            - mysql
            - redis
    mysql:
        image: 'mysql:8.0'
        ports:
            - '${FORWARD_DB_PORT:-3306}:3306'
        environment:
            MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}'
            MYSQL_DATABASE: '${DB_DATABASE}'
            MYSQL_USER: '${DB_USERNAME}'
            MYSQL_PASSWORD: '${DB_PASSWORD}'
            MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
        volumes:
            - 'sailmysql:/var/lib/mysql'
        networks:
            - sail
        healthcheck:
          test: ["CMD", "mysqladmin", "ping"]
    redis:
        image: 'redis:alpine'
        ports:
            - '${FORWARD_REDIS_PORT:-6379}:6379'
        volumes:
            - 'sailredis:/data'
        networks:
            - sail
        healthcheck:
          test: ["CMD", "redis-cli", "ping"]
    mailhog:
        image: 'mailhog/mailhog:latest'
        ports:
            - '${FORWARD_MAILHOG_PORT:-1025}:1025'
            - '${FORWARD_MAILHOG_DASHBOARD_PORT:-8025}:8025'
        networks:
            - sail
networks:
    sail:
        driver: bridge
volumes:
    sailmysql:
        driver: local
    sailredis:
        driver: local

Also the is a file: docker/production/Dockerfile

in the Dockerfile there is this:

FROM phpswoole/swoole:php8.0-alpine

LABEL maintainer="Nick Pratley <[email protected]>"

WORKDIR /var/www/html

ENV TZ=UTC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

RUN apk add --no-cache supervisor icu-dev \
    && apk add --no-cache --virtual .build-deps linux-headers \
        make automake autoconf gcc g++ zlib-dev bzip2-dev \
        libzip-dev libxml2-dev gmp-dev openssl-dev yaml-dev \
    && docker-php-ext-install mysqli pdo_mysql pcntl intl \
    && pecl install redis \
    && docker-php-ext-enable redis \
    && apk del .build-deps

COPY docker/production/start-container /usr/local/bin/start-container
COPY docker/production/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY docker/production/php.ini /etc/php/8.0/cli/conf.d/99-sail.ini
RUN chmod +x /usr/local/bin/start-container

ADD . /var/www/html

EXPOSE 80

ENTRYPOINT ["start-container"]

Here is using phpswoole/swoole:php8.0-alpine which is ok, but in the docker-compose they are using the sail image, sail is not for production because it has more stuff that I don't need, what can I do? thanks.

0

There are 0 best solutions below