Spaces:
Running
Running
FROM node:20-bullseye-slim AS base | |
ENV PNPM_HOME="/pnpm" | |
ENV PATH="$PNPM_HOME:$PATH" | |
FROM base AS build | |
WORKDIR /app | |
COPY . /app | |
RUN corepack enable | |
RUN apt-get update && \ | |
apt-get install -y python3 build-essential | |
RUN --mount=type=cache,id=pnpm,target=/pnpm/store \ | |
pnpm install --prod --frozen-lockfile | |
RUN pnpm deploy --filter=@imput/cobalt-api --prod /prod/api | |
FROM base AS api | |
WORKDIR /app | |
ARG API_URL="https://fuliai-cobalt.hf.space/" | |
ARG API_PORT=7860 | |
ENV API_URL=${API_URL} | |
ENV API_PORT=${API_PORT} | |
COPY --from=build /prod/api /app | |
COPY --from=build /app/.git /app/.git | |
# 复制.env.example并重命名为.env | |
COPY .env.example .env | |
RUN if [ -n "$API_URL" ]; then \ | |
sed -i "s|^API_URL=.*|API_URL=${API_URL}|" .env; \ | |
fi && \ | |
if [ -n "$API_PORT" ]; then \ | |
sed -i "s|^API_PORT=.*|API_PORT=${API_PORT}|" .env; \ | |
fi | |
# 输出.env文件内容以进行调试 | |
RUN cat .env | |
CMD [ "node", "src/cobalt" ] |