Last active
April 18, 2022 07:10
-
-
Save bikalbasnet/e89d7d7b9a50cae2f508cd0943921ac8 to your computer and use it in GitHub Desktop.
This Gist allows you to run php applications and database without installing anything on your machine except docker
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
# Need to run composer install for a repo does not have docker? Use this | |
docker run --rm -v $(pwd):/app webdevops/php:8.0 bash -c "cd /app && composer install" | |
# Create Network | |
docker network create some-network | |
# Run the PHP Project | |
docker run --rm --name some-app -e 'WEBROOT=/var/www/html/public/' -e 'PHP_CATCHALL=1' -e "PUID=`id -u $USER`" -e "PGID=`id -g $USER`" -v $(pwd):/var/www/html/ -p 8000:80 --net=some-network richarvey/nginx-php-fpm:latest | |
# Run the mysql (if needed) | |
docker run --rm --name somemysql -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=laravel -p 3306:3306 -p 33060:33060 -d --net=some-network mysql:5.6 | |
# Run adminer (if needed) | |
docker run --rm --name myadminer -v intyo-adminer -d --net=some-network -p 8080:8080 adminer | |
# Laravel Specific | |
docker exec -it some-app cp .env.example .env | |
docker exec -it some-app php artisan migrate:fresh | |
# Detect code standard violoation | |
docker run -v $(pwd)/app:/scripts/ texthtml/phpcs phpcs --standard=PSR12 /scripts/ | |
# Install without memory limit for composer | |
php -d memory_limit=-1 /usr/local/bin/composer require | |
## Run Postgres on the fly | |
docker volume create pgdata | |
docker run -it --rm --name vinyldb -e POSTGRES_PASSWORD=postgres -p:5432:5432 -d -v pgdata:/var/lib/postgresql/data postgres | |
docker volume create mydata | |
docker run -it --rm --name mysqldb -e MYSQL_ROOT_PASSWORD=root -p:3306:3306 -d -v mydata:/var/lib/mysql --net=local mysql | |
docker volume create adminerdata | |
docker run --rm -e ADMINER_DEFAULT_SERVER=mysqldb --name myadminer -v adminerdata -d -p 8080:8080 --net=local adminer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment