dockerlaravel-4php-5.6laravel-config

Dockerizing Laravel 4.1 Project with PHP 5.6 and MySQL 5.7.20


Description: I have an existing Laravel 4.1 project that requires PHP 5.6 and MySQL 5.7.20. My development environment is on Ubuntu 20.04 with PHP 8.1 and MySQL 8.0.35. I am looking to Dockerize this project to ensure a consistent development environment.

Requirements: Use PHP 5.6 in the Docker container. MySQL version 5.7.20 in the Docker container. Set up the necessary configurations for Laravel 4.1.

Questions: Dockerfile for PHP 5.6: I need guidance on creating a Dockerfile that installs PHP 5.6 for my Laravel 4.1 project. What specific steps and commands should I include?

Dockerfile for MySQL 5.7.20: Similarly, how can I create a Dockerfile for MySQL 5.7.20 to ensure compatibility with my Laravel 4.1 project? Any specific configurations or settings I need to be aware of?

Docker Compose: What should my docker-compose.yml file look like to orchestrate both the PHP and MySQL containers? Are there any best practices or considerations for Laravel 4.1?

Laravel 4.1 Configuration: Are there any specific Laravel configurations I need to adjust to work seamlessly with PHP 5.6 and MySQL 5.7.20 inside Docker?

Development Workflow: How should I structure my Docker setup for an efficient development workflow? Are there any tools or practices I should adopt?

Additional Context: I have already checked Docker Hub for PHP 5.6 and MySQL 5.7.20 images but would appreciate guidance on selecting the most appropriate ones for my scenario. Any tips or recommendations for managing dependencies and environment variables within Docker.


Solution

  • This procedure is success for this project,

    1. https://github.com/a2way-com/drop-in-docker-php using this you can dockarize a laravel app easily.

    2. have to change this to suitable way of this project, here I attached my changes.

    App.Dockerfile

    FROM php:5.6-fpm-alpine
    ARG UID
    RUN apk --update add shadow
    RUN usermod -u $UID www-data && groupmod -g $UID www-data
    RUN apk --update add sudo
    RUN echo "www-data ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
    RUN apk add --no-cache libmcrypt-dev libmcrypt
    RUN apk --update add composer
    RUN docker-php-ext-install mcrypt
    RUN docker-php-ext-enable mcrypt
    RUN docker-php-ext-install pdo_mysql
    RUN apk add --update npm
    RUN apk add --update make
    

    docker-compose.yml

    version: '3.8'
    name: 'drop-in-docker-php'
    services:
     mysql:
      image: mysql:5.7.44
      env_file:
       - ./env/mysql.env
      ports:
       - $MYSQL_PORT:3306
      volumes:
       - ./vols/mysql/:/var/lib/mysql/
      user: $UID:$UID
     adminer:
      image: adminer:4.8.1-standalone
      env_file:
       - ./env/adminer.env
      ports:
       - $ADMINER_PORT:8080
     mailhog:
      image: mailhog/mailhog:v1.0.1
      ports:
       - $MAILHOG_SMTP_PORT:1025
       - $MAILHOG_UI_PORT:8025
     app:
      image: $APP_IMAGE
      build:
       context: .
       dockerfile: ./Dockerfiles/app.Dockerfile
       args:
        UID: $UID
      volumes:
       - $APP_VOLUMES_SRC:/var/www/html/
       - ./vols/app/docker-user-home/:/home/www-data/
      env_file:
       - ./env/app.env
     static:
      image: nginx:1.24.0-alpine3.17
      volumes:
       - $STATIC_VOLUMES_PUBLIC:/usr/share/nginx/html/
     proxy:
      image: $PROXY_IMAGE
      build:
       context: .
       dockerfile: ./Dockerfiles/proxy.Dockerfile
      ports:
       - $PROXY_PORT:80
      env_file:
        - ./env/proxy.env
    

    changing the above two files and making the env files correctly you can dockarize this project successfully.