temp: 暂存更新
This commit is contained in:
24
docker/Dockerfile
Normal file
24
docker/Dockerfile
Normal file
@@ -0,0 +1,24 @@
|
||||
# Use the official Nginx image based on Alpine
|
||||
FROM nginx:alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy the contents of the dist directory to the Nginx html directory
|
||||
COPY dist/ /default-app/
|
||||
|
||||
# 删除默认的defult.conf
|
||||
RUN rm /etc/nginx/conf.d/default.conf
|
||||
|
||||
COPY default.conf /etc/nginx/conf.d/default.conf
|
||||
|
||||
COPY app-init.sh /app-init.sh
|
||||
RUN chmod +x /app-init.sh
|
||||
|
||||
# Expose port 80
|
||||
EXPOSE 80
|
||||
|
||||
# 使用启动脚本作为 ENTRYPOINT
|
||||
ENTRYPOINT ["/app-init.sh"]
|
||||
|
||||
# Start Nginx
|
||||
# CMD ["nginx", "-g", "daemon off;"]
|
||||
17
docker/app-init.sh
Normal file
17
docker/app-init.sh
Normal file
@@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
|
||||
# 宿主机挂载路径
|
||||
TARGET_DIR="/app"
|
||||
|
||||
# 检查目录是否为空
|
||||
if [ -z "$(ls -A $TARGET_DIR)" ]; then
|
||||
echo "Directory is empty. Copying default content..."
|
||||
cp -r /default-app/* $TARGET_DIR/
|
||||
else
|
||||
echo "Directory is not empty. Skipping copy."
|
||||
fi
|
||||
|
||||
# 启动应用或保持容器运行
|
||||
# exec "$@"
|
||||
|
||||
nginx -g "daemon off;"
|
||||
9
docker/default.conf
Normal file
9
docker/default.conf
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
root /app;
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user