File size: 944 Bytes
cbbefdc
27bd649
 
5bab120
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5391861
 
 
 
 
 
 
 
 
 
 
 
 
 
5bab120
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
ARG API_URL="https://fuliai-cobalt.hf.space/"
ARG API_PORT=7860

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

COPY --from=build /prod/api /app
COPY --from=build /app/.git /app/.git

# 复制.env.example并重命名为.env
COPY .env.example .env

# 如果ARG有值,则替换.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" ]