Dockerfile update

This commit is contained in:
2025-10-21 21:43:46 +03:00
parent 1d0ab8caee
commit d02928e307
3 changed files with 38 additions and 25 deletions

21
Dockerfile Normal file
View File

@@ -0,0 +1,21 @@
# Build client
FROM node:22-alpine AS client
WORKDIR /app/client
COPY client/package*.json ./
RUN npm ci || npm i
COPY client .
RUN npm run build
# Build server
FROM node:22-slim
RUN apt-get update && apt-get install -y ffmpeg
WORKDIR /app/server
COPY server/package*.json ./
RUN npm ci || npm i
COPY server .
# Move files to public folder
COPY --from=client /app/client/dist ./public
EXPOSE 3001
CMD ["npm", "start"]

View File

@@ -1,32 +1,11 @@
version: "3.9"
networks:
dupe_network:
driver: bridge
services:
server:
build: ./server
container_name: dupe-server
dupe:
build: .
container_name: dupe
ports:
- "3001:3001"
networks:
- dupe_network
volumes:
- ./downloads:/app/downloads
restart: unless-stopped
client:
build: ./client
container_name: dupe-client
depends_on:
- server
ports:
- "5173:5173"
networks:
- dupe_network
volumes:
- ./downloads:/app/downloads
environment:
- VITE_API=http://localhost:3001
- ./downloads:/app/server/downloads
restart: unless-stopped

View File

@@ -300,6 +300,19 @@ console.log("📂 Download path:", DOWNLOAD_DIR);
const server = app.listen(PORT, () =>
console.log(`✅ WebTorrent server ${PORT} portunda çalışıyor`)
);
// --- ✅ Client build (frontend) dosyalarını sun ---
const publicDir = path.join(__dirname, "public");
if (fs.existsSync(publicDir)) {
app.use(express.static(publicDir));
// Frontend route'larını index.html'e yönlendir
app.get("*", (req, res, next) => {
if (req.path.startsWith("/api")) return next();
res.sendFile(path.join(publicDir, "index.html"));
});
}
const wss = new WebSocketServer({ server });
wss.on("connection", (ws) => {
ws.send(JSON.stringify({ type: "progress", torrents: snapshot() }));