| FROM node:18-alpine AS frontend-builder |
| WORKDIR /app/web/admin-spa |
|
|
| COPY web/admin-spa/package*.json ./ |
| RUN npm ci |
|
|
| COPY web/admin-spa/ ./ |
| RUN npm run build |
|
|
|
|
| FROM node:18-alpine |
|
|
| LABEL org.opencontainers.image.title="123" |
| LABEL org.opencontainers.image.description="1234" |
| LABEL org.opencontainers.image.version="1.0.0" |
| LABEL maintainer="123@example.com" |
|
|
| WORKDIR /app |
|
|
| RUN apk add --no-cache redis curl dumb-init python3 py3-pip |
|
|
| RUN python3 -m venv /opt/venv && \ |
| . /opt/venv/bin/activate && \ |
| pip install --no-cache-dir --upgrade pip && \ |
| pip install --no-cache-dir huggingface_hub |
| ENV PATH="/opt/venv/bin:${PATH}" |
|
|
| COPY package*.json ./ |
| RUN npm ci --omit=dev && npm cache clean --force |
|
|
| COPY . . |
|
|
| COPY --from=frontend-builder /app/web/admin-spa/dist /app/web/admin-spa/dist |
|
|
| # COPY tools/hf_backup.py /app/tools/hf_backup.py |
| # COPY tools/hf-backup.sh /app/tools/hf-backup.sh |
|
|
| RUN chmod +x /app/tools/hf-backup.sh || true |
| COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh |
| RUN chmod +x /usr/local/bin/docker-entrypoint.sh |
|
|
| RUN mkdir -p /app/logs /app/data /app/temp |
|
|
| RUN if [ ! -f "/app/config/config.js" ] && [ -f "/app/config/config.example.js" ]; then \ |
| cp /app/config/config.example.js /app/config/config.js; \ |
| fi |
|
|
| ENV NODE_ENV=production |
| ENV HOST=0.0.0.0 |
| ENV PORT=7860 |
|
|
| EXPOSE 7860 |
| HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ |
| CMD sh -c 'curl -fsS "http://127.0.0.1:${PORT:-7860}/health" || exit 1' |
|
|
| ENTRYPOINT ["dumb-init", "--", "/usr/local/bin/docker-entrypoint.sh"] |
| CMD ["node", "src/app.js"] |
|
|