Skip to content

Commit 96ac997

Browse files
author
Nik
committed
initial Version
0 parents  commit 96ac997

8 files changed

Lines changed: 98 additions & 0 deletions

File tree

‎.env.example‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
PORT=3000
2+
PUBLIC_BASE_URL=https://vps.recordweb.dev/openrwp
3+
BLOB_DIR=/data/blobs

‎.github/workflows/deploy.yml‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Deploy to VPS
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Deploy via SSH
13+
uses: appleboy/ssh-action@v1.0.3
14+
with:
15+
host: ${{ secrets.VPS_HOST }}
16+
username: ${{ secrets.VPS_USER }}
17+
key: ${{ secrets.VPS_SSH_KEY }}
18+
script: |
19+
set -euo pipefail
20+
if [ ! -d /opt/openrwp/.git ]; then
21+
git clone https://github.com/recordweb/openRWP.git /opt/openrwp
22+
fi
23+
cd /opt/openrwp
24+
git fetch origin
25+
git reset --hard origin/main
26+
git clean -fd
27+
[ -f .env ] || { echo "ERROR: /opt/openrwp/.env is missing"; exit 1; }
28+
docker compose up -d --build
29+
for i in $(seq 1 15); do
30+
if docker compose exec -T openrwp wget -qO- http://localhost:3000/health; then
31+
exit 0
32+
fi
33+
sleep 2
34+
done
35+
docker compose logs --tail=50
36+
exit 1

‎.gitignore‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.env
2+
node_modules/

‎backend/.dockerignore‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
.env

‎backend/Dockerfile‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM node:24-alpine
2+
WORKDIR /app
3+
ENV NODE_ENV=production
4+
COPY package.json ./
5+
RUN npm install --omit=dev
6+
COPY . .
7+
# Blob directory owned by the unprivileged user; a new named volume inherits this.
8+
RUN mkdir -p /data/blobs && chown node:node /data/blobs
9+
USER node
10+
EXPOSE 3000
11+
CMD ["node", "server.js"]

‎backend/package.json‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "openrwp-backend",
3+
"version": "0.0.1",
4+
"private": true,
5+
"type": "module",
6+
"scripts": { "start": "node server.js" }
7+
}

‎backend/server.js‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import http from 'node:http';
2+
3+
const PORT = Number(process.env.PORT ?? 3000);
4+
5+
const server = http.createServer((req, res) => {
6+
res.setHeader('Content-Type', 'application/json');
7+
if (req.method === 'GET' && req.url === '/health') {
8+
res.writeHead(200);
9+
res.end(JSON.stringify({ status: 'ok', service: 'openrwp' }));
10+
return;
11+
}
12+
res.writeHead(404);
13+
res.end(JSON.stringify({ error: 'not-found' }));
14+
});
15+
16+
server.listen(PORT, () => console.log(`openrwp listening on ${PORT}`));

‎docker-compose.yml‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: openrwp
2+
3+
services:
4+
openrwp:
5+
build: ./backend
6+
container_name: openrwp
7+
restart: unless-stopped
8+
env_file:
9+
- .env
10+
volumes:
11+
- openrwp-blobs:/data/blobs
12+
networks:
13+
- tws-proxy
14+
15+
networks:
16+
tws-proxy:
17+
external: true
18+
name: tws-proxy
19+
20+
volumes:
21+
openrwp-blobs:

0 commit comments

Comments
 (0)