增加部署文件

This commit is contained in:
suguo 2025-02-14 15:31:50 +08:00
parent 096ec5485f
commit 273ba1eaa8
2 changed files with 66 additions and 0 deletions

33
Dockerfile Normal file
View File

@ -0,0 +1,33 @@
# PHP-FPM镜像
FROM php:8.2-fpm
# 安装依赖
RUN apt-get update && apt-get install -y \
git \
zip \
unzip \
libzip-dev \
libpng-dev \
libonig-dev \
libxml2-dev \
&& docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd sockets zip
# 安装Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
WORKDIR /var/www
COPY . .
RUN composer install --no-dev --optimize-autoloader
# 设置权限
RUN chown -R www-data:www-data /var/www/storage
RUN chmod -R 775 /var/www/storage
# Nginx配置
FROM nginx:alpine
COPY --from=0 /var/www /var/www
COPY .docker/nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80

33
docker-compose.yml Normal file
View File

@ -0,0 +1,33 @@
version: '3'
services:
app:
build: .
volumes:
- .:/var/www/html
environment:
- DB_HOST=mysql
- DB_PORT=3306
mysql:
image: mysql:8.0
environment:
MYSQL_ROOT_PASSWORD: example_root_password
MYSQL_DATABASE: myapp
MYSQL_USER: myapp_user
MYSQL_PASSWORD: myapp_password
volumes:
- mysql_data:/var/lib/mysql
nginx:
image: nginx:alpine
ports:
- "80:80"
volumes:
- .:/var/www/html
- ./.docker/nginx.conf:/etc/nginx/conf.d/default.conf
depends_on:
- app
volumes:
mysql_data: