Docker Изображение Apache Root Ошибка приложения - PullRequest
0 голосов
/ 07 мая 2020

У нас есть изображение docker, работающее локально, но внезапно мы получаем эту ошибку, эта ошибка просто появляется, когда мы загружаем код в Github, потому что мы хотели запустить его на AWS ECS:

tok    | AH00526: Syntax error on line 115 of /etc/apache2/apache2.conf:
tok    | Error:\tApache has not been designed to serve pages while\n\trunning as root.  There are known race conditions that\n\twill allow any local user to read any file on the system.\n\tIf you still desire to serve pages as root then\n\tadd -DBIG_SECURITY_HOLE to the CFLAGS env variable\n\tand then rebuild the server.\n\tIt is strongly suggested that you instead modify the User\n\tdirective in your httpd.conf file to list a non-root\n\tuser.\n
tok exited with code 1

У нас есть наш docker файл, как этот, мы установили пользователя как www-data:

FROM php:7.4-apache

# Arguments defined in docker-compose.yml
ARG user
ARG uid

# install all the dependencies and enable PHP modules
RUN apt-get update && apt-get upgrade -y && apt-get install -y \
      procps \
      nano \
      git \
      unzip \
      libicu-dev \
      zlib1g-dev \
      libxml2 \
      libxml2-dev \
      libreadline-dev \
      supervisor \
      cron \
      libzip-dev \
      libpng-dev  \
      libonig-dev  \
    && docker-php-ext-configure pdo_mysql --with-pdo-mysql=mysqlnd \
    && docker-php-ext-configure intl \
    && docker-php-ext-install \
      pdo_mysql \
      sockets \
      intl \
      opcache \
      zip \
      gd \
    && rm -rf /tmp/* \
    && rm -rf /var/list/apt/* \
    && rm -rf /var/lib/apt/lists/* \
    && apt-get clean

# 2. Apache configs + document root.
#RUN echo "ServerName tok.local" >> /etc/apache2/apache2.conf

ENV APACHE_DOCUMENT_ROOT=/var/www/html/public
#RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf
#RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf

# 3. mod_rewrite for URL rewrite and mod_headers for .htaccess extra headers like Access-Control-Allow-Origin-
RUN a2enmod rewrite headers

# disable default site and delete all default files inside APP_HOME
RUN a2dissite 000-default.conf

COPY ./docker/general/laravel.conf /etc/apache2/sites-available/laravel.conf
RUN a2ensite laravel.conf

# 4. Start with base PHP config, then add extensions.
RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"

# 5. Composer.
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

ADD ./ /var/www/html

COPY ./composer.json /var/www/html
COPY ./composer.lock /var/www/html

RUN composer install --working-dir=/var/www/html

RUN chown -R www-data /var/www/html/bootstrap \
 && chown -R www-data /var/www/html/storage \
 && chown -R www-data /var/www/html/storage/logs \
 && chown -R www-data /var/www/html/storage/framework

RUN chown -R www-data:www-data /var/www
RUN chmod 755 /var/www
RUN chmod 755 /var/www/html/storage/framework

# 6. We need a user with the same UID/GID as the host user
# so when we execute CLI commands, all the host file's permissions and ownership remain intact.
# Otherwise commands from inside the container would create root-owned files and directories.
ARG uid

RUN chown -R www-data:www-data /var/www/html
#RUN useradd -G www-data,$uid -u 1000 -d /home/devuser devuser
# RUN mkdir -p /home/devuser/.composer && \
#     chown -R devuser:devuser /home/devuser

И наш docker -compose.yml:

version: '3.5'

services:
  tok:
    build:
      context: '.'
      args:
        user: www-data
        uid: ${UID}
    container_name: tok
    environment:
      - APACHE_RUN_USER=#${UID}
      - APACHE_RUN_GROUP=#${UID}
    volumes:
      - .:/var/www/html
    working_dir: /var/www/
    ports:
      - 8000:80
    networks:
      backend:
        aliases:
          - tok

networks:
  backend:
    name: backend-network

Мы не понимаю откуда берёт папка root, что-то не хватает?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...