ColamanAI commited on
Commit
39687c8
1 Parent(s): 5c3ed65

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +40 -0
Dockerfile ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # First stage: build environment
2
+ FROM node:lts AS BUILD_IMAGE
3
+
4
+ # Update the package list and install git
5
+ RUN apt-get update && apt-get install -y git
6
+
7
+ WORKDIR /app
8
+
9
+ # Clone GitHub repository
10
+ RUN git clone https://github.com/Sunhaha520/qwen-free-api.git /app
11
+
12
+ # Install dependencies and build the project
13
+ RUN yarn install --registry https://registry.npmmirror.com/ && yarn run build
14
+
15
+ # Second stage: production environment
16
+ FROM node:lts-alpine
17
+
18
+ WORKDIR /app
19
+
20
+ # Copy the built files and required directories from the build stage
21
+ COPY --from=BUILD_IMAGE /app/configs /app/configs
22
+ COPY --from=BUILD_IMAGE /app/package.json /app/package.json
23
+ COPY --from=BUILD_IMAGE /app/dist /app/dist
24
+ COPY --from=BUILD_IMAGE /app/public /app/public
25
+ COPY --from=BUILD_IMAGE /app/node_modules /app/node_modules
26
+
27
+ # Install production dependencies
28
+ RUN yarn install --production --registry https://registry.npmmirror.com/
29
+
30
+ # Create the log directory and grant write permissions
31
+ RUN mkdir -p /app/logs && chmod 777 /app/logs
32
+
33
+ # Specify port environment variable
34
+ ENV PORT 7860
35
+
36
+ # Expose port
37
+ EXPOSE $PORT
38
+
39
+ # Specify the command to be executed when the container starts
40
+ CMD ["node", "dist/index.js", "--port", "7860"]