I am trying to mount the local directory to docker directory so that changes can be made to the source code and will be immediately reflected in the running Laravel application. But it still doesn't work when I add docker volume into the service image in yml file. Instead, the 404 Not Found error shows up:
Not Found
The requested URL / was not found on this server.
Here is what I did:
docker-compose.yml
version: '2'
services:
laravel:
build:
context: ./
dockerfile: .dockerfile
ports:
- "8080:80"
working_dir: /var/www
volumes:
- .:/var/www
depends_on:
- mysql
mysql:
image: mysql:5.6.36
volumes:
- db_data:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=
- MYSQL_DATABASE=homestead
- MYSQL_ALLOW_EMPTY_PASSWORD=yes
phpmyadmin:
depends_on:
- mysql
image: phpmyadmin/phpmyadmin
restart: always
ports:
- 8090:80
environment:
PMA_HOST: mysql
MYSQL_ROOT_PASSWORD:
volumes:
db_data:
Dockerfile
FROM php:7.1.5-apache
#install all the system dependencies and enable PHP modules
RUN apt-get update && apt-get install -y \
libicu-dev \
libpq-dev \
libmcrypt-dev \
git \
zip \
unzip \
&& rm -r /var/lib/apt/lists/* \
&& docker-php-ext-configure pdo_mysql --with-pdo-mysql=mysqlnd \
&& docker-php-ext-install \
intl \
mbstring \
mcrypt \
pcntl \
pdo_mysql \
pdo_pgsql \
pgsql \
zip \
opcache
#install composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin/ --filename=composer
#set our application folder as an environment variable
ENV APP_HOME /var/www/html
#change uid and gid of apache to docker user uid/gid
RUN usermod -u 1000 www-data && groupmod -g 1000 www-data
#change the web_root to laravel /var/www/html/public folder
RUN sed -i -e "s/html/html\/public/g" /etc/apache2/sites-enabled/000-default.conf
# enable apache module rewrite
RUN a2enmod rewrite
#copy source files and run composer
COPY . $APP_HOME
# install all PHP dependencies
RUN composer install --no-interaction
#change ownership of our applications
RUN chown -R www-data:www-data $APP_HOME
FYI, everything works fine when volume is not added into laravel service image but the updates didn't reflect on the docker container. I need to rebuild the images and containers every time the changes made.
Question: How the changes made in Laravel can reflect into the Docker container?
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2C1Vspl
via IFTTT
Aucun commentaire:
Enregistrer un commentaire