File size: 1,189 Bytes
39687c8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# First stage: build environment
FROM node:lts AS BUILD_IMAGE

# Update the package list and install git
RUN apt-get update && apt-get install -y git

WORKDIR /app

# Clone GitHub repository
RUN git clone https://github.com/Sunhaha520/qwen-free-api.git /app

# Install dependencies and build the project
RUN yarn install --registry https://registry.npmmirror.com/ && yarn run build

# Second stage: production environment
FROM node:lts-alpine

WORKDIR /app

# Copy the built files and required directories from the build stage
COPY --from=BUILD_IMAGE /app/configs /app/configs
COPY --from=BUILD_IMAGE /app/package.json /app/package.json
COPY --from=BUILD_IMAGE /app/dist /app/dist
COPY --from=BUILD_IMAGE /app/public /app/public
COPY --from=BUILD_IMAGE /app/node_modules /app/node_modules

# Install production dependencies
RUN yarn install --production --registry https://registry.npmmirror.com/

# Create the log directory and grant write permissions
RUN mkdir -p /app/logs && chmod 777 /app/logs

# Specify port environment variable
ENV PORT 7860

# Expose port
EXPOSE $PORT

# Specify the command to be executed when the container starts
CMD ["node", "dist/index.js", "--port", "7860"]