Spaces:
Paused
Paused
| FROM node:lts-alpine3.19 | |
| # Arguments | |
| ARG APP_HOME=/home/node/app | |
| # Install system dependencies | |
| RUN apk add gcompat tini git | |
| # Create app directory | |
| WORKDIR ${APP_HOME} | |
| # Set NODE_ENV to production | |
| ENV NODE_ENV=production | |
| # Install app dependencies | |
| COPY package*.json post-install.js ./ | |
| RUN \ | |
| echo "*** Install npm packages ***" && \ | |
| npm i --no-audit --no-fund --loglevel=error --no-progress --omit=dev && npm cache clean --force | |
| # Bundle app source | |
| COPY . ./ | |
| # 保留用户自定义的config.yaml,只在不存在时创建 | |
| RUN \ | |
| rm -f "config.yaml" || true && \ | |
| ln -s "./config/config.yaml" "config.yaml" || true && \ | |
| mkdir "config" || true; \ | |
| fi && \ | |
| chmod 777 "config" && \ | |
| chmod 777 ./ | |
| # Pre-compile public libraries | |
| RUN \ | |
| echo "*** Run Webpack ***" && \ | |
| node "./docker/build-lib.js" | |
| # Cleanup unnecessary files | |
| RUN \ | |
| echo "*** Cleanup ***" && \ | |
| mv "./docker/docker-entrypoint.sh" "./" && \ | |
| rm -rf "./docker" && \ | |
| echo "*** Make docker-entrypoint.sh executable ***" && \ | |
| chmod +x "./docker-entrypoint.sh" && \ | |
| echo "*** Convert line endings to Unix format ***" && \ | |
| dos2unix "./docker-entrypoint.sh" | |
| # Fix extension repos permissions | |
| RUN git config --global --add safe.directory "*" | |
| # Ensure proper file permissions | |
| RUN chown -R node:node ${APP_HOME} && \ | |
| chmod -R 755 ${APP_HOME} | |
| EXPOSE 8000 | |
| # Ensure proper handling of kernel signals | |
| ENTRYPOINT ["tini", "--", "./docker-entrypoint.sh"] | |