lilast
Browse files- Dockerfile +11 -5
- src/main.ts +4 -1
Dockerfile
CHANGED
|
@@ -8,13 +8,19 @@ WORKDIR /app
|
|
| 8 |
COPY package*.json ./
|
| 9 |
|
| 10 |
# Install the project dependencies
|
| 11 |
-
RUN npm install
|
| 12 |
|
| 13 |
# Copy the rest of the project files to the working directory
|
| 14 |
COPY . .
|
| 15 |
|
| 16 |
-
#
|
| 17 |
-
|
| 18 |
|
| 19 |
-
#
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
COPY package*.json ./
|
| 9 |
|
| 10 |
# Install the project dependencies
|
| 11 |
+
RUN npm install --production
|
| 12 |
|
| 13 |
# Copy the rest of the project files to the working directory
|
| 14 |
COPY . .
|
| 15 |
|
| 16 |
+
# Build the app for production
|
| 17 |
+
RUN npm run build
|
| 18 |
|
| 19 |
+
# Expose port 7860 (Hugging Face Spaces requirement)
|
| 20 |
+
EXPOSE 7860
|
| 21 |
+
|
| 22 |
+
# Set environment variables for production mode
|
| 23 |
+
ENV NODE_ENV=production PORT=7860
|
| 24 |
+
|
| 25 |
+
# Specify the command to run your application in production mode
|
| 26 |
+
CMD ["npm", "run", "start:prod"]
|
src/main.ts
CHANGED
|
@@ -19,6 +19,9 @@ async function bootstrap() {
|
|
| 19 |
app.use(bodyParser.urlencoded({ extended: true }));
|
| 20 |
app.use(bodyParser.json());
|
| 21 |
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
| 23 |
}
|
| 24 |
bootstrap();
|
|
|
|
| 19 |
app.use(bodyParser.urlencoded({ extended: true }));
|
| 20 |
app.use(bodyParser.json());
|
| 21 |
|
| 22 |
+
// Use the PORT environment variable or default to 8080
|
| 23 |
+
const port = process.env.PORT || 7860;
|
| 24 |
+
|
| 25 |
+
await app.listen(port);
|
| 26 |
}
|
| 27 |
bootstrap();
|