Last active
March 10, 2024 13:25
-
-
Save ibayazit/76101dc384bcd895fcce866a05e004b8 to your computer and use it in GitHub Desktop.
Laravel 5.7 dockerize
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: | |
app: | |
build: | |
context: . | |
dockerfile: Dockerfile | |
ports: | |
- 8000:8000 | |
volumes: | |
- .:/var/www/html | |
depends_on: | |
- db | |
networks: | |
- laravel-net | |
db: | |
platform: linux/x86_64 | |
image: mysql:5.7 | |
environment: | |
MYSQL_ROOT_PASSWORD: laravel_password | |
MYSQL_DATABASE: laravel_db | |
MYSQL_USER: laravel_user | |
MYSQL_PASSWORD: laravel_password | |
ports: | |
- 3306:3306 | |
volumes: | |
- ./.docker/mysql:/var/lib/mysql | |
networks: | |
- laravel-net | |
networks: | |
laravel-net: |
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.4.0-cli | |
WORKDIR /var/www/html | |
RUN apt-get update && apt-get install -y \ | |
git \ | |
zip \ | |
unzip \ | |
libmcrypt-dev \ | |
libonig-dev \ | |
libxml2-dev \ | |
libzip-dev \ | |
libfreetype6-dev \ | |
libjpeg62-turbo-dev \ | |
libpng-dev | |
RUN pecl update-channels && pecl install mcrypt-1.0.4 && docker-php-ext-enable mcrypt | |
RUN docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath zip | |
RUN apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libpng-dev \ | |
&& docker-php-ext-configure gd --with-freetype --with-jpeg \ | |
&& docker-php-ext-install -j$(nproc) gd | |
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer | |
COPY . . | |
# RUN composer install --no-interaction --no-scripts --no-suggest | |
RUN chown -R www-data:www-data /var/www/html/storage /var/www/html/bootstrap/cache | |
EXPOSE 8000 | |
CMD ["php", "-S", "0.0.0.0:8000", "-t", "./public"] |
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
// Import existing database | |
docker exec -i CONTEINER_NAME mysql -uDATABASE_USER -pDATABASE_PASSWORD DATABASE_NAME < ~/LOCAL_PATH/BACKUP.sql | |
// if you can't connect to database change .env DB_HOST to | |
DB_HOST=host.docker.internal |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment