Skip to content

Optimize Dockerfile and docker compose for Better Performance, Security, and Reduced Image Size #383

@Neophytis

Description

@Neophytis

Problem

The current Dockerfile has several inefficiencies that impact build time, image size, and security:

  • Image Size: PHP image is 2.12GB (disk usage) / 423MB (content size) — can be reduced by ~40–50%.
  • Security Issues: Running as root user, unnecessary packages installed, using COMPOSER_ALLOW_SUPERUSER=1.
  • Build Inefficiency: 15+ separate RUN commands creating unnecessary layers.
  • Missing Optimizations: No multi-stage build separation, inefficient caching.

Current State

IMAGE                    DISK USAGE   CONTENT SIZE
bewelcome/php:latest     2.12GB       423MB
bewelcome/nginx:latest   219MB        76MB

We should also match the MariaDB version until we migrate the platform

mysql  Ver 15.1 Distrib 10.1.48-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions