- Overview
- Live Site
- Features
- Prerequisites
- Installation
- Configuration
- Using Makefile
- Environment Variables
- Deployment
- Accessing Services
- Troubleshooting
- License
This project is a Dockerized CodeIgniter 3 application designed to run on Vercel. It utilizes PostgreSQL as its database and provides a set of Docker Compose commands for managing the development environment.
You can view a live demo of this application here.
- Dockerized environment for PHP and PostgreSQL
- Easily deployable on Vercel
- Managed with Docker Compose and Makefile
- Environment variable support
- PostgreSQL database integration
- Docker
- Docker Compose
To get started with this project, clone the repository and navigate to the project directory.
git clone <repository-url>
cd <repository-directory>Ensure you have the necessary environment variables configured in your .env file. or copy from the .env_sample Here is an example:
# Database configuration
POSTGRES_DB=codeigniter
POSTGRES_USER=codeigniter_user
POSTGRES_PASSWORD=codeigniter_password
# Additional configuration
POSTGRES_HOST=host.docker.internal
POSTGRES_PORT=5433
# Application-specific environment variables
APP_ENV=production
APP_DEBUG=false
APP_URL=http://localhostThe project includes a Makefile to simplify common Docker Compose tasks. Below is a list of available commands:
make upThis command starts the PHP and PostgreSQL containers in detached mode.
make downThis command stops and removes the running containers.
make shellThis command opens a Bash shell in the PHP container.
make composer-installThis command installs PHP dependencies using Composer inside the PHP container.
make composer-updatemake migration name=add-users-tablemake (controller|model) module=product name=productmake migrateThis command updates PHP dependencies using Composer inside the PHP container.
make logsThis command displays the logs from the Docker containers.
make restartThis command restarts the Docker containers.
make postgres-shellThis command opens a Bash shell in the PostgreSQL container.
Make sure to set up a .env file with your database configuration and other environment-specific settings.
To deploy this application to Vercel, follow these steps:
Install Vercel CLI
npm install -g vercelLogin to your Vercel account
vercel loginConfigure vercel.json as follows:
{
"version": 2,
"builds": [
{ "src": "api/*.php", "use": "vercel-php@0.7.1" }
],
"routes": [
{ "src": "/(.*)", "dest": "/api/index.php" }
]
}This configuration will ensure that all your PHP files under api/ are deployed and processed correctly, and all incoming requests are routed to api/index.php
Deploy to Vercel
vercel --prodAfter starting the Docker containers, you can access the following services:
- PHP application: http://localhost:8081 (or the port you configured)
- PostgreSQL database: Accessible via
psqlor a database client using the credentials provided in the.envfile.
- Container Issues: If you encounter conflicts with container names, ensure you stop any existing containers that might be using the same names or ports.
- Environment Variables: Make sure your
.envfile is correctly set up with all required variables. - Vercel Deployment: Ensure your build files are in the correct directory and that your
vercel.jsonis configured properly. - Vercel Error: try to change the Node.js Version to 18.x to fix this issue
This project is licensed under the MIT License.