Skip to content

edwinwcw2021/laravel_docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Debuggable Laravel Application with Docker & SQL Server - Local Development

Introduction

Learn to develop your Laravel application locally using Docker, simplifying the deployment and maintenance process. This guide walks you through setting up a pre-configured Docker image, enabling seamless connectivity to your SQL Server database, and providing a reliable development environment.

This is a brief, proof-of-concept example of Laravel JWT authentication. While it is not comprehensive and doesn't implement HTTPS-only cookies for the refresh token, it is functional. Programmers should be able to integrate this code directly into a Laravel environment for testing and debugging

My current Docker image is compliant with the Docker Scout vulnerability check. (Oct 14, 2025) screen5

Prerequist installation


Install and setup procedures

  1. Configure Git to support Unix line endings (LF).
git config --global core.autocrlf input
  1. Run the script below to clone the Git repository with the Docker setup and PHP source code into the chosen directory.
git clone https://github.com/edwinwcw2021/laravel_docker.git
cd laravel_docker
  1. Download the MSSQL backup file here.
  2. Restore the backup to your MSSQL Developer server. (My local SA password is sa123. If you are using a different password, please update it in the .env file and the config.php file accordingly.) Remember to enable TCP/IP in MSSQL after the first installation. To do this, press Windows + R, type SQLServerManager16.msc, and press Enter.
SQLServerManager16.msc

screen 1 5. Run the following script to pull the Docker image, create the necessary volume, and create the Docker container:

docker volume create dbdata
docker compose up -d --build
  1. Execute the script below to open a Bash shell within the Docker container, or use VS Code to run postinstall.sh as shown in the YouTube tutorial:
bash.bat
  1. Execute the post-install script below in a Linux Bash shell: (This script will initialize MySQL and download my tested vendor files for Laravel. You can run it using composer update in the Dev Console in VS Code.)
sudo su -
. /usr/src/postinstall.sh
  1. Configure MySQL and start debugging and laravel. For details, please refer to youtube.
. /usr/src/startlaral.sh

screen 2 screen 3 9. Finally. Use Postman to test the RestAPI functionality


Technical Information

  1. Microsoft ODBC Driver 18 for SQL Server in Linux
  2. Laravel Framework 11.46.1
  3. Ubuntu Linxu 22.04
  4. Nginx/1.18.0
  5. Php 8.4
  6. MySQL Community Server 9.2.0
  7. Once the development environment is set up, find additional information [here].

Usage Guide for further development and System Design

  1. Mount Point 1 (Configuration and Startup): The local folder .\linux is mounted to the container path /usr/src. This mount is used for startup scripts and configuration files to be executed inside the Docker container during setup and development. This mount point can be utilized for further development.

  2. Mount Point 2 (Web Development): The local folder .\Web is mounted to /var/www/html. This links directly to the PHP source code. If the code was obtained via git clone, please delete the .git folder within this mount point to prevent conflicts with your own version control.

  3. Mount Point 3 (Database Persistence): A named volume, dbdata, is created and mounted to persist the MySQL database files. This volume can be reused across different projects. You can reuse this base Docker image by creating new containers with different port assignments and additional mount points. This design ensures data persistence and reuse. Even if the container is droped and recreated with a different image, the data will remain safely stored as long as the volume is referenced.

screen4

  1. Please note that this Docker setup is intended for development use only. It should not be deployed directly to any production system. Additional work is required for a production release — for example, the .env file should never be placed in the root directory of the code.

  2. I set up this Docker environment over seven months ago, but additional work is needed before it can be released to Docker Hub. For development and debugging PHP code on your local PC, having root access is much more convenient — especially when using the VS Code remote debugger.

  3. he default password for MySQL is mypass, and my local SQL password is sa123. I strongly suggest you use your own strong password and update both the .env and config.php files accordingly.

  4. If you need MySQL to start every time the container launches, please uncomment (remove the #) the line for /etc/init.d/mysql start inside the /usr/local/bin/startup.sh file.

docker hub

Step-by-step guide to build and debug Laravel 11 in Docker — with MySQL, MSSQL, and JWT authentication

Rumble tutorial

About

Debuggable Laravel Application with Docker, MSSQL Server (optional MySQL 9), nginx, php 8.4

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published