This repository provides the simplest and most efficient Docker setup for running Symfony applications. It includes a Dockerfile for building the container and a Docker Compose file for easy management.
Author: Destiny Diekedie Contact: Upwork LinkedIn
- Ubuntu 20.04 base image: Provides a stable and reliable environment.
- PHP 8.2: Uses the latest stable PHP version for optimal performance and features.
- Node.js 18.18.2 and npm: Includes Node.js and npm for frontend development.
- Composer: Installs Composer for dependency management.
- Symfony CLI: Installs the Symfony CLI for development tools.
- Graceful shutdown: The
entrypoint.sh
script ensures the Symfony server stops cleanly when the container is stopped. - Port 8001: The Symfony server runs on port 8001, making it easy to access.
- Volume mapping: Maps your local
app/
directory to/var/www/html/
in the container, allowing for seamless code changes. - Docker Compose: Simplifies the process of building and running the container.
- Timezone Set: Sets the timezone to Africa/Lagos.
- Docker installed on your system.
- Docker Compose installed on your system.
-
Clone the repository:
git clone <your-repository-url> cd <repository-directory>
-
Create your Symfony project directory:
Create an
app
directory in the root of your project. This directory will be mounted into the Docker container.mkdir app
-
Place your Symfony project inside the app directory or Leave the app directory empty: You can leave the app directory empty or place your existing Symfony project inside the newly created app directory. In case you left the app directory empty, make sure to restart the container or symfony server after installing a new Symfony project. The Symfony CLI tool will not restart the server for you.
-
Build and run the Docker container:
docker-compose up --build
This command will build the Docker image and start the container.
-
Access your Symfony application:
Open your web browser and navigate to
http://localhost:8001
. -
Stop the container:
docker-compose down