Last active
July 24, 2018 09:14
-
-
Save rutcreate/9c6719d8979fcfc285be7dfa1fb75ae2 to your computer and use it in GitHub Desktop.
Docker Laravel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3' | |
services: | |
php: | |
image: <user/repo:tag> | |
ports: | |
- 9000:80 | |
volumes: | |
- ./html:/var/www/html | |
mysql: | |
image: mysql:5.7 | |
volumes: | |
- db_data:/var/lib/mysql | |
environment: | |
MYSQL_DATABASE: laravel | |
MYSQL_ROOT_PASSWORD: secret | |
volumes: | |
db_data: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM php:7.1-apache | |
# Update apache document root. | |
ENV APACHE_DOCUMENT_ROOT /var/www/html/public | |
RUN sed -ri -e 's!/var/www/html!/var/www/html/public!g' /etc/apache2/sites-available/*.conf | |
RUN sed -ri -e 's!/var/www/!/var/www/html/public!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf | |
# Enable mod write. | |
RUN a2enmod rewrite | |
# Install php extensions. | |
RUN apt-get update \ | |
&& apt-get install -y --no-install-recommends \ | |
vim \ | |
curl \ | |
libmemcached-dev \ | |
libz-dev \ | |
libpq-dev \ | |
libjpeg-dev \ | |
libpng-dev \ | |
libfreetype6-dev \ | |
libssl-dev \ | |
libmcrypt-dev \ | |
&& rm -rf /var/lib/apt/lists/* | |
RUN docker-php-ext-install pdo_mysql \ | |
&& docker-php-ext-install pdo_pgsql \ | |
&& docker-php-ext-install zip \ | |
&& docker-php-ext-configure gd \ | |
--enable-gd-native-ttf \ | |
--with-jpeg-dir=/usr/lib \ | |
--with-freetype-dir=/usr/include/freetype2 && \ | |
docker-php-ext-install gd | |
# Install composer. | |
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" | |
RUN php -r "if (hash_file('SHA384', 'composer-setup.php') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" | |
RUN php composer-setup.php | |
RUN php -r "unlink('composer-setup.php');" | |
RUN mv /var/www/html/composer.phar /usr/local/bin/composer | |
# Install laravel CLI. | |
# RUN composer global require "laravel/installer" | |
CMD ["apache2-foreground"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
all: start | |
start: | |
docker stack deploy -c docker-compose.yml laravel_project_name | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to
docker build -t <user/repo:tag> .
composer
from getcomposer.orgcomposer global require "laravel/installer"
laravel new html
docker stack deploy -c docker-compose.yml <stack-name>
Composer
docker exec <container-id> composer <command>
PHP Artisan
docker exec <container-id> php artisan <command>