Hello,
Installing laravel 5.7 app under docker(based on php:7.2-apache ) I need to use “/public” in my url to run my app, so root url of my app is http://127.0.0.1:8081/public
FROM php:7.2-apache
RUN apt-get update && \
apt-get install -y \
libfreetype6-dev \
libwebp-dev \
libjpeg62-turbo-dev \
libpng-dev \
nano \
libgmp-dev \
libldap2-dev \
netcat \
sqlite3 \
libsqlite3-dev && \
docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-webp-dir=/usr/include/ --with-jpeg-dir=/usr/include/ && \
docker-php-ext-install gd pdo pdo_mysql pdo_sqlite zip gmp bcmath pcntl ldap sysvmsg exif \
&& a2enmod rewrite
ENTRYPOINT [ "php", "artisan", "serve", "–host=0.0.0.0", "–port=8081" ]
# I suppose need to use port of "web" in docker-compose.yml ?
Building the project :
$ docker-compose up -d --build
Creating network “votes_docker_default” with the default driver
Building web
Step 1/3 : FROM php:7.2-apache
—> cf1a377ba77f
Step 2/3 : RUN apt-get update && apt-get install -y libfreetype6-dev libwebp-dev libjpeg62-turbo-dev libpng-dev nano libgmp-dev libldap2-dev netcat sqlite3 libsqlite3-dev && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-webp-dir=/usr/include/ --with-jpeg-dir=/usr/include/ && docker-php-ext-install gd pdo pdo_mysql pdo_sqlite zip gmp bcmath pcntl ldap sysvmsg exif && a2enmod rewrite
—> Using cache
—> 40b2a1e9cafc
Step 3/3 : ENTRYPOINT [ “php”, “artisan”, “serve”, “–host=0.0.0.0”, “–port=8081” ]
—> Running in 94e5ee982001
Removing intermediate container 94e5ee982001
—> 3f8e5e3a15ba
Successfully built 3f8e5e3a15ba
Successfully tagged votes_docker_web:latest
Creating votes_docker_web_1 … done
Creating votes_docker_db_1 … done
Creating votes_docker_composer_1 … done
Creating votes_docker_phpmyadmin_1 … done
But checking logs I got error :
$ docker logs --tail=20 votes_docker_web_1
Warning: require(/var/www/html/vendor/autoload.php): failed to open stream: No such file or directory in /var/www/html/artisan on line 18
Fatal error: require(): Failed opening required '/var/www/html/vendor/autoload.php' (include_path='.:/usr/local/lib/php') in /var/www/html/artisan on line 18
there is composer install command. Do you mean it?
But the thing is that as composer.json has a lot of libraries, so uploading/installing all libraries takes several minutes.
usually I waite untill /vendor/autoload.php appears and I consider that composer run successfully.
but composer install is in process yet?
Sorry, I am new in docker and that is tricky for me.
If there is a way to enter at entrypoint after composer run successfully ?
Or maybe to run entrypoint ayt command line ?
Do you mean after I rebuilded the project with command docker-compose up -d --build
I need a take a pause in several minutes( untill /vendor/autoload.php appears ) and run again docker-compose up -d
?
I tried, but next got errors:
$ docker-compose up -d
votes_docker_db_1 is up-to-date
Starting votes_docker_composer_1 ...
Starting votes_docker_composer_1 ... done
Starting votes_docker_web_1 ... done
$ docker logs --tail=20 votes_docker_web_1
Warning: require(/var/www/html/vendor/autoload.php): failed to open stream: No such file or directory in /var/www/html/artisan on line 18
Fatal error: require(): Failed opening required '/var/www/html/vendor/autoload.php' (include_path='.:/usr/local/lib/php') in /var/www/html/artisan on line 18
Too many arguments, expected arguments "command".
$ docker-compose exec web bash
ERROR: No container found for web_1
Thank you! I will look into it. But I am surpised, I suppose that I am not the first who has “/” instead of “/public” issue? Are there some common decision ?
Thank you for your help and for this link.
I looked that at end of web/Dockerfile.yml there was a line : COPY virtualhost.conf /etc/apache2/sites-enabled/000-default.conf
and in this 000-default.conf “/public” path and other parameters were written.
I am testing on my local laptop now and seems all works ok.
Next I will have to move the project under Digital Ocean with ubuntu 18 server and to make it work with
my dns hosting created at https://my.freenom.com. Could you please give a hint what have I to use for this ?