Dockerfile update
This commit is contained in:
21
Dockerfile
Normal file
21
Dockerfile
Normal 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"]
|
||||||
@@ -1,32 +1,11 @@
|
|||||||
version: "3.9"
|
version: "3.9"
|
||||||
|
|
||||||
networks:
|
|
||||||
dupe_network:
|
|
||||||
driver: bridge
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
server:
|
dupe:
|
||||||
build: ./server
|
build: .
|
||||||
container_name: dupe-server
|
container_name: dupe
|
||||||
ports:
|
ports:
|
||||||
- "3001:3001"
|
- "3001:3001"
|
||||||
networks:
|
|
||||||
- dupe_network
|
|
||||||
volumes:
|
volumes:
|
||||||
- ./downloads:/app/downloads
|
- ./downloads:/app/server/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
|
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|||||||
@@ -300,6 +300,19 @@ console.log("📂 Download path:", DOWNLOAD_DIR);
|
|||||||
const server = app.listen(PORT, () =>
|
const server = app.listen(PORT, () =>
|
||||||
console.log(`✅ WebTorrent server ${PORT} portunda çalışıyor`)
|
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 });
|
const wss = new WebSocketServer({ server });
|
||||||
wss.on("connection", (ws) => {
|
wss.on("connection", (ws) => {
|
||||||
ws.send(JSON.stringify({ type: "progress", torrents: snapshot() }));
|
ws.send(JSON.stringify({ type: "progress", torrents: snapshot() }));
|
||||||
|
|||||||
Reference in New Issue
Block a user