2

I am trying to deploy my Laravel application on AWS using docker image by following given tutorial:

https://medium.com/@okekedesmond/deploying-containerized-laravel-application-using-aws-ec2-instances-with-docker-and-rds-883e8f6d6245

I am stuck at first point while building docker image. Here is my 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`

It is giving error at step no. 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

How do I solve it on windows? any help will be appreciated

4
  • Couldn't you just make one manually in the specific directory? Commented Jan 11, 2022 at 15:40
  • that's I am asking where should I make this 000-default.conf file? In Laravel project folder? as I am on windows Commented Jan 11, 2022 at 15:47
  • I just used apache2 on ubuntu but I think it doesn't differ. The directory to put in is already in your error message. it is /etc/apache2/sites-available/ Commented Jan 11, 2022 at 15:57
  • Though I am not 100% sure, maybe you can google it Commented Jan 11, 2022 at 15:57

1 Answer 1

2

I think the best solution is to manually make a new one, here is an example file:

https://gist.github.com/tjtoml/942d696c868b22a25259

And it should be located in:

/etc/apache2/sites-available/000-default.conf

It could be that you have to customize it for your needs

Sign up to request clarification or add additional context in comments.

6 Comments

Can you tell me where should I place this file in windows so that while creating image docker will add this file? should I place this file in laravel root folder where Dockerfile is placed?
It is hard to tell without seeing your directory structure. Do you have apache2 installed on your windows machine?
Got the issue. I think I am not using any wsl2 therefore it is not working
So it works now? :) I had huge issues with setting up apache2 on ubuntu few days ago, so I am happy when you were able to solve it :)
yes solved it. I am working first time on docker it is mind twisting game :D
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.