TASKS 21: Docker & Deployment Setup - RadLeoOFC/laravel-admin-panel GitHub Wiki
Docker & Deployment Setup Report
Objective
The goal of this task is to set up a production-like environment using Docker containers and orchestration. The following steps have been taken:
- Dockerizing the Laravel Application
- Setting Up Environment Variables
- Handling Local vs. Production Differences
- Deploying to AWS
Each step is documented with corresponding screenshots and explanations.
1. Dockerizing the Laravel Application
A Dockerfile and docker-compose.yml have been created to set up Laravel, MySQL, and Nginx. Below are the key steps:
- Created a Dockerfile to define the Laravel application container.
- Set up MySQL and Nginx in the
docker-compose.ymlfile. - Configured volumes to persist data.
Dockerfile

docker-compose.yml file


nginx_config file

supervisord_config file

docker build

Screenshot: Terminal output showing running containers after using docker-compose up -d.


2. Setting Up Environment Variables
The .env file was configured to work seamlessly with Docker environment variables. The key updates include:
- Mapped
.envvariables todocker-compose.yml. - Ensured database credentials are correctly loaded from the
.envfile.
Screenshot: Displaying .env file with database credentials.


3. Handling Local vs. Production Differences
To handle different environments, separate Docker Compose files were created:
docker-compose.dev.yml– used for local development with debugging enabled.docker-compose.prod.yml– optimized for production with security and performance improvements.
Screenshot: Terminal showing different Docker Compose files.

docker-compose.dev.yml file


docker-compose.prod.yml file


nginx_dev_config file

nginx_prod_config file

Launching a local development environment


4. Deploying to AWS
The Laravel application was deployed to an AWS EC2 instance using Docker. The following steps were taken:
- Copied the project to the server using
scp. - Installed Docker and Docker Compose on the EC2 instance.
- Ran
docker-compose up -dto start the application. - Configured security groups to allow HTTP, HTTPS, and SSH access.
- Fixed permission issues for Laravel storage and cache directories.
Screenshot: AWS EC2 instance with running containers.

Screenshot: Laravel application running on AWS.

5. Admin Credentials for the Application on AWS Server
The application is deployed and accessible at:
URL:
http://13.51.156.86:8080/register
http://13.51.156.86:8080/memberships
Admin Login Credentials:
- Email (Username):
[email protected] - Password:
password
These credentials can be used to log in as an administrator and manage the application.
Conclusion
The Laravel application has been successfully containerized and deployed using Docker and AWS EC2. The environment is now more scalable and mirrors a production setup. Key takeaways from this process:
- Docker provides a consistent environment for development and production.
- Environment variables must be handled correctly to ensure portability.
- Separate configurations for development and production help streamline deployments.
- Deploying to AWS requires setting up security rules and managing permissions properly.
Further improvements can include using a CI/CD pipeline to automate deployments and adding monitoring tools for better observability.
Final Screenshot: Push to GitHub with commit message
