Anil Paul

Web Developer – Designer

Azure Laravel CI Pipeline

CI YAML for laravel

first specify the branch to trigger build:

trigger:
  - master

pool and version set up:

pool:
  vmImage: ubuntu-latest

variables:
  phpVersion: 7.4
composer install
- script: |
      sudo update-alternatives --set php /usr/bin/php$(phpVersion)
      sudo update-alternatives --set phar /usr/bin/phar$(phpVersion)
      sudo update-alternatives --set phpdbg /usr/bin/phpdbg$(phpVersion)
      sudo update-alternatives --set php-cgi /usr/bin/php-cgi$(phpVersion)
      sudo update-alternatives --set phar.phar /usr/bin/phar.phar$(phpVersion)
      sudo a
      php -version
    displayName: 'Use PHP version $(phpVersion)'

  - script: composer install --no-interaction --prefer-dist
    displayName: 'composer install'
run tests
 - script: php artisan test
    displayName: 'php artisan test'
copy the env file securely stored in azure dev ops

Please refere azure documentation here

  - task: DownloadSecureFile@1
    displayName: 'Download .env file from secure file library'
    inputs:
      secureFile: .env
npm install
 - script: npm install
    displayName: 'npm install'
Archieve and publish Artifacts
  - task: ArchiveFiles@1
    displayName: 'Archive files'
    inputs:
      rootFolder: '$(System.DefaultWorkingDirectory)'
      includeRootFolder: false
      archiveType: zip

  - task: PublishBuildArtifacts@1
    displayName: 'Publish Artifact: drop'

All together

# PHP
# Test and package your PHP project.
# Add steps that run tests, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/php

trigger:
  - master

pool:
  vmImage: ubuntu-latest

variables:
  phpVersion: 7.4

steps:
  - script: |
      sudo update-alternatives --set php /usr/bin/php$(phpVersion)
      sudo update-alternatives --set phar /usr/bin/phar$(phpVersion)
      sudo update-alternatives --set phpdbg /usr/bin/phpdbg$(phpVersion)
      sudo update-alternatives --set php-cgi /usr/bin/php-cgi$(phpVersion)
      sudo update-alternatives --set phar.phar /usr/bin/phar.phar$(phpVersion)
      sudo a
      php -version
    displayName: 'Use PHP version $(phpVersion)'

  - script: composer install --no-interaction --prefer-dist
    displayName: 'composer install'

  - script: php artisan test
    displayName: 'php artisan test'

  - task: DownloadSecureFile@1
    displayName: 'Download .env file from secure file library'
    inputs:
      secureFile: .env

  - script: sudo npm install -g npm@latest && npm install
    displayName: 'npm install'

  - task: ArchiveFiles@1
    displayName: 'Archive files'
    inputs:
      rootFolder: '$(System.DefaultWorkingDirectory)'
      includeRootFolder: false
      archiveType: zip

  - task: PublishBuildArtifacts@1
    displayName: 'Publish Artifact: drop'

Laravel Websockets Docker Development

Docker Image

webdawe/php-fpm:7.4

Laravel Websockets

LARAVEL_WEBSOCKETS_PORT=6004

nginx will route the port 80 websocket requests to 127.0.0.1:6004

Docker compose

version: '3'
services:
  my-app:
    image: webdawe/php-fpm:7.4
    hostname: my-app
    container_name: my-app
    dns: 8.8.8.8
    environment:
      CONTAINER_ROLE: app
      APP_ENV: local

    volumes:
      - ./:/var/www/html

    networks:
      - my-network
    ports:
      - 80:80
    tty: true