added dockerignore

added wait for db before app started
This commit is contained in:
jack
2018-05-17 12:26:32 +08:00
parent 06aa931eb5
commit 40830f327d
5 changed files with 30 additions and 20 deletions
+2
View File
@@ -0,0 +1,2 @@
vendor
node_modules
+3 -4
View File
@@ -1,5 +1,5 @@
FROM php:7
RUN apt-get update -y && apt-get install -y openssl zip unzip git zlib1g-dev
FROM php:7.1.3
RUN apt-get update -y && apt-get install -y openssl zip unzip git zlib1g-dev netcat mysql-client
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN docker-php-ext-install pdo pdo_mysql zip
WORKDIR /app
@@ -8,6 +8,5 @@ RUN composer install
COPY wait.sh /usr/local/bin/wait.sh
RUN chmod +x /usr/local/bin/wait.sh
CMD /usr/local/bin/wait.sh && php artisan serve --host=0.0.0.0 --port=8000
CMD /usr/local/bin/wait.sh && php artisan migrate && php artisan db:seed && php artisan serve --host=0.0.0.0 --port=8000
EXPOSE 8000
+15 -14
View File
@@ -1,18 +1,5 @@
version: '2'
version: '3'
services:
app:
build: .
ports:
- "8000:8000"
volumes:
- .:/app
env_file: .env
working_dir: /app
command: bash -c 'sh /usr/local/bin/wait.sh && php artisan migrate && php artisan db:seed && php artisan serve --host 0.0.0.0'
depends_on:
- mysql
links:
- mysql
mysql:
build:
context: ./docker/mysql
@@ -30,6 +17,20 @@ services:
ports:
- "3306:3306"
app:
build: .
ports:
- "8000:8000"
volumes:
- .:/app
env_file: .env
working_dir: /app
depends_on:
- mysql
links:
- mysql
phpmyadmin:
depends_on:
- mysql
+3 -1
View File
@@ -98,7 +98,9 @@ export default {
if(store.getters['auth/user'].role === 'admin'){
this.$router.push({ name: 'admin.home' })
}
this.$router.push({ name: 'home' })
else{
this.$router.push({ name: 'home' })
}
}
}
}
+7 -1
View File
@@ -1,7 +1,13 @@
#!/bin/bash
HOST="mysql"
PORT="3306"
USER="default"
PASSWORD="secret"
DATABASE="default"
echo "Waiting for mysql"
until mysql -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" -uroot -p"$MYSQL_ENV_MYSQL_ROOT_PASSWORD" &> /dev/null
until nc -w 1 -z mysql 3306 &> /dev/null
do
printf "."
sleep 1