mirror of
https://github.com/tiennm99/composes.git
synced 2026-10-11 03:13:16 +00:00
feat: init
This commit is contained in:
1 parent
4148e42d36
commit
6481a83d2f
5 files changed
+301
No files matched your search
@@ -0,0 +1,42 @@
|
||||
FROM php:8.3-fpm
|
||||
|
||||
# Install system dependencies
|
||||
RUN apt-get update && apt-get install -y \
|
||||
git \
|
||||
curl \
|
||||
libpng-dev \
|
||||
libonig-dev \
|
||||
libxml2-dev \
|
||||
libzip-dev \
|
||||
zip \
|
||||
unzip \
|
||||
default-mysql-client
|
||||
|
||||
# Clear cache
|
||||
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install PHP extensions
|
||||
RUN docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd zip xml
|
||||
|
||||
# Get latest Composer
|
||||
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /var/www/html
|
||||
|
||||
# Create tastyigniter project (when container is first built)
|
||||
RUN composer create-project tastyigniter/tastyigniter:^v4.0 /var/www/html --prefer-dist --no-interaction --no-progress
|
||||
|
||||
# Set file permissions
|
||||
RUN chown -R www-data:www-data /var/www/html
|
||||
RUN chmod -R 755 /var/www/html/storage
|
||||
|
||||
# Copy custom entrypoint
|
||||
COPY docker/entrypoint.sh /usr/local/bin/entrypoint.sh
|
||||
RUN chmod +x /usr/local/bin/entrypoint.sh
|
||||
|
||||
# Entrypoint script
|
||||
ENTRYPOINT ["entrypoint.sh"]
|
||||
|
||||
# Start PHP-FPM server
|
||||
CMD ["php-fpm"]
|
||||
@@ -0,0 +1,91 @@
|
||||
# TastyIgniter Docker Setup
|
||||
|
||||
This repository contains Docker configuration files to quickly set up a TastyIgniter v4.0+ environment. The setup includes:
|
||||
|
||||
- PHP 8.3 with all required extensions
|
||||
- MySQL 8 database
|
||||
- Nginx web server
|
||||
- Automated installation process
|
||||
- Properly configured scheduler and queue workers
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Docker and Docker Compose installed on your system
|
||||
- Basic understanding of Docker concepts
|
||||
|
||||
## Directory Structure
|
||||
|
||||
```
|
||||
tastyigniter-docker/
|
||||
├── docker/
|
||||
│ ├── entrypoint.sh
|
||||
│ └── nginx/
|
||||
│ └── default.conf
|
||||
├── docker-compose.yml
|
||||
├── Dockerfile
|
||||
└── README.md
|
||||
```
|
||||
|
||||
## Setup Instructions
|
||||
|
||||
1. Create the directory structure as shown above:
|
||||
|
||||
```bash
|
||||
mkdir -p tastyigniter-docker/docker/nginx
|
||||
```
|
||||
|
||||
2. Copy all the configuration files into their respective directories.
|
||||
|
||||
3. Start the Docker environment:
|
||||
|
||||
```bash
|
||||
cd tastyigniter-docker
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
4. The setup will:
|
||||
- Create a new TastyIgniter project
|
||||
- Set up the database connection
|
||||
- Run the non-interactive installation
|
||||
- Configure the proper permissions
|
||||
- Set up scheduled tasks and queue processing
|
||||
|
||||
5. Access TastyIgniter:
|
||||
- Frontend: http://localhost
|
||||
- Admin panel: http://localhost/admin
|
||||
- Default admin credentials:
|
||||
- Username: admin
|
||||
- Email: admin@example.com
|
||||
- Password: admin123
|
||||
|
||||
## Configuration Options
|
||||
|
||||
You can customize the installation by modifying the environment variables in the `docker-compose.yml` file:
|
||||
|
||||
- `APP_URL`: Your application URL
|
||||
- `DB_DATABASE`, `DB_USERNAME`, `DB_PASSWORD`: Database connection details
|
||||
- `ADMIN_USER`, `ADMIN_EMAIL`, `ADMIN_PASSWORD`: Administrator account details
|
||||
|
||||
## Persistent Storage
|
||||
|
||||
The setup uses Docker volumes for:
|
||||
- MySQL data: Stored in the `dbdata` volume
|
||||
- TastyIgniter storage: Mapped to the `./storage` directory on your host
|
||||
|
||||
## Production Deployment
|
||||
|
||||
Before deploying to production, make sure to:
|
||||
|
||||
1. Change all default passwords
|
||||
2. Set `APP_DEBUG=false`
|
||||
3. Generate a unique `APP_KEY`
|
||||
4. Configure proper SSL/TLS in the Nginx configuration for HTTPS
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
If you encounter issues:
|
||||
|
||||
1. Check the logs: `docker-compose logs -f app`
|
||||
2. Verify database connectivity: `docker-compose exec app php artisan db:monitor`
|
||||
3. Check container status: `docker-compose ps`
|
||||
4. Ensure proper permissions on the storage directory
|
||||
@@ -0,0 +1,101 @@
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
app:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
container_name: tastyigniter-app
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- APP_NAME=TastyIgniter
|
||||
- APP_ENV=production
|
||||
- APP_KEY=
|
||||
- APP_DEBUG=false
|
||||
- APP_URL=http://localhost
|
||||
|
||||
# Database configuration
|
||||
- DB_CONNECTION=mysql
|
||||
- DB_HOST=db
|
||||
- DB_PORT=3306
|
||||
- DB_DATABASE=tastyigniter
|
||||
- DB_USERNAME=tastyigniter
|
||||
- DB_PASSWORD=secret_password
|
||||
|
||||
# Admin account
|
||||
- ADMIN_USER=admin
|
||||
- ADMIN_EMAIL=admin@example.com
|
||||
- ADMIN_PASSWORD=admin123
|
||||
|
||||
# Scheduler and Queue
|
||||
- QUEUE_CONNECTION=database
|
||||
volumes:
|
||||
- ./:/var/www/html
|
||||
- ./storage:/var/www/html/storage
|
||||
depends_on:
|
||||
- db
|
||||
networks:
|
||||
- tastyigniter-network
|
||||
|
||||
nginx:
|
||||
image: nginx:alpine
|
||||
container_name: tastyigniter-nginx
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "80:80"
|
||||
volumes:
|
||||
- ./:/var/www/html
|
||||
- ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf
|
||||
depends_on:
|
||||
- app
|
||||
networks:
|
||||
- tastyigniter-network
|
||||
|
||||
db:
|
||||
image: mysql:8
|
||||
container_name: tastyigniter-db
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- MYSQL_DATABASE=tastyigniter
|
||||
- MYSQL_USER=tastyigniter
|
||||
- MYSQL_PASSWORD=secret_password
|
||||
- MYSQL_ROOT_PASSWORD=root_password
|
||||
volumes:
|
||||
- dbdata:/var/lib/mysql
|
||||
networks:
|
||||
- tastyigniter-network
|
||||
|
||||
cron:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
container_name: tastyigniter-cron
|
||||
restart: unless-stopped
|
||||
command: bash -c "while true; do php /var/www/html/artisan schedule:run --verbose --no-interaction; sleep 60; done"
|
||||
volumes:
|
||||
- ./:/var/www/html
|
||||
depends_on:
|
||||
- app
|
||||
networks:
|
||||
- tastyigniter-network
|
||||
|
||||
queue:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
container_name: tastyigniter-queue
|
||||
restart: unless-stopped
|
||||
command: php /var/www/html/artisan queue:work
|
||||
volumes:
|
||||
- ./:/var/www/html
|
||||
depends_on:
|
||||
- app
|
||||
networks:
|
||||
- tastyigniter-network
|
||||
|
||||
volumes:
|
||||
dbdata:
|
||||
|
||||
networks:
|
||||
tastyigniter-network:
|
||||
driver: bridge
|
||||
@@ -0,0 +1,33 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Generate app key if not set
|
||||
if [ -z "$APP_KEY" ]; then
|
||||
php artisan key:generate
|
||||
fi
|
||||
|
||||
# Wait for database to be ready
|
||||
echo "Waiting for database to be ready..."
|
||||
while ! mysql -h "$DB_HOST" -u "$DB_USERNAME" -p"$DB_PASSWORD" -e "SELECT 1" >/dev/null 2>&1; do
|
||||
sleep 1
|
||||
done
|
||||
echo "Database connection established"
|
||||
|
||||
# Run TastyIgniter installer in non-interactive mode
|
||||
if [ ! -f .env ] || ! grep -q "IGNITER_INSTALLED=true" .env; then
|
||||
echo "Installing TastyIgniter..."
|
||||
php artisan igniter:install --no-interaction
|
||||
|
||||
# Mark as installed in .env
|
||||
echo "IGNITER_INSTALLED=true" >> .env
|
||||
|
||||
echo "TastyIgniter installed successfully"
|
||||
else
|
||||
echo "TastyIgniter already installed"
|
||||
fi
|
||||
|
||||
# Set permissions again to ensure proper access
|
||||
chown -R www-data:www-data /var/www/html
|
||||
chmod -R 755 /var/www/html/storage
|
||||
|
||||
exec "$@"
|
||||
@@ -0,0 +1,34 @@
|
||||
server {
|
||||
listen 80;
|
||||
index index.php index.html;
|
||||
server_name localhost;
|
||||
root /var/www/html/public;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.php?$query_string;
|
||||
}
|
||||
|
||||
location ~ \.php$ {
|
||||
try_files $uri =404;
|
||||
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
||||
fastcgi_pass app:9000;
|
||||
fastcgi_index index.php;
|
||||
include fastcgi_params;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||
}
|
||||
|
||||
location ~ /\.ht {
|
||||
deny all;
|
||||
}
|
||||
|
||||
location ~ /\.(?!well-known).* {
|
||||
deny all;
|
||||
}
|
||||
|
||||
gzip on;
|
||||
gzip_proxied expired no-cache no-store private auth;
|
||||
gzip_types text/plain text/css application/x-javascript application/json application/javascript image/x-icon image/png image/gif image/jpeg image/svg+xml;
|
||||
|
||||
client_max_body_size 20M;
|
||||
}
|
||||
Reference in new issue
Block a user