【发布时间】:2022-01-11 14:55:44
【问题描述】:
我正在尝试按照给定的教程使用 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 上解决它?任何帮助将不胜感激
【问题讨论】:
-
你不能在特定目录中手动制作一个吗?
-
那是我在问我应该在哪里制作这个 000-default.conf 文件?在 Laravel 项目文件夹中?就像我在窗户上一样
-
我只是在 ubuntu 上使用了 apache2,但我认为它并没有什么不同。要放入的目录已经在您的错误消息中。它是
/etc/apache2/sites-available/ -
虽然我不是 100% 确定,但也许你可以 google 一下