Skip to content

Commit ddef213

Browse files
author
Yaroslav Pohil
committed
Add Docker setup with Nginx, PHP, MySQL, and Node.js services; include README for project setup and usage instructions.
1 parent c274c6f commit ddef213

File tree

7 files changed

+235
-8
lines changed

7 files changed

+235
-8
lines changed

.env.example

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ APP_NAME=Laravel
22
APP_ENV=local
33
APP_KEY=
44
APP_DEBUG=true
5-
APP_URL=http://localhost
5+
APP_URL=http://localhost:8000
66

77
APP_LOCALE=en
88
APP_FALLBACK_LOCALE=en
@@ -20,12 +20,12 @@ LOG_STACK=single
2020
LOG_DEPRECATIONS_CHANNEL=null
2121
LOG_LEVEL=debug
2222

23-
DB_CONNECTION=sqlite
24-
# DB_HOST=127.0.0.1
25-
# DB_PORT=3306
26-
# DB_DATABASE=laravel
27-
# DB_USERNAME=root
28-
# DB_PASSWORD=
23+
DB_CONNECTION=mysql
24+
DB_HOST=mysql
25+
DB_PORT=3306
26+
DB_DATABASE=task_manager
27+
DB_USERNAME=root
28+
DB_PASSWORD=root
2929

3030
SESSION_DRIVER=database
3131
SESSION_LIFETIME=120

docker-compose.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
version: '3.8'
2+
3+
services:
4+
# Nginx Service
5+
nginx:
6+
image: nginx:alpine
7+
container_name: task_manager_nginx
8+
ports:
9+
- "8000:80"
10+
volumes:
11+
- ./:/var/www
12+
- ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf
13+
depends_on:
14+
- php
15+
networks:
16+
- task_manager_network
17+
18+
# PHP Service
19+
php:
20+
build:
21+
context: ./docker/php
22+
dockerfile: Dockerfile
23+
container_name: task_manager_php
24+
volumes:
25+
- ./:/var/www
26+
depends_on:
27+
- mysql
28+
networks:
29+
- task_manager_network
30+
31+
# MySQL Service
32+
mysql:
33+
image: mysql:8.4
34+
container_name: task_manager_mysql
35+
restart: unless-stopped
36+
environment:
37+
MYSQL_DATABASE: task_manager
38+
MYSQL_ROOT_PASSWORD: root
39+
MYSQL_PASSWORD: password
40+
MYSQL_USER: task_manager
41+
SERVICE_NAME: mysql
42+
volumes:
43+
- task_manager_mysql_data:/var/lib/mysql
44+
ports:
45+
- "3306:3306"
46+
networks:
47+
- task_manager_network
48+
49+
# Node.js Service
50+
node:
51+
build:
52+
context: ./docker/node
53+
dockerfile: Dockerfile
54+
container_name: task_manager_node
55+
volumes:
56+
- ./:/var/www
57+
working_dir: /var/www
58+
ports:
59+
- "5173:5173"
60+
environment:
61+
- VITE_APP_URL=http://localhost:8000
62+
- CHOKIDAR_USEPOLLING=true
63+
- VITE_PORT=5173
64+
networks:
65+
- task_manager_network
66+
depends_on:
67+
- php
68+
69+
networks:
70+
task_manager_network:
71+
driver: bridge
72+
73+
volumes:
74+
task_manager_mysql_data:
75+
driver: local

docker/nginx/default.conf

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
server {
2+
listen 80;
3+
index index.php index.html;
4+
error_log /var/log/nginx/error.log;
5+
access_log /var/log/nginx/access.log;
6+
root /var/www/public;
7+
8+
location / {
9+
try_files $uri $uri/ /index.php?$query_string;
10+
gzip_static on;
11+
}
12+
13+
location ~ \.php$ {
14+
try_files $uri =404;
15+
fastcgi_split_path_info ^(.+\.php)(/.+)$;
16+
fastcgi_pass php:9000;
17+
fastcgi_index index.php;
18+
include fastcgi_params;
19+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
20+
fastcgi_param PATH_INFO $fastcgi_path_info;
21+
}
22+
}

docker/node/Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM node:20.15-alpine
2+
3+
WORKDIR /var/www
4+
5+
# Make port 5173 available outside the container
6+
EXPOSE 5173
7+
8+
ENV HOST=0.0.0.0
9+
ENV PORT=5173
10+
11+
# Install dependencies and start the development server
12+
CMD ["/bin/sh", "-c", "npm install && npm run dev -- --host 0.0.0.0"]

docker/php/Dockerfile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
FROM php:8.3-fpm
2+
3+
# Set working directory
4+
WORKDIR /var/www
5+
6+
# Install dependencies
7+
RUN apt-get update && apt-get install -y \
8+
build-essential \
9+
libpng-dev \
10+
libjpeg62-turbo-dev \
11+
libfreetype6-dev \
12+
locales \
13+
zip \
14+
unzip \
15+
git \
16+
curl \
17+
libzip-dev
18+
19+
# Clear cache
20+
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
21+
22+
# Install extensions
23+
RUN docker-php-ext-install pdo_mysql zip
24+
25+
# Install composer
26+
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
27+
28+
# Add user for application
29+
RUN groupadd -g 1000 www
30+
RUN useradd -u 1000 -ms /bin/bash -g www www
31+
32+
# Change current user to www
33+
USER www
34+
35+
# Expose port 9000 and start php-fpm server
36+
EXPOSE 9000
37+
CMD ["php-fpm"]

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

readme.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Task Manager Application
2+
3+
A Laravel 12 application with Vue.js 3 for managing tasks with user authentication.
4+
5+
## Features
6+
7+
- User Authentication with Laravel Sanctum
8+
- Task Management (Create, Read, Update, Delete)
9+
- API with proper validation and authorization
10+
- Integration with Vue.js 3 frontend
11+
- Comprehensive tests for all features
12+
13+
## Requirements
14+
15+
- Docker and Docker Compose
16+
17+
## Getting Started
18+
19+
### Setup with Docker
20+
21+
1. Clone the repository
22+
```
23+
git clone https://github.com/yaroslav-pohil/clear-gate.git
24+
cd clear-gate
25+
```
26+
27+
2. Copy the environment file
28+
```
29+
cp .env.example .env
30+
```
31+
32+
3. Start the Docker containers
33+
```
34+
docker-compose up -d
35+
```
36+
37+
4. Install PHP dependencies
38+
```
39+
docker-compose exec php composer install
40+
```
41+
42+
5. Generate application key
43+
```
44+
docker-compose exec php php artisan key:generate
45+
```
46+
47+
6. Run migrations and seed data
48+
```
49+
docker-compose exec php php artisan migrate --seed
50+
```
51+
52+
### Accessing the Application
53+
54+
- Frontend: http://localhost:8000
55+
- API: http://localhost:8000/api
56+
57+
## API Documentation
58+
59+
The API is documented using a Postman collection. Import the `task_manager_api.postman_collection.json` file into Postman to explore and test the API endpoints.
60+
61+
## Testing
62+
63+
To run tests:
64+
65+
```
66+
docker-compose exec php php artisan test
67+
```
68+
69+
## Stopping the Application
70+
71+
To stop the Docker containers:
72+
73+
```
74+
docker-compose down
75+
```
76+
77+
To stop and remove volumes (this will delete your database data):
78+
79+
```
80+
docker-compose down -v
81+
```

0 commit comments

Comments
 (0)