Skip to content

Instantly share code, notes, and snippets.

@azophy
Created August 30, 2022 04:22
Show Gist options
  • Save azophy/3d5f10d2c0c0e874760f993a8326cb2e to your computer and use it in GitHub Desktop.
Save azophy/3d5f10d2c0c0e874760f993a8326cb2e to your computer and use it in GitHub Desktop.
Minimalist Dockerization for PHP project (Laravel, CodeIgniter, Symphony, etc).

Minimalist Dockerization for PHP project (Laravel, CodeIgniter, Symphony, etc)

This Gist is optimized for learning & simplicity. You should optimize further if you wish to deploy to production.

Features

  • basic PHP & Webserver using php:apache base image
  • composer
  • mlocati/php-extension-installer for easily install PHP extensions

Usage

  • copy docker-compose.yml and Dockerfile into your folder
  • run docker compose up
services:
app:
build:
context: .
ports:
- 8000:80
# this base image already contains webserver & php runtime
FROM php:8.1-apache
# setup composer & php extension installer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/bin/
# install your PHP extension here
RUN install-php-extensions zip pdo_pgsql
# copy files from source code
COPY . /var/www/html
RUN composer install && composer dump-autoload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment