新增本地开发环境配置

This commit is contained in:
2025-10-18 09:14:30 +08:00
parent cbf3c44f14
commit 79641f01ee
4 changed files with 90 additions and 1 deletions

6
.gitignore vendored
View File

@@ -1 +1,5 @@
*.csv
*.csv
.idea/
.vscode/
.volumes/

3
Dockerfile Normal file
View File

@@ -0,0 +1,3 @@
FROM php:7.3-fpm-alpine
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories
RUN docker-php-ext-install pdo_mysql mysqli

49
docker-compose.yaml Normal file
View File

@@ -0,0 +1,49 @@
name: juipphp
services:
mysql:
image: mysql:8.0.21
environment:
MYSQL_ROOT_PASSWORD: 123456789
MYSQL_DATABASE: hualianyun
ports:
- "3306:3306"
command: --default-authentication-plugin=mysql_native_password
volumes:
- ./.volumes/mysql:/var/lib/mysql
php:
build:
context: .
dockerfile: Dockerfile
volumes:
- ./alipay:/var/www/html/alipay
- ./app:/var/www/html/app
- ./config:/var/www/html/config
- ./enum:/var/www/html/enum
- ./extends:/var/www/html/extends
- ./fastphp:/var/www/html/fastphp
- ./script:/var/www/html/script
- ./vendor:/var/www/html/vendor
- ./.htaccess:/var/www/html/.htaccess
- ./index.php:/var/www/html/index.php
depends_on:
- mysql
nginx:
image: nginx:alpine
volumes:
- ./nginx.conf:/etc/nginx/conf.d/app.conf
- ./alipay:/var/www/html/alipay
- ./app:/var/www/html/app
- ./config:/var/www/html/config
- ./enum:/var/www/html/enum
- ./extends:/var/www/html/extends
- ./fastphp:/var/www/html/fastphp
- ./script:/var/www/html/script
- ./vendor:/var/www/html/vendor
- ./.htaccess:/var/www/html/.htaccess
- ./index.php:/var/www/html/index.php
ports:
- 9000:9000

33
nginx.conf Normal file
View File

@@ -0,0 +1,33 @@
server {
listen 9000;
server_name _;
# CORS
add_header 'Access-Control-Allow-Origin' "$http_origin" always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always;
add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Requested-With' always;
add_header 'Access-Control-Allow-Credentials' 'true' always;
# pre-flight requests
if ($request_method = 'OPTIONS') {
return 204;
}
index index.php;
root /var/www/html;
location ~ \.php(.*)$ {
fastcgi_pass php:9000;
include fastcgi_params;
fastcgi_param PATH_INFO $1;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location / {
if (!-e $request_filename) {
rewrite ^/index.php(.*)$ /index.php?s=$1 last;
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
}
}