|
|
|
FROM node:18-alpine AS frontend-builder |
|
|
|
WORKDIR /app |
|
|
|
|
|
COPY web/package*.json ./ |
|
|
|
|
|
RUN npm ci |
|
|
|
|
|
COPY web/ ./ |
|
|
|
|
|
RUN rm -rf api/ || true |
|
RUN rm -rf storage/ || true |
|
RUN rm -rf .git/ || true |
|
RUN rm -rf .next/ || true |
|
RUN rm -rf .local/ || true |
|
|
|
|
|
RUN npm run build |
|
|
|
|
|
FROM python:3.11-slim |
|
|
|
|
|
RUN apt-get update && apt-get install -y \ |
|
nginx \ |
|
supervisor \ |
|
curl \ |
|
&& rm -rf /var/lib/apt/lists/* |
|
|
|
|
|
RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \ |
|
apt-get install -y nodejs |
|
|
|
WORKDIR /app |
|
|
|
|
|
COPY pyproject.toml poetry.lock ./ |
|
|
|
|
|
RUN pip install --no-cache-dir --upgrade pip \ |
|
&& pip install --no-cache-dir poetry \ |
|
&& poetry config virtualenvs.create false \ |
|
&& poetry install --only=main --no-root || pip install fastapi uvicorn python-dotenv pydantic |
|
|
|
|
|
COPY src/ ./src/ |
|
COPY README.md ./ |
|
|
|
|
|
COPY --from=frontend-builder /app/.next ./web/.next |
|
COPY --from=frontend-builder /app/public ./web/public |
|
COPY --from=frontend-builder /app/package.json ./web/package.json |
|
|
|
|
|
|
|
COPY web/api/ ./web/api/ |
|
|
|
|
|
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf |
|
COPY nginx.conf /etc/nginx/nginx.conf |
|
|
|
|
|
RUN mkdir -p /var/log/supervisor /var/log/nginx /var/run \ |
|
&& chmod +x /app/src/ || true |
|
|
|
|
|
EXPOSE 7860 |
|
|
|
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \ |
|
CMD curl -f http://localhost:7860/health || exit 1 |
|
|
|
|
|
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"] |