修改docker
This commit is contained in:
14
Dockerfile
14
Dockerfile
@ -8,14 +8,14 @@ COPY docker/nginx/enable-php.conf /opt/docker/etc/nginx/enable-php.conf
|
|||||||
COPY docker/nginx/vhost.conf /opt/docker/etc/nginx/vhost.conf
|
COPY docker/nginx/vhost.conf /opt/docker/etc/nginx/vhost.conf
|
||||||
# 复制自定义 entrypoint 脚本
|
# 复制自定义 entrypoint 脚本
|
||||||
COPY docker/entrypoint.sh /usr/local/bin/custom-entrypoint.sh
|
COPY docker/entrypoint.sh /usr/local/bin/custom-entrypoint.sh
|
||||||
# 给脚本添加可执行权限
|
# 安装时区数据并给脚本添加可执行权限
|
||||||
RUN chmod +x /app/public/start.sh && \
|
RUN apk add --no-cache tzdata && \
|
||||||
|
chmod +x /app/public/start.sh && \
|
||||||
chmod +x /usr/local/bin/custom-entrypoint.sh
|
chmod +x /usr/local/bin/custom-entrypoint.sh
|
||||||
# 设置项目文件为只读权限(除 runtime 目录外)
|
# 设置权限:app 目录可写,内部文件只读,runtime 目录可写
|
||||||
RUN chmod -R 555 /app
|
RUN chmod 755 /app && \
|
||||||
# 设置 runtime 目录和 .env 文件位置为可写权限
|
chmod -R 555 /app/* && \
|
||||||
RUN chmod -R 755 /app/runtime && \
|
chmod -R 755 /app/runtime
|
||||||
chmod 755 /app
|
|
||||||
# 复制 crontab 配置并安装
|
# 复制 crontab 配置并安装
|
||||||
COPY docker/crontab /tmp/crontab
|
COPY docker/crontab /tmp/crontab
|
||||||
RUN cat /tmp/crontab && \
|
RUN cat /tmp/crontab && \
|
||||||
|
|||||||
@ -1,23 +1,31 @@
|
|||||||
version: '3.8'
|
version: '3.8'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
web:
|
weipan02:
|
||||||
build: .
|
container_name: weipan02
|
||||||
container_name: weipan_web
|
image: gits.boolcdn.net/weipan_server:25.10.31
|
||||||
ports:
|
|
||||||
- "8080:80"
|
|
||||||
volumes:
|
|
||||||
- runtime_data:/app/runtime
|
|
||||||
environment:
|
environment:
|
||||||
|
- SERVER_DATE_TIMEZONE=Asia/Shanghai
|
||||||
# 数据库配置(用于生成 .env 文件)
|
# 数据库配置(用于生成 .env 文件)
|
||||||
- database_hostname=10.100.100.88
|
- database_hostname=10.0.0.1
|
||||||
- database_database=0302-2
|
- database_database=0302-2
|
||||||
- database_username=0302-2
|
- database_username=0302-2
|
||||||
- database_password=0302-2
|
- database_password=0302-2
|
||||||
- database_charset=utf8mb4
|
- database_charset=utf8mb4
|
||||||
- database_hostport=65306
|
- database_hostport=3306
|
||||||
network_mode: host
|
ports:
|
||||||
restart: unless-stopped
|
- "8080:80"
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
runtime_data:
|
- /www/docker/weipan02/_runtime:/app/runtime
|
||||||
|
- /www/docker/weipan02/_upload:/app/public/upload
|
||||||
|
networks:
|
||||||
|
- docker
|
||||||
|
restart: always
|
||||||
|
deploy:
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
cpus: "0.25"
|
||||||
|
memory: 8gb
|
||||||
|
networks:
|
||||||
|
docker:
|
||||||
|
external: true
|
||||||
@ -1,6 +1,15 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
cp /usr/share/zoneinfo/${SERVER_DATE_TIMEZONE:-Asia/Shanghai} /etc/localtime
|
||||||
|
|
||||||
|
echo "${SERVER_DATE_TIMEZONE:-Asia/Shanghai}" > /etc/timezone
|
||||||
|
|
||||||
|
# 动态设置 PHP_DATE_TIMEZONE 与 SERVER_DATE_TIMEZONE 保持一致(运行时生效)
|
||||||
|
export PHP_DATE_TIMEZONE=${SERVER_DATE_TIMEZONE:-Asia/Shanghai}
|
||||||
|
|
||||||
|
date
|
||||||
|
|
||||||
# 根据环境变量生成 .env 文件
|
# 根据环境变量生成 .env 文件
|
||||||
cat > /app/.env <<EOF
|
cat > /app/.env <<EOF
|
||||||
[DATABASE]
|
[DATABASE]
|
||||||
@ -15,16 +24,5 @@ EOF
|
|||||||
echo "Generated .env file:"
|
echo "Generated .env file:"
|
||||||
cat /app/.env
|
cat /app/.env
|
||||||
|
|
||||||
apk add --no-cache tzdata
|
|
||||||
|
|
||||||
cp /usr/share/zoneinfo/${SERVER_DATE_TIMEZONE:-Asia/Shanghai} /etc/localtime
|
|
||||||
|
|
||||||
echo "${SERVER_DATE_TIMEZONE:-Asia/Shanghai}" > /etc/timezone
|
|
||||||
|
|
||||||
# 动态设置 PHP_DATE_TIMEZONE 与 SERVER_DATE_TIMEZONE 保持一致(运行时生效)
|
|
||||||
export PHP_DATE_TIMEZONE=${SERVER_DATE_TIMEZONE:-Asia/Shanghai}
|
|
||||||
|
|
||||||
date
|
|
||||||
|
|
||||||
# 执行原始镜像的入口点(webdevops 镜像使用 supervisord)
|
# 执行原始镜像的入口点(webdevops 镜像使用 supervisord)
|
||||||
exec /entrypoint supervisord
|
exec /entrypoint supervisord
|
||||||
|
|||||||
Reference in New Issue
Block a user