php artisan migrate on Azure (in BitBucket pipeline)

php artisan migrate on Azure (in BitBucket pipeline)

I have setup a pipeline in BitBucket to automatically deploy my master branch of my project to an Azure Web App instance.

I have setup a pipeline in BitBucket to automatically deploy my master branch of my project to an Azure Web App instance.

The app deploys the files and runs composer update as expected (although it does warn that it's running as root), but php artisan migrate --force returns:

Illuminate\Database\QueryException : SQLSTATE[HY000] [1045] Access denied for user 'forge'@'127.0.0.1' (using password: NO) (SQL: select * from information_schema.tables where table_schema = forge and table_name = migrations) I have already created the .env file, and when I run php artisan migrate from within a shell it runs successfully and the tables are created.

Being that 'forge' is the default user in database.php I figure .env isn't being loaded when the command is fired from the deploy script.

Is there something obvious I've missed to cause this issue, or should I somehow set it up to not run as root? I could replace the database details in database.php but I feel that's the wrong thing to do.

edit

.env contents (with certain data replaced with ****):

APP_NAME=Laravel
APP_ENV=local
APP_KEY=********
APP_DEBUG=true
APP_URL=********

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=********
DB_DATABASE=********
DB_USERNAME=********
DB_PASSWORD=********

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_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

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}"

edit 2

I realise I'm yet to publish my bitbucket-pipelines.yml file:

image: php:7.2-fpm

pipelines:
  branches:
    master:
      - step:
          script:
            - apt-get update && apt-get install -qy git curl libmcrypt-dev mysql-client && apt-get install -qy unzip git
            - yes | pecl install mcrypt-1.0.1
            - docker-php-ext-install pdo_mysql
            - curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
            - composer update
            - php artisan migrate --force
            - php artisan serve --port=80 &
            - sleep 5
            - curl -vk http://localhost:80
          deployment: staging
          services:
            - mysql

definitions:
  services:
    mysql:
      image: mysql:5.7
      environment:
        MYSQL_DATABASE: '******'
        MYSQL_RANDOM_ROOT_PASSWORD: 'yes'
        MYSQL_USER: '******'
        MYSQL_PASSWORD: '******'
        MYSQL_PORT: '******'

I also have a .env.pipelines file:

APP_ENV=local
APP_KEY=******
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_DATABASE=******
DB_USERNAME=******
DB_PASSWORD=******

laravel azure

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Php how to delete multiple rows through checkbox using ajax in laravel

In this article i will let you know to delete multiple rows through checkbox using ajax in laravel and before delete we will give a confirmation message.

How to Hire Laravel Developers and How Much Does It Cost.

Want to make the most out of the latest Laravel technology? Here is your guide on how to hire the best Laravel developer, and at the right price. 

How to perform migration rollback in laravel

Sometimes we need to rollback one specific migration. Here, in this article we will discuss about the migration rollback in laravel.

Laravel Development Company

Skenix Infotech is a top Laravel Website Development Company with Expert Laravel Developers that provides robust Laravel Development Services at fair costs.

5 Laravel’s Hidden Gems

Spread the love1. Stop on first validation error By default, Laravel will check for all validation rules and return a list of errors. But if you want to stop this process after first validation failure, that’s how you can achieve…Read More→