Vexflow2 / Dockerfile
isididiidid's picture
Update Dockerfile
ffb40ca verified
# Step 1: Base Image
FROM node:20-slim
# Step 2: Set Working Directory
WORKDIR /app
# --- 创建一个专门用于运行的用户 ---
RUN useradd --create-home --shell /bin/bash appuser
USER appuser
WORKDIR /home/appuser/app
# Step 3: Copy package files and install dependencies
COPY --chown=appuser:appuser package*.json ./
RUN npm ci
# Step 4: Install Playwright's system dependencies
USER root
RUN npx playwright install-deps
USER appuser
# Step 5: Install Playwright browsers
RUN npx playwright install
# Step 6: Copy the rest of the application code
COPY --chown=appuser:appuser . .
# Step 7: ***【简化权限设置】***
# 准备可写的代理目录
USER root
# (1) 处理代理二进制文件
RUN mkdir -p /tmp/proxy && cp src/proxy/chrome_proxy_server_linux_amd64 /tmp/proxy/
RUN chmod +x /tmp/proxy/chrome_proxy_server_linux_amd64
# (2) ***【移除】*** 不再需要处理日志文件权限
# RUN mkdir -p /tmp/logs
# RUN touch /tmp/logs/proxy_server.log
# RUN chown -R appuser:appuser /tmp/logs
# 切换回 appuser
USER appuser
# Step 8: Expose the application port
EXPOSE 7860
# Step 9: Set production environment
ENV NODE_ENV=production
# Step 10: Define the command to run the application
CMD ["node", "src/lightweight-client-express.js"]