So Im building a Laravel application, I have a mysql db defined in my docker-compose.yml and an nginx webserver to go together with my php app.
this is the Dockerfile of the PHP app:
# Install dependencies
RUN apt-get update && apt-get install -y \
build-essential \
libpng-dev \
libjpeg62-turbo-dev \
libfreetype6-dev \
locales \
zip \
jpegoptim optipng pngquant gifsicle \
unzip \
git \
libonig-dev \
libzip-dev \
curl
# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
# Install extensions
RUN docker-php-ext-install pdo_mysql zip exif pcntl gd mysqli pdo
WORKDIR /var/www
COPY composer.lock composer.json ./
# Install composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=comp>
# Copy existing application directory contents
COPY . ./
RUN chown -R www-data:www-data /var/www
#laravel + packages install
RUN composer install
RUN chmod -R guo+w storage
# Expose port 9000 and start php-fpm server
EXPOSE 9000
CMD ["php-fpm"]
ENTRYPOINT ["/var/www/migrate.sh"]
the shell script just is this:
#!/bin/sh
nohup php artisan migrate:fresh --force
golb_app_1 exited with code 0
app_1 | Dropped all tables successfully.
app_1 | Migration table created successfully.
app_1 | Migrating: 2014_10_12_000000_create_users_table
app_1 | Migrated: 2014_10_12_000000_create_users_table (24.82ms)
app_1 | Migrating: 2014_10_12_100000_create_password_resets_table
app_1 | Migrated: 2014_10_12_100000_create_password_resets_table (17.29ms)
app_1 | Migrating: 2019_08_19_000000_create_failed_jobs_table
app_1 | Migrated: 2019_08_19_000000_create_failed_jobs_table (22.36ms)
app_1 | Migrating: 2021_06_09_080445_create_posts_table
app_1 | Migrated: 2021_06_09_080445_create_posts_table (47.77ms)
app_1 | Migrating: 2021_06_09_120221_update_users_table
app_1 | Migrated: 2021_06_09_120221_update_users_table (21.67ms)
golb_app_1 exited with code 0
Is the output that I am getting If i run my docker-compose up. Then Container will restart and do it again and again.
If I comment out the script and run it with docker exec It will run and the DB works fine.