This commit is contained in:
编码猿
2025-09-09 09:11:29 +08:00
parent 01c6885a2b
commit 1909ff27ae
3 changed files with 90 additions and 14 deletions

View File

@@ -1,20 +1,24 @@
# 使用基础镜像(根据需要选择合适的版本)
FROM debian:bullseye-slim # 或 ubuntu:22.04
FROM node:18-bullseye-slim
# 设置非交互模式,避免安装过程中出现交互提示
ENV DEBIAN_FRONTEND=noninteractive
# 更新软件源并安装iproute2同时清理缓存减小镜像体积
# 安装iproute2
RUN apt-get update && \
apt-get install -y --no-install-recommends \
iproute2 \ # 包含ip命令的工具包
&& \
apt-get install -y --no-install-recommends iproute2 && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# 可选:设置工作目录
# 创建非root用户
RUN useradd -m appuser
USER appuser
WORKDIR /app
# 可选:添加启动命令
CMD ["bash"]
# 复制项目文件和依赖
COPY --chown=appuser:appuser package*.json ./
COPY --chown=appuser:appuser node_modules ./node_modules
COPY --chown=appuser:appuser . .
# 暴露应用端口host模式下实际使用宿主机端口
EXPOSE 9900
# 启动命令
CMD ["npm", "start"]