poprawki do deployu
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
out/
|
||||||
|
pictures/
|
||||||
@@ -4,6 +4,7 @@ import path from "path";
|
|||||||
|
|
||||||
export const REMOTE_DIR = "/";
|
export const REMOTE_DIR = "/";
|
||||||
export const LOCAL_DIR = path.resolve("./downloads");
|
export const LOCAL_DIR = path.resolve("./downloads");
|
||||||
|
export const OUT_DIR = path.resolve("./out");
|
||||||
|
|
||||||
export async function downloadMissing(remoteDir: string = REMOTE_DIR) {
|
export async function downloadMissing(remoteDir: string = REMOTE_DIR) {
|
||||||
await fs.mkdir(LOCAL_DIR, { recursive: true })
|
await fs.mkdir(LOCAL_DIR, { recursive: true })
|
||||||
|
|||||||
@@ -1,14 +1,16 @@
|
|||||||
// src/routes/auth.ts
|
// src/routes/auth.ts
|
||||||
import { Router } from "express";
|
import { Router } from "express";
|
||||||
import { downloadMissing, LOCAL_DIR } from "../lib/nextcloud";
|
import { downloadMissing, LOCAL_DIR, OUT_DIR } from "../lib/nextcloud";
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import { encodeFrames } from "../lib/crateClip";
|
import { encodeFrames } from "../lib/crateClip";
|
||||||
import fs from "node:fs"
|
import fs from "node:fs"
|
||||||
|
|
||||||
const router = Router();
|
const router = Router();
|
||||||
|
|
||||||
|
export const out_vid_path = `${OUT_DIR}/out.mp4`
|
||||||
|
|
||||||
router.get("/video", async (req, res) => {
|
router.get("/video", async (req, res) => {
|
||||||
const videoPath = path.resolve("./out.mp4");
|
const videoPath = path.resolve(out_vid_path);
|
||||||
const stat = fs.statSync(videoPath);
|
const stat = fs.statSync(videoPath);
|
||||||
|
|
||||||
// Simple ETag based on file size + modification time
|
// Simple ETag based on file size + modification time
|
||||||
@@ -25,13 +27,15 @@ router.get("/video", async (req, res) => {
|
|||||||
|
|
||||||
router.post("/createclip", async (req, res) => {
|
router.post("/createclip", async (req, res) => {
|
||||||
try {
|
try {
|
||||||
|
await fs.mkdirSync(OUT_DIR, { recursive: true })
|
||||||
await encodeFrames({
|
await encodeFrames({
|
||||||
inputPattern: `${LOCAL_DIR}/*.jpg`,
|
inputPattern: `${LOCAL_DIR}/*.jpg`,
|
||||||
output: path.resolve("./out.mp4"),
|
output: out_vid_path,
|
||||||
fps: 8,
|
fps: 8,
|
||||||
});
|
});
|
||||||
res.status(200).end();
|
res.status(200).end();
|
||||||
} catch {
|
} catch (e) {
|
||||||
|
console.log(e)
|
||||||
res.status(501).end();
|
res.status(501).end();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ dotenv.config();
|
|||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
app.use(cors({
|
app.use(cors({
|
||||||
origin: "http://localhost:5173",
|
origin: "https://papryk.com",
|
||||||
methods: ["GET", "POST"],
|
methods: ["GET", "POST"],
|
||||||
credentials: true
|
credentials: true
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -1,28 +1,38 @@
|
|||||||
services:
|
services:
|
||||||
backend:
|
papryk-com-backend:
|
||||||
build: ./back
|
build: ./back
|
||||||
container_name: papryk-backend
|
container_name: papryk-backend
|
||||||
expose:
|
expose:
|
||||||
- "3000"
|
- "3000"
|
||||||
environment:
|
environment:
|
||||||
- NODE_ENV=development
|
- NODE_ENV=development
|
||||||
|
volumes:
|
||||||
|
- ./pictures:/app/downloads
|
||||||
|
- ./out:/app/out
|
||||||
|
|
||||||
frontend:
|
|
||||||
|
papryk-com-frontend:
|
||||||
build:
|
build:
|
||||||
context: ./front
|
context: ./front
|
||||||
args:
|
args:
|
||||||
VITE_API_URL: "http://localhost/api"
|
VITE_API_URL: "https://papryk.com/api"
|
||||||
container_name: papryk-frontend
|
container_name: papryk-frontend
|
||||||
expose:
|
expose:
|
||||||
- "5173"
|
- "5173"
|
||||||
|
|
||||||
nginx:
|
papryk-com-nginx:
|
||||||
image: nginx:alpine
|
image: nginx:alpine
|
||||||
container_name: papryk-nginx
|
container_name: papryk-nginx
|
||||||
ports:
|
# ports:
|
||||||
- "80:80"
|
# - "80:80"
|
||||||
volumes:
|
volumes:
|
||||||
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
|
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
|
||||||
depends_on:
|
depends_on:
|
||||||
- frontend
|
- papryk-com-frontend
|
||||||
- backend
|
- papryk-com-backend
|
||||||
|
networks:
|
||||||
|
- proxy-net
|
||||||
|
|
||||||
|
networks:
|
||||||
|
proxy-net:
|
||||||
|
external: true
|
||||||
|
|||||||
@@ -1,9 +1,29 @@
|
|||||||
FROM oven/bun:latest
|
# FROM oven/bun:latest
|
||||||
|
#
|
||||||
|
# WORKDIR /app
|
||||||
|
#
|
||||||
|
# COPY package.json bun.lockb* ./
|
||||||
|
# RUN bun install
|
||||||
|
#
|
||||||
|
# COPY . .
|
||||||
|
#
|
||||||
|
# ARG VITE_API_URL
|
||||||
|
# ENV VITE_API_URL=$VITE_API_URL
|
||||||
|
#
|
||||||
|
# RUN rm -f .env .env.*
|
||||||
|
#
|
||||||
|
# RUN bun run build --mode production
|
||||||
|
#
|
||||||
|
# EXPOSE 5173
|
||||||
|
#
|
||||||
|
# CMD ["bun", "run", "preview", "--", "--host", "--port", "5173"]
|
||||||
|
# Build stage
|
||||||
|
FROM oven/bun:latest AS builder
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY package.json bun.lockb* ./
|
COPY package.json bun.lockb* ./
|
||||||
RUN bun install
|
RUN bun install --frozen-lockfile
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
@@ -11,9 +31,14 @@ ARG VITE_API_URL
|
|||||||
ENV VITE_API_URL=$VITE_API_URL
|
ENV VITE_API_URL=$VITE_API_URL
|
||||||
|
|
||||||
RUN rm -f .env .env.*
|
RUN rm -f .env .env.*
|
||||||
|
|
||||||
RUN bun run build --mode production
|
RUN bun run build --mode production
|
||||||
|
|
||||||
EXPOSE 5173
|
|
||||||
|
|
||||||
CMD ["bun", "run", "preview", "--", "--host", "--port", "5173"]
|
# Production stage
|
||||||
|
FROM nginx:alpine
|
||||||
|
|
||||||
|
COPY --from=builder /app/dist /usr/share/nginx/html
|
||||||
|
|
||||||
|
EXPOSE 80
|
||||||
|
|
||||||
|
CMD ["nginx", "-g", "daemon off;"]
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ server {
|
|||||||
# FRONTEND (Vite)
|
# FRONTEND (Vite)
|
||||||
# =========================
|
# =========================
|
||||||
location / {
|
location / {
|
||||||
proxy_pass http://frontend:5173;
|
# proxy_pass http://papryk-com-frontend:5173;
|
||||||
|
proxy_pass http://papryk-com-frontend:80;
|
||||||
proxy_http_version 1.1;
|
proxy_http_version 1.1;
|
||||||
|
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
@@ -19,7 +20,7 @@ server {
|
|||||||
location /api/ {
|
location /api/ {
|
||||||
rewrite ^/api/(.*)$ /$1 break;
|
rewrite ^/api/(.*)$ /$1 break;
|
||||||
|
|
||||||
proxy_pass http://backend:3000;
|
proxy_pass http://papryk-com-backend:3000;
|
||||||
proxy_http_version 1.1;
|
proxy_http_version 1.1;
|
||||||
|
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
|
|||||||
Reference in New Issue
Block a user