:gem: [Feature] Enable docker for node server
Browse files- .github/workflows/sync_to_huggingface_space.yml +2 -0
- Dockerfile +2 -10
- server.js +2 -3
.github/workflows/sync_to_huggingface_space.yml
CHANGED
@@ -1,5 +1,7 @@
|
|
1 |
name: Sync to Hugging Face hub
|
2 |
on:
|
|
|
|
|
3 |
workflow_dispatch:
|
4 |
|
5 |
jobs:
|
|
|
1 |
name: Sync to Hugging Face hub
|
2 |
on:
|
3 |
+
push:
|
4 |
+
branches: [main]
|
5 |
workflow_dispatch:
|
6 |
|
7 |
jobs:
|
Dockerfile
CHANGED
@@ -1,14 +1,6 @@
|
|
1 |
FROM node:18-slim
|
2 |
WORKDIR $HOME/app
|
3 |
-
|
4 |
-
RUN git clone https://github.com/Rob--W/cors-anywhere.git cors-anywhere
|
5 |
-
WORKDIR $HOME/app/cors-anywhere
|
6 |
RUN npm install
|
7 |
-
RUN npm install http-server -g
|
8 |
-
COPY . $HOME/app
|
9 |
-
WORKDIR $HOME/app
|
10 |
-
VOLUME /data
|
11 |
-
ENV PORT=12349
|
12 |
-
CMD node ./cors-anywhere/server.js &
|
13 |
EXPOSE 12345
|
14 |
-
CMD
|
|
|
1 |
FROM node:18-slim
|
2 |
WORKDIR $HOME/app
|
3 |
+
COPY . .
|
|
|
|
|
4 |
RUN npm install
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
EXPOSE 12345
|
6 |
+
CMD node server.js
|
server.js
CHANGED
@@ -32,12 +32,11 @@ app.post("/chat/completions", async (req, res) => {
|
|
32 |
response.data.pipe(res);
|
33 |
} catch (error) {
|
34 |
console.error(error);
|
35 |
-
|
36 |
-
res.status(500).json({ error: "Error calling OpenAI API" });
|
37 |
}
|
38 |
});
|
39 |
|
40 |
const port = 12345;
|
41 |
app.listen(port, () => {
|
42 |
-
console.log(`Server is running on http://
|
43 |
});
|
|
|
32 |
response.data.pipe(res);
|
33 |
} catch (error) {
|
34 |
console.error(error);
|
35 |
+
res.status(500).json({ error: "Failed to requests OpenAI Endpoint" });
|
|
|
36 |
}
|
37 |
});
|
38 |
|
39 |
const port = 12345;
|
40 |
app.listen(port, () => {
|
41 |
+
console.log(`Server is running on http://127.0.0.1:${port}`);
|
42 |
});
|