Created
January 11, 2021 23:17
-
-
Save haroldcris/6130c0d07d972b4ff74077106071fea6 to your computer and use it in GitHub Desktop.
Laravel from https://tuxyvarman.com/2020/05/18/docker-compose-up-your-entire-laravel-apache-mysql-development-environment/
This file contains hidden or 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.7' | |
| services: | |
| laravel-app: | |
| build: | |
| context: '.' | |
| args: | |
| uid: ${UID} | |
| container_name: laravel-app | |
| environment: | |
| - APACHE_RUN_USER=#${UID} | |
| - APACHE_RUN_GROUP=#${UID} | |
| volumes: | |
| - .:/var/www/html | |
| ports: | |
| - 8000:80 | |
| networks: | |
| backend: | |
| aliases: | |
| - laravel-app | |
| mysql-db: | |
| image: mysql:5.7 | |
| container_name: ${DB_HOST} | |
| ports: | |
| - "33061:3306" | |
| command: --init-file /docker-entrypoint-initdb.d/init.sql | |
| volumes: | |
| - ./run/var:/var/lib/mysql | |
| - ./run/dump/init.sql:/docker-entrypoint-initdb.d/init.sql | |
| environment: | |
| - MYSQL_ROOT_PASSWORD=securerootpassword | |
| - MYSQL_DATABASE=${DB_DATABASE} | |
| - MYSQL_USER=${DB_USERNAME} | |
| - MYSQL_PASSWORD=${DB_PASSWORD} | |
| networks: | |
| backend: | |
| aliases: | |
| - db | |
| networks: | |
| backend: | |
| name: backend-network |
This file contains hidden or 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.4.6-apache | |
| RUN apt-get update | |
| # 1. development packages | |
| RUN apt-get install -y \ | |
| git \ | |
| zip \ | |
| curl \ | |
| sudo \ | |
| unzip \ | |
| libicu-dev \ | |
| libbz2-dev \ | |
| libpng-dev \ | |
| libjpeg-dev \ | |
| libmcrypt-dev \ | |
| libreadline-dev \ | |
| libfreetype6-dev \ | |
| libonig-dev \ | |
| libzip-dev \ | |
| g++ | |
| # 2. apache configs + document root | |
| ENV APACHE_DOCUMENT_ROOT=/var/www/html/public | |
| RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf | |
| RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf | |
| # 3. mod_rewrite for URL rewrite and mod_headers for .htaccess extra headers like Access-Control-Allow-Origin- | |
| RUN a2enmod rewrite headers | |
| # 4. start with base php config, then add extensions | |
| RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini" | |
| RUN docker-php-ext-install \ | |
| bz2 \ | |
| intl \ | |
| iconv \ | |
| bcmath \ | |
| opcache \ | |
| calendar \ | |
| mbstring \ | |
| pdo_mysql \ | |
| zip | |
| # 5. composer | |
| COPY --from=composer:latest /usr/bin/composer /usr/bin/composer | |
| # 6. we need a user with the same UID/GID with host user | |
| # so when we execute CLI commands, all the host file's ownership remains intact | |
| # otherwise command from inside container will create root-owned files and directories | |
| ARG uid | |
| RUN useradd -G www-data,root -u $uid -d /home/devuser devuser | |
| RUN mkdir -p /home/devuser/.composer && \ | |
| chown -R devuser:devuser /home/devuser |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment