This is a minimal and ready-to-use Docker setup for developing PHP or Node.js projects.
It is optimized for development environments, but with minimal adjustments, it can also be used for production.
- PHP-FPM: PHP FastCGI Process Manager for handling PHP-based applications.
- Node.js: A JavaScript runtime built on Chrome's V8 JavaScript engine.
- MariaDB: An open-source relational database management system, a fork of MySQL.
- Nginx: A high-performance web server and reverse proxy.
- Certbot: For automatic SSL certificate generation and renewal.
- Redis: A fast, open-source, in-memory data structure store, used as a database, cache, and message broker.
- MinIO: An open-source object storage service, compatible with Amazon S3.
-
Add the repository as a submodule:
git submodule add https://github.com/VictorMGomes/slim-containers.git
-
Copy the example environment file:
cp slim-containers/.env.example slim-containers/.env
-
Build images:
docker-compose -f slim-containers/docker-compose.yml build --no-cache
-
To start selected services in detached mode (background):
docker-compose -f slim-containers/docker-compose.yml up -d nginx php-fpm mariadb
-
To stop and remove containers:
docker-compose -f slim-containers/docker-compose.yml down
-
NGINX
You can configure an Nginx reverse proxy by defining theNGINX_VIRTUAL_HOSTS_CONFIG
variable.
The format ofNGINX_VIRTUAL_HOSTS_CONFIG
follows this structure:
VIRTUAL_HOST_DOMAIN:TEMPLATE_NAME:SERVICE_NAME:PUBLIC_PATH
,
where:VIRTUAL_HOST_DOMAIN
is the domain name,TEMPLATE_NAME
is the Nginx template,SERVICE_NAME
is the container service name,PUBLIC_PATH
is the application's public directory (if applicable).
Examples:
-
If your application is a Laravel application:
NGINX_VIRTUAL_HOSTS_CONFIG="app.local:php-fpm:${PHP_FPM_SERVICE_NAME}:/public"
-
If your application has its root folder as the public folder:
NGINX_VIRTUAL_HOSTS_CONFIG="app.local:php-fpm:${PHP_FPM_SERVICE_NAME}:"
-
If your application is a Node.js application:
NGINX_VIRTUAL_HOSTS_CONFIG="app.local:nodejs:${NODE_SERVICE_NAME}:"
-
If you have multiple sites with different domains, separated by a comma
,
, for both PHP-FPM and Node.js:NGINX_VIRTUAL_HOSTS_CONFIG="app.local:php-fpm:${PHP_FPM_SERVICE_NAME}:/public,app2.local:nodejs:${NODE_SERVICE_NAME}:"
Important: For local domains, you need to configure the hosts file of your operating system.
-
Windows hosts file path:
C:\Windows\System32\drivers\etc\hosts
-
Linux hosts file path:
/etc/hosts
Add the following lines to your hosts file to map virtual domains:
127.0.0.1 app.local 127.0.0.1 app2.local
To contribute to this project, please read the contributing guide.
Check the upcomming features in TODO of this project.
Check out the release changelog for this project.
If this project has been useful to you, consider making a donation to help it grow.
You can choose a donation method by clicking here