Skip to content

Commit 91b0af3

Browse files
committed
Add Draft of Readme.md
1 parent 192a0eb commit 91b0af3

File tree

1 file changed

+169
-0
lines changed

1 file changed

+169
-0
lines changed

README.md

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
# Laravel Dockerize Project
2+
## Overview
3+
4+
This project serves as an educational guide for Laravel developers looking to create modern, efficient, and flexible Docker environments for both development and production. It demonstrates best practices in building Docker images tailored for Laravel applications, providing a solid foundation for developers to understand and extend Docker functionalities in their own projects.
5+
6+
## Table of Contents
7+
8+
- [Overview](#overview)
9+
- [Project Structure](#project-structure)
10+
- [Development Environment](#development-environment)
11+
- [Key Features](#key-features)
12+
- [Getting Started](#getting-started)
13+
- [Usage](#usage)
14+
- [Production Environment](#production-environment)
15+
- [Building the Production Image](#building-the-production-image)
16+
- [Deploying](#deploying)
17+
- [Technical Details](#technical-details)
18+
- [Contributing](#contributing)
19+
- [License](#license)
20+
21+
## Project Structure
22+
23+
The project is divided into three main parts: example Laravel 11 app used to test docker environments,
24+
development environment and production environment.
25+
26+
### Development Environment
27+
28+
Focuses on providing a flexible and independent environment that includes all necessary tools for typical Laravel development, such as Redis, MariaDB/PostgreSQL, and Node.js for building frontend assets. This environment supports rapid development and testing.
29+
30+
### Production Environment
31+
32+
Emphasizes building a slim, secure, and efficient Docker image suitable for deploying a Laravel application in production. The image is optimized for performance, with pre-built assets and only essential dependencies.
33+
34+
## Key Features
35+
36+
### Development Environment
37+
38+
- Complete Development Stack: Includes PHP, MySQL/PostgreSQL, Redis, and Node.js.
39+
- Hot-Reloading: Supports live reloading of code changes for rapid development.
40+
- Service Flexibility: Easily swap out or add services (e.g., switching between MySQL and PostgreSQL).
41+
- Persistent Volumes: Code changes are reflected immediately without rebuilding containers.
42+
43+
### Production Environment
44+
45+
- Optimized Image: The production image is slim, containing only the necessary dependencies for running a Laravel application.
46+
- Pre-Built Assets: Assets are built during the image creation process, ensuring that the production environment is ready to serve content immediately.
47+
- Security Best Practices: The image is built with security in mind, minimizing the attack surface by excluding unnecessary packages and users.
48+
49+
## Getting Started
50+
51+
To get started with this project, follow these steps:
52+
53+
1. Clone the Repository:
54+
55+
```bash
56+
git clone https://github.com/yourusername/laravel-dockerize.git
57+
cd laravel-dockerize
58+
```
59+
60+
2. Start the Development Environment:
61+
62+
```bash
63+
cd development/
64+
docker-compose up -d
65+
```
66+
67+
3. Install Laravel Dependencies:
68+
69+
```bash
70+
docker-compose exec workspace bash
71+
composer install
72+
npm install
73+
npm run dev
74+
```
75+
76+
4. Access the Application:
77+
78+
Open your browser and navigate to [http://localhost](http://localhost).
79+
80+
## Usage
81+
82+
### Access the Workspace Container:
83+
84+
```bash
85+
docker-compose exec workspace bash
86+
```
87+
88+
### Run Artisan Commands:
89+
90+
```bash
91+
docker-compose exec workspace php artisan migrate
92+
```
93+
94+
### Rebuild Containers:
95+
96+
```bash
97+
docker-compose up -d --build
98+
```
99+
100+
## Production Environment
101+
102+
### Key Features
103+
104+
- Optimized Image: The production image is slim, containing only the necessary dependencies for running a Laravel application.
105+
- Pre-Built Assets: Assets are built during the image creation process, ensuring that the production environment is ready to serve content immediately.
106+
- Security Best Practices: The image is built with security in mind, minimizing the attack surface by excluding unnecessary packages and users.
107+
108+
### Building the Production Image
109+
110+
1. Build the Image:
111+
112+
```bash
113+
docker build -f Dockerfile.prod -t laravel-app:latest .
114+
```
115+
116+
2. Run the Container:
117+
118+
```bash
119+
docker run -d -p 9000:9000 laravel-app:latest
120+
```
121+
122+
### Deploying
123+
124+
The production image can be deployed to any Docker-compatible hosting environment, such as AWS ECS, Kubernetes, or a traditional VPS.
125+
126+
## Technical Details
127+
128+
- PHP: Version 8.3 FPM is used for optimal performance in production.
129+
- Node.js: Version 18.x is used in development for building frontend assets with Vite.
130+
- MySQL/PostgreSQL: Both databases are supported, allowing flexibility depending on your application's requirements.
131+
- Redis: Integrated for caching and session management.
132+
133+
## Contributing
134+
135+
Contributions are welcome! Please follow these steps to contribute:
136+
137+
1. Fork the Repository: Click the "Fork" button at the top right of this page.
138+
2. Clone Your Fork:
139+
140+
```bash
141+
git clone https://github.com/yourusername/laravel-dockerize.git
142+
cd laravel-dockerize
143+
```
144+
145+
3. Create a Branch:
146+
147+
```bash
148+
git checkout -b feature-branch
149+
```
150+
151+
4. Make Your Changes.
152+
153+
5. Commit Your Changes:
154+
155+
```bash
156+
git commit -m "Description of changes"
157+
```
158+
159+
6. Push to Your Fork:
160+
161+
```bash
162+
git push origin feature-branch
163+
```
164+
165+
7. Create a Pull Request: Navigate to the original repository and create a new pull request.
166+
167+
## License
168+
169+
This project is licensed under the MIT License. See the LICENSE file for more details.

0 commit comments

Comments
 (0)