在 windows 上构建 Laravel 应用程序的 docker 图像时未找到 000-default.conf
000-default.conf not found while building docker image of Laravel app on windows
我正尝试按照给定的教程使用 docker 图像在 AWS 上部署我的 Laravel 应用程序:
https://medium.com/@okekedesmond/deploying-containerized-laravel-application-using-aws-ec2-instances-with-docker-and-rds-883e8f6d6245
我在构建 docker 图像时卡在了第一点。这是我的 Dockerfile:
# Defining the base image for our project, if you understand how docker images and layers work, this should not be difficult to understand.
FROM php:7.3-cli
# We need to update the image and install some import packages
RUN apt-get update -y && apt-get install -y openssl zip unzip git curl libpng-dev libonig-dev libxml2-dev
# cleaning packages and install scripts
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
# Installing composer which is used to install Laravel
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin –filename=composer
#Creating a configuration file for apache and linking
ADD 000-default.conf /etc/apache2/sites-available/
RUN ln -sf /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-enabled/000-default.conf
#Restarting Apache
RUN a2enmod rewrite
RUN service apache2 restart
# Create a work directory and copy all project file into the
WORKDIR /var/www/app/
COPY . /var/www/app
#Granting permissions to files and folders
RUN chmod -R o+w /var/www/app/storage
RUN chown -R www-data:www-data ./storage
RUN chgrp -R www-data storage bootstrap/cache
RUN chmod -R ug+rwx storage bootstrap/cache
RUN chmod -R 755 /var/www/app/
RUN find /var/www/app/ -type d -exec chmod 775 {} \;
RUN chown -R www-data:www-data /var/www
# Installing dependencies from laravel package
RUN composer install --no-scripts --no-autoloader --no-ansi --no-interaction --working-dir=/var/www/app
#Running some packages
RUN docker-php-ext-install mbstring pdo pdo_mysql mbstring exif pcntl bcmath gd opcache
#Running Laravel on docker, because we are using the php-7.3-cli so we have to use a php server in our docker image
CMD php artisan serve --host=0.0.0.0 --port=80
EXPOSE 80`
第 1 步出错。 5:
Step 5/21 : ADD 000-default.conf /etc/apache2/sites-available/
ADD failed: file not found in build context or excluded by .dockerignore: stat 000-default.conf: file does not exist
如何在 windows 上解决它?任何帮助将不胜感激
我认为最好的解决办法是手动制作一个新文件,这里是一个示例文件:
https://gist.github.com/tjtoml/942d696c868b22a25259
它应该位于:
/etc/apache2/sites-available/000-default.conf
您可能需要根据自己的需要对其进行自定义
我正尝试按照给定的教程使用 docker 图像在 AWS 上部署我的 Laravel 应用程序:
https://medium.com/@okekedesmond/deploying-containerized-laravel-application-using-aws-ec2-instances-with-docker-and-rds-883e8f6d6245
我在构建 docker 图像时卡在了第一点。这是我的 Dockerfile:
# Defining the base image for our project, if you understand how docker images and layers work, this should not be difficult to understand.
FROM php:7.3-cli
# We need to update the image and install some import packages
RUN apt-get update -y && apt-get install -y openssl zip unzip git curl libpng-dev libonig-dev libxml2-dev
# cleaning packages and install scripts
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
# Installing composer which is used to install Laravel
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin –filename=composer
#Creating a configuration file for apache and linking
ADD 000-default.conf /etc/apache2/sites-available/
RUN ln -sf /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-enabled/000-default.conf
#Restarting Apache
RUN a2enmod rewrite
RUN service apache2 restart
# Create a work directory and copy all project file into the
WORKDIR /var/www/app/
COPY . /var/www/app
#Granting permissions to files and folders
RUN chmod -R o+w /var/www/app/storage
RUN chown -R www-data:www-data ./storage
RUN chgrp -R www-data storage bootstrap/cache
RUN chmod -R ug+rwx storage bootstrap/cache
RUN chmod -R 755 /var/www/app/
RUN find /var/www/app/ -type d -exec chmod 775 {} \;
RUN chown -R www-data:www-data /var/www
# Installing dependencies from laravel package
RUN composer install --no-scripts --no-autoloader --no-ansi --no-interaction --working-dir=/var/www/app
#Running some packages
RUN docker-php-ext-install mbstring pdo pdo_mysql mbstring exif pcntl bcmath gd opcache
#Running Laravel on docker, because we are using the php-7.3-cli so we have to use a php server in our docker image
CMD php artisan serve --host=0.0.0.0 --port=80
EXPOSE 80`
第 1 步出错。 5:
Step 5/21 : ADD 000-default.conf /etc/apache2/sites-available/
ADD failed: file not found in build context or excluded by .dockerignore: stat 000-default.conf: file does not exist
如何在 windows 上解决它?任何帮助将不胜感激
我认为最好的解决办法是手动制作一个新文件,这里是一个示例文件:
https://gist.github.com/tjtoml/942d696c868b22a25259
它应该位于:
/etc/apache2/sites-available/000-default.conf
您可能需要根据自己的需要对其进行自定义