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 Development Company | Hire Laravel Developer

Laravel Development Company | Hire Laravel Developer

Get a free quote for custom Laravel Development Services from a trusted Laravel web development company. Hire Laravel Developers now @ best affordable rates

Get a free quote for custom Laravel Development Services from a trusted Laravel web development company. Hire Laravel Developers now at best affordable rates

Laravel Tutorial - Abusing Laravel

Laravel Tutorial - Abusing Laravel

Laravel Tutorial - Abusing Laravel: In this talk, Gustavo takes a look at the importance of Unit Tests and how Dependency Injection, which is often not promoted by Laravel docs, can help to achieve Unit Testing.

In this talk, Gustavo takes a look at the importance of Unit Tests and how Dependency Injection, which is often not promoted by Laravel docs, can help to achieve Unit Testing.

Thanks for reading

If you liked this post, share it with all of your programming buddies!

Follow us on Facebook | Twitter

Further reading about Laravel

Laravel 5.8 Tutorial for Beginners

Learn GraphQL with Laravel and Vue.js - Full Tutorial

Export or Import of CSV or Excel file in Laravel 5.8 with MySQL

Laravel 5.8 CRUD Tutorial With Example Step By Step

Build RESTful API In Laravel 5.8 Example

Get Weather Data with Laravel Weather

Get Weather Data with Laravel Weather

Get Weather Data with Laravel Weather. Laravel Weather is a good package which we can use to get weather data. It's a wrapper around Open Weather Map API (Current weather). A wrapper around Open Weather Map API (Current weather)

🌤️ A wrapper around Open Weather Map API (Current weather)

Installation

You can install the package via composer:

source-shell
composer require gnahotelsolutions/laravel-weather
Usage
text-html-php
$weather = new Weather();

// Checking weather by city name
$currentWeatherInGirona = $weather->get('girona,es');

// You can use the city id, this will get you unambiguous results
$currentWeatherInGirona = $weather->find('3121456');

Units

By default the package uses metric for Celsius temperature results, this can be modified using the configuration file or on the fly:

text-html-php
$weather = new Weather();

$currentWeatherInGirona = $weather->inUnits('imperial')->get('girona,es');

Language

By default the package uses es for the description translation, this can be modified using the configuration file or on the fly:

text-html-php
$weather = new Weather();

$currentWeatherInGirona = $weather->inLanguage('en')->get('girona');

Guzzle Client Instance

If you need to use another instance of Guzzle, to modify headers for example:

text-html-php
$weather = new Weather();

$guzzle = $this->getSpecialGuzzleClient();

$currentWeatherInGirona = $weather->using($guzzle)->get('girona');

Testing

source-shell
composer test