-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
214155f
commit b037dd5
Showing
2 changed files
with
23 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,24 @@ | ||
# 使用distroless作为基础镜像 | ||
FROM gcr.io/distroless/static-debian12 | ||
# 使用 distroless base 镜像,因为它很小且为了安全没有包含不必要的程序或库 | ||
FROM gcr.io/distroless/base-debian12 | ||
|
||
# 设置工作目录 | ||
WORKDIR /public | ||
WORKDIR /app | ||
|
||
# 从构建上下文中复制静态网页内容 | ||
COPY ./dist/ . | ||
# 从构建上下文中复制 static-web-server 二进制文件 | ||
# 假设在 GitHub Actions workflow 中 static-web-server 被下载到工作目录 | ||
COPY static-web-server /usr/local/bin/static-web-server | ||
|
||
# 从构建上下文中复制static-web-server二进制文件 | ||
COPY sws /usr/local/bin/static-web-server | ||
# 从构建上下文中复制构建好的静态文件 | ||
# 假设 npm run build 生成的静态文件在 /dist 目录下 | ||
COPY dist/ /app/ | ||
|
||
# 暴露端口80 | ||
# 设置静态文件服务器的环境变量 | ||
ENV PORT=80 \ | ||
SERVER_ROOT=/app | ||
|
||
# 暴露 80 端口 | ||
EXPOSE 80 | ||
|
||
# 启动static-web-server | ||
CMD ["/usr/local/bin/static-web-server", "-p", "80", "-r", "/public"] | ||
# 当容器启动时运行 static-web-server | ||
ENTRYPOINT ["/usr/local/bin/static-web-server"] | ||
CMD ["-p", "80", "-r", "/app"] |