Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is the "sail up" command not building my laravel docker containers?

I'm trying out Laravel Sail, as I've been successfully using Laradock for a few years and hoping to simplify my dev environment setup. I am on Windows 10 64, Docker Desktop 3.0 installed using WSL 2, and my Laravel app is running Laravel 8.20.1.

In my Laravel project, I've followed the Laravel Sail setup guide: I've run composer require laravel/sail --dev and php artisan sail:install, and I see the docker-compose.yml in my root directory.

But when I run ./vendor/bin/sail up I get this error:

./vendor/bin/sail: line 1: XSym: command not found
./vendor/bin/sail: line 2: 0024: command not found
./vendor/bin/sail: line 3: a81960381c7144e16cd1e768af147de3: command not found
./vendor/bin/sail: line 4: ../laravel/sail/bin/sail: No such file or directory

Update: I fixed the above through Qumber's help: removing /vendor/ and reinstalling. But now I get this error:

In GitBash I get this response:

Unsupported operating system [MINGW64_NT-10.0-19041]. Laravel Sail supports macOS, Linux, and Windows (WSL2).

If I try from Powershell now, I get:

/bin/bash: C:\Users\ssund\Source\steepdb\vendor\bin\/../laravel/sail/bin/sail: No such file or directory

-------------Requested attachments--------------------

docker-compose.yml:

# For more information: https://laravel.com/docs/sail
version: '3'
services:
    laravel.test:
        build:
            context: ./vendor/laravel/sail/runtimes/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
            # - selenium
    # selenium:
    #     image: 'selenium/standalone-chrome'
    #     volumes:
    #         - '/dev/shm:/dev/shm'
    #     networks:
    #         - sail
    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
    redis:
        image: 'redis:alpine'
        ports:
            - '${FORWARD_REDIS_PORT:-6379}:6379'
        volumes:
            - 'sailredis:/data'
        networks:
            - sail
    # memcached:
    #     image: 'memcached:alpine'
    #     ports:
    #         - '11211:11211'
    #     networks:
    #         - sail
    mailhog:
        image: 'mailhog/mailhog:latest'
        ports:
            - 1025:1025
            - 8025:8025
        networks:
            - sail
networks:
    sail:
        driver: bridge
volumes:
    sailmysql:
        driver: local
    sailredis:
        driver: local

Dockerfile in \vendor\laravel\sail\runtimes\7.4:

FROM ubuntu:20.04

LABEL maintainer="Taylor Otwell"

ARG WWWGROUP

WORKDIR /var/www/html

ENV DEBIAN_FRONTEND noninteractive
ENV TZ=UTC

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

RUN apt-get update \
    && apt-get install -y gnupg gosu curl ca-certificates zip unzip git supervisor sqlite3 libcap2-bin libpng-dev python2 \
    && mkdir -p ~/.gnupg \
    && chmod 600 ~/.gnupg \
    && echo "disable-ipv6" >> ~/.gnupg/dirmngr.conf \
    && apt-key adv --homedir ~/.gnupg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys E5267A6C \
    && apt-key adv --homedir ~/.gnupg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys C300EE8C \
    && echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu focal main" > /etc/apt/sources.list.d/ppa_ondrej_php.list \
    && apt-get update \
    && apt-get install -y php7.4-cli php7.4-dev \
       php7.4-pgsql php7.4-sqlite3 php7.4-gd \
       php7.4-curl php7.4-memcached \
       php7.4-imap php7.4-mysql php7.4-mbstring \
       php7.4-xml php7.4-zip php7.4-bcmath php7.4-soap \
       php7.4-intl php7.4-readline php7.4-pcov \
       php7.4-msgpack php7.4-igbinary php7.4-ldap \
       php7.4-redis \
    && php -r "readfile('http://getcomposer.org/installer');" | php -- --install-dir=/usr/bin/ --filename=composer \
    && curl -sL https://deb.nodesource.com/setup_15.x | bash - \
    && apt-get install -y nodejs \
    && apt-get install -y mysql-client \
    && apt-get -y autoremove \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

RUN setcap "cap_net_bind_service=+ep" /usr/bin/php7.4

RUN groupadd --force -g $WWWGROUP sail
RUN useradd -ms /bin/bash --no-user-group -g $WWWGROUP -u 1337 sail

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

EXPOSE 8000

ENTRYPOINT ["start-container"]
like image 906
sersun Avatar asked Jan 24 '23 13:01

sersun


1 Answers

Ok there were multiple things that I needed to fix here.

  1. @Qumber helped me initially by suggesting I wipe /vendor/ and run composer install/update again. That fixed the missing sail file that wasn't getting added for some reason.
  2. I also had some permission-related issues, possibly due to running compose in WSL and then trying to run sail in Windows/GitBash (or vice versa).
  3. The biggest issue was my misunderstanding about Docker WSL2 integration and that the sail command should be run from within WLS (coming from Laradock, I made some incorrect assumptions). I needed to have a linux distro installed (I chose Ubuntu 20.x) AND make sure it was set as the default, via running wsl -s . You can check which is currently default with wsl -l -v. For more detailed steps about this setup see https://learn.microsoft.com/en-us/windows/wsl/install-win10#step-4---download-the-linux-kernel-update-package.

Once I fixed the above, I was able to open Windows Terminal, create an Ubuntu tab, and run ./vendor/bin/sail up and it executed.

like image 112
sersun Avatar answered Jan 29 '23 00:01

sersun