Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix FileNotFound error #421

Merged
merged 1 commit into from
Nov 17, 2021
Merged

Fix FileNotFound error #421

merged 1 commit into from
Nov 17, 2021

Conversation

vokamut
Copy link
Contributor

@vokamut vokamut commented Nov 16, 2021

Errors occur when you use octane in docker:

ERROR container/poller.go:16 vertex got an error {"id": "http.Plugin", "error": "WorkerAllocate:\n\tgoridge_frame_receive: FileNotFound: Could not open input file: ./vendor/bin/roadrunner-worker\n"}

and

ERROR container/endure.go:406 error during the internal_init {"error": "endure_internal_init: Function call error:\n\tendure_call_init_fn:\n\tstatic_plugin_init:\n\tstatic_plugin_valid: root directory 'public' does not exists"}

@taylorotwell
Copy link
Member

Execute how in Docker? With what Docker file?

@taylorotwell taylorotwell marked this pull request as draft November 16, 2021 14:04
@vokamut
Copy link
Contributor Author

vokamut commented Nov 17, 2021

Dockerfile:

FROM alpine:edge as build
LABEL stage=build

RUN apk add --no-cache \
    tzdata \
    curl \
    php8 \
    php8-ctype \
    php8-curl \
    php8-dom \
    php8-fileinfo \
    php8-gd \
    php8-iconv \
    php8-intl \
    php8-json \
    php8-mbstring \
    php8-mysqlnd \
    php8-opcache \
    php8-openssl \
    php8-pcntl \
    php8-pdo \
    php8-pdo_mysql \
    php8-pdo_sqlite \
    php8-phar \
    php8-posix \
    php8-session \
    php8-simplexml \
    php8-sockets \
    php8-sqlite3 \
    php8-tokenizer \
    php8-xml \
    php8-xmlwriter \
    php8-zip \
    zip \
    unzip \
    git

RUN cp /usr/share/zoneinfo/Europe/Moscow /etc/localtime && echo Europe/Moscow > /etc/timezone

RUN curl -L https://getcomposer.org/download/latest-stable/composer.phar -o /usr/local/bin/composer && chmod +x /usr/local/bin/composer

RUN apk del --no-cache \
    alpine-baselayout \
    alpine-keys \
    apk-tools \
    dpkg \
    dpkg-dev \
    scanelf \
    tzdata

RUN touch /etc/group

RUN mkdir -p /var/www/.config/psysh

RUN echo "root:x:0:0:root:/:/bin/sh" > /etc/passwd

RUN ln -s /usr/bin/php8 /bin/php

RUN adduser -h /var/www --disabled-password --gecos "First Last,RoomNumber,WorkPhone,HomePhone" wwwdata

ENV LC_ALL en_US.UTF-8

COPY . /var/www
COPY ./docker/php/docker-php-custom.ini /usr/local/etc/php/conf.d/
COPY ./docker/start.sh /usr/local/bin/start.sh

WORKDIR /var/www

RUN composer install --no-dev --no-scripts --no-interaction --prefer-dist --optimize-autoloader

RUN php artisan package:discover
RUN php artisan horizon:publish

RUN ./vendor/bin/rr get-binary --quiet

RUN chmod +x /usr/local/bin/start.sh
RUN chmod +x rr

RUN chown -R wwwdata:wwwdata \
    .config/psysh \
    storage \
    database \
    bootstrap/cache

RUN rm -rf /tmp/* /usr/local/bin/composer

FROM scratch

COPY --from=build / /

RUN php -v

USER wwwdata

WORKDIR /var/www

EXPOSE 8000
EXPOSE 8892

ENTRYPOINT ["/usr/local/bin/start.sh"]

start.sh

#!/usr/bin/env sh

set -e

role=${CONTAINER_ROLE:-app}
env=${APP_ENV:-production}
domain=${APP_DOMAIN:-laravel.test}

cd /var/www

if [ "$env" == "production" ]; then
    echo "Caching configuration..."
    php artisan optimize
else
    echo "Clearing caches..."
    php artisan optimize:clear
fi

if [ "$role" = "app" ]; then

    cp .rr.yaml bootstrap/cache/.rr.yaml
    sed -i -e "s/DOMAIN/$domain/g" bootstrap/cache/.rr.yaml
    php artisan octane:start --host=0.0.0.0 --rr-config=bootstrap/cache/.rr.yaml

elif [ "$role" = "horizon" ]; then

    echo "Running the horizon..."
    php artisan horizon

elif [ "$role" = "scheduler" ]; then

    while [ true ]
    do
      php artisan schedule:run --verbose --no-interaction &
      sleep 60
    done

else

    echo "Could not match the container role \"$role\""
    exit 1

fi

.rr.yaml:

http:
    address: 0.0.0.0:8000

    ssl:
        address: :8892
        redirect: false
        cert: /var/www/docker/certs/DOMAIN.crt
        key: /var/www/docker/certs/DOMAIN.key

    http2:
        h2c: false
        max_concurrent_streams: 128

App part of docker-compose.yml:

version: '3.1'
services:
  app:
    build:
      context: ./
      dockerfile: ./docker/app.dockerfile
      args:
        UID: ${UID}
        GID: ${GID}
    user: "${UID}:${GID}"
    volumes:
      - ./docker/start.sh:/usr/local/bin/start.sh
      - ./docker/php/docker-php-custom.ini:/usr/local/etc/php/conf.d/docker-php-custom.ini
      - ./:/var/www
    ports:
      - ${HTTP_PORT}:8000
      - ${HTTPS_PORT}:8892
    environment:
      APP_ENV: ${APP_ENV}
      APP_DOMAIN: ${APP_DOMAIN}
      CONTAINER_ROLE: app
    networks:
      - net

@driesvints driesvints marked this pull request as ready for review November 17, 2021 08:22
'-o', 'http.pool.num_workers='.$this->workerCount(),
'-o', 'http.pool.max_jobs='.$this->option('max-requests'),
'-o', 'rpc.listen=tcp://'.$this->option('host').':'.$this->rpcPort(),
'-o', 'http.pool.supervisor.exec_ttl='.$this->maxExecutionTime(),
'-o', 'http.static.dir=public',
'-o', 'http.static.dir='.base_path('public'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public_path could be used here. But this changes look good to me.

@taylorotwell taylorotwell merged commit b5c8f19 into laravel:1.x Nov 17, 2021
@vokamut vokamut deleted the patch-1 branch November 18, 2021 06:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants