Last active
March 5, 2021 14:24
-
-
Save jacmkno/5b20f4c05de70420a03f5bc76eaaae48 to your computer and use it in GitHub Desktop.
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
APP_NAME=Sourect | |
APP_ENV=local | |
APP_KEY=base64:AmZFtXskJNRgoVVlfeu5IzgCOW2L9soPAaQ8JeH3Jvg= | |
APP_DEBUG=true | |
APP_URL=http://localhost | |
LOG_CHANNEL=stack | |
DB_CONNECTION=mysql | |
DB_HOST=sourect_mysql | |
DB_PORT=3306 | |
DB_DATABASE=dev | |
DB_USERNAME=dev | |
DB_PASSWORD=dev | |
BROADCAST_DRIVER=log | |
CACHE_DRIVER=file | |
QUEUE_CONNECTION=sync | |
SESSION_DRIVER=file | |
SESSION_LIFETIME=120 | |
REDIS_HOST=127.0.0.1 | |
REDIS_PASSWORD=null | |
REDIS_PORT=6379 | |
MAIL_MAILER=smtp | |
MAIL_HOST=smtp.mailtrap.io | |
MAIL_PORT=2525 | |
MAIL_USERNAME=null | |
MAIL_PASSWORD=null | |
MAIL_ENCRYPTION=null | |
MAIL_FROM_ADDRESS=null | |
MAIL_FROM_NAME="${APP_NAME}" | |
AWS_ACCESS_KEY_ID= | |
AWS_SECRET_ACCESS_KEY= | |
AWS_DEFAULT_REGION=us-east-1 | |
AWS_BUCKET= | |
PUSHER_APP_ID= | |
PUSHER_APP_KEY= | |
PUSHER_APP_SECRET= | |
PUSHER_APP_CLUSTER=mt1 | |
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" | |
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" |
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
-- This file is required, but may be empty if a demo database is not available. |
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
ACLSUPPORT=$( setfacl -m u:www-data:rwX /var/www/laravel/ 2>&1) | |
if [[ $ACLSUPPORT != *"Operation not supported"* ]]; then | |
setfacl -R -m u:www-data:rwX /var/www/laravel/; | |
fi | |
if [ ! -f .env ] ; then | |
cp .env.example .env; | |
else | |
echo ".env FILE ALREADY EXISTS. Skipping copy from .env.example"; | |
fi | |
if [ ! -d vendor ] ; then | |
echo "Running: composer install" | |
composer install; | |
else | |
echo "vendor FOLDER ALEADY EXISTS. Skipping composer install"; | |
fi | |
php artisan storage:link; | |
MYSQL_INSTALLED=$(echo "select * from users"|mysql -udev -pdev -hsourect_mysql dev|wc -l); | |
if [ $MYSQL_INSTALLED == '0' ] ; then | |
php artisan voyager:install; | |
mysql -udev -pdev -hsourect_mysql dev < demodb.sql; | |
php artisan migrate; | |
php artisan mds:sync import; | |
else | |
echo "USERS TABLE ALREADY EXISTS. Skipping voyager:install and MySQL data load." | |
fi | |
if [ ! -d node_modules ] ; then | |
echo "Running: npm install" | |
npm install --loglevel verbose; | |
else | |
echo "node_modules FOLDER ALEADY EXISTS. Skipping npm install"; | |
fi | |
npm run watch; |
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: | |
mysql: | |
image: mysql:5.7 | |
container_name: sourect_mysql | |
environment: | |
MYSQL_ROOT_PASSWORD: root | |
MYSQL_DATABASE: dev | |
MYSQL_USER: dev | |
MYSQL_PASSWORD: dev | |
ports: | |
- "3306:3306" | |
volumes: | |
- dbdata:/var/lib/mysql | |
php: | |
build: | |
context: . | |
args: | |
- NODE_VERSION=v12.18.3 | |
- PHP_IMAGE_TAG=7.2-apache | |
container_name: sourect_laravel | |
environment: | |
APACHE_DOCUMENT_ROOT: /var/www/laravel/public | |
APP_URL: http://localhost | |
AUTORUN: 1 | |
WAIT_HOSTS: sourect_mysql:3306 | |
volumes: | |
- .:/var/www/laravel | |
ports: | |
- "80:80" | |
depends_on: | |
- mysql | |
volumes: | |
dbdata: |
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
ARG PHP_IMAGE_TAG | |
FROM php:${PHP_IMAGE_TAG} | |
EXPOSE 80 | |
WORKDIR /root | |
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.7.3/wait /wait | |
RUN chmod +x /wait | |
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf | |
RUN sed -ri -e 's!AllowOverride None!AllowOverride All!g' /etc/apache2/apache2.conf | |
RUN curl -sS https://getcomposer.org/installer > composer-setup.php | |
RUN php composer-setup.php --version=1.10.10 | |
RUN mv composer.phar /bin/composer | |
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash | |
RUN apt update | |
RUN apt install -y acl git vim default-mysql-client libcurl4-openssl-dev libzip-dev zlib1g-dev libpng-dev libicu-dev libsqlite3-dev libxml2 libxml2-dev | |
RUN apt install -y libcurl4-openssl-dev libzip-dev zlib1g-dev libpng-dev libicu-dev libsqlite3-dev libxml2 libxml2-dev | |
RUN docker-php-ext-install pdo pdo_mysql curl exif gd iconv intl pdo pdo_mysql pdo_sqlite xml zip | |
RUN export NVM_DIR="$HOME/.nvm" | |
RUN /bin/bash -c "[[ -s $HOME/.nvm/nvm.sh ]] && . $HOME/.nvm/nvm.sh" | |
ARG NODE_VERSION | |
RUN /bin/bash -i -c "nvm install $NODE_VERSION && nvm use --delete-prefix $NODE_VERSION" | |
RUN a2enmod rewrite | |
WORKDIR /var/www/laravel | |
ARG AUTORUN | |
CMD /wait; \ | |
/bin/sh -c "exec /usr/sbin/apache2ctl -D FOREGROUND;" & \ | |
/bin/bash -i /var/www/laravel/docker-boot.sh; |
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
#Remove all Volumes | |
docker volume rm $(docker volume ls -q) | |
#Remove all containers | |
docker rm $(docker ps -a -q) | |
#Enter instance | |
docker exec -it INSTANCE_ID /bin/bash | |
#List instances to get INSTANCE_ID | |
docker ps | |
#Activate Environment (-d for detached, --build to rebuild) | |
docker-compose up -d --build | |
docker-compose up --build | |
docker-compose up | |
#Deactivate Environment | |
docker-compose down --remove-orphans | |
#Cleanup docker entirely | |
docker-compose down --remove-orphans; docker rm $(docker ps -a -q); docker volume rm $(docker volume ls -q) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment