add fronted docker
This commit is contained in:
1 parent
5cd5ec5649
commit
a18f7a5c8b
14 files changed
+124
-24
No files matched your search
@@ -8,7 +8,6 @@ FROM node:22-slim AS build
|
||||
WORKDIR /app
|
||||
COPY --from=deps /app/node_modules ./node_modules
|
||||
COPY . .
|
||||
# 빌드 시점엔 API가 없어도 되도록 rewrite 대상은 런타임 환경변수로 받는다
|
||||
RUN npm run build
|
||||
|
||||
FROM node:22-slim AS run
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
"use client";
|
||||
|
||||
import DisabledNotice from "@/components/disabled-notice";
|
||||
import { FEATURES } from "@/lib/features";
|
||||
import { use, useEffect, useState } from "react";
|
||||
import Link from "next/link";
|
||||
import MetadataCard from "@/components/metadata-card";
|
||||
import { InternalOnlyWarning, LicenseBadge } from "@/components/license-badge";
|
||||
import { apiFetch, archiveKind, type ArchiveEntry } from "@/lib/api";
|
||||
|
||||
export default function ArchiveDetailPage({ params }: { params: Promise<{ slug: string }> }) {
|
||||
function ArchiveDetailPageInner({ params }: { params: Promise<{ slug: string }> }) {
|
||||
const { slug } = use(params);
|
||||
const [entry, setEntry] = useState<ArchiveEntry | null>(null);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
@@ -86,3 +88,9 @@ export default function ArchiveDetailPage({ params }: { params: Promise<{ slug:
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
export default function ArchiveDetailPage(props: Parameters<typeof ArchiveDetailPageInner>[0]) {
|
||||
if (!FEATURES.archive) return <DisabledNotice title="아카이브" backHref="/" />;
|
||||
return <ArchiveDetailPageInner {...props} />;
|
||||
}
|
||||
@@ -1,10 +1,12 @@
|
||||
"use client";
|
||||
|
||||
import DisabledNotice from "@/components/disabled-notice";
|
||||
import { FEATURES } from "@/lib/features";
|
||||
import { useEffect, useState } from "react";
|
||||
import Link from "next/link";
|
||||
import { apiFetch, archiveKind, type ArchiveEntry } from "@/lib/api";
|
||||
|
||||
export default function ArchivePage() {
|
||||
function ArchivePageInner() {
|
||||
const [entries, setEntries] = useState<ArchiveEntry[] | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -50,3 +52,9 @@ export default function ArchivePage() {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
export default function ArchivePage() {
|
||||
if (!FEATURES.archive) return <DisabledNotice title="아카이브" backHref="/" />;
|
||||
return <ArchivePageInner />;
|
||||
}
|
||||
@@ -2,6 +2,7 @@ import type { Metadata } from "next";
|
||||
import Link from "next/link";
|
||||
import Ado2Logo from "@/components/ado2-logo";
|
||||
import NavLink from "@/components/nav-link";
|
||||
import { FEATURES } from "@/lib/features";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "ADO2 무빙포스터",
|
||||
@@ -20,8 +21,8 @@ export default function Ado2Layout({ children }: { children: React.ReactNode })
|
||||
</div>
|
||||
<nav className="sidebar-menu">
|
||||
<NavLink href="/" icon="video">무빙포스터</NavLink>
|
||||
<NavLink href="/studio" icon="image">포스터 스타일링</NavLink>
|
||||
<NavLink href="/archive" icon="folder">아카이브</NavLink>
|
||||
{FEATURES.styling && <NavLink href="/studio" icon="image">포스터 스타일링</NavLink>}
|
||||
{FEATURES.archive && <NavLink href="/archive" icon="folder">아카이브</NavLink>}
|
||||
</nav>
|
||||
<div className="sidebar-foot">무빙포스터 · 내부 빌드</div>
|
||||
</aside>
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import DisabledNotice from "@/components/disabled-notice";
|
||||
import { FEATURES } from "@/lib/features";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import PosterDropzone from "@/components/poster-dropzone";
|
||||
import {
|
||||
@@ -12,7 +14,7 @@ interface UploadHint { enabled: boolean; min_long_edge: number }
|
||||
|
||||
const USER_CATEGORY = "user";
|
||||
|
||||
export default function StudioPage() {
|
||||
function StudioPageInner() {
|
||||
const [templates, setTemplates] = useState<F2Template[]>([]);
|
||||
const [categories, setCategories] = useState<F2Category[]>([]);
|
||||
const [formats, setFormats] = useState<F2Format[]>([]);
|
||||
@@ -301,3 +303,9 @@ export default function StudioPage() {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
export default function StudioPage() {
|
||||
if (!FEATURES.styling) return <DisabledNotice title="포스터 스타일링" backHref="/" />;
|
||||
return <StudioPageInner />;
|
||||
}
|
||||
@@ -2,6 +2,7 @@ import type { Metadata } from "next";
|
||||
import Link from "next/link";
|
||||
import Ado2Logo from "@/components/ado2-logo";
|
||||
import NavLink from "@/components/nav-link";
|
||||
import { FEATURES } from "@/lib/features";
|
||||
|
||||
/* Playreel 자체 셸.
|
||||
* ADO2 BI 는 넣는다 — Playreel 은 별도 URL 로 나가지만 ADO2 제품이고,
|
||||
@@ -32,7 +33,7 @@ export default function PlayreelLayout({ children }: { children: React.ReactNode
|
||||
</div>
|
||||
<nav className="sidebar-menu">
|
||||
<NavLink href="/playreel" icon="video">예고편 만들기</NavLink>
|
||||
<NavLink href="/playreel/archive" icon="folder">아카이브</NavLink>
|
||||
{FEATURES.archive && <NavLink href="/playreel/archive" icon="folder">아카이브</NavLink>}
|
||||
</nav>
|
||||
<div className="sidebar-foot">Playreel · an ADO2 product · 내부 빌드</div>
|
||||
</aside>
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import DisabledNotice from "@/components/disabled-notice";
|
||||
import { FEATURES } from "@/lib/features";
|
||||
import { useEffect, useState } from "react";
|
||||
import Link from "next/link";
|
||||
import { apiFetch } from "@/lib/api";
|
||||
@@ -21,7 +23,7 @@ type Entry = {
|
||||
created_at?: number;
|
||||
};
|
||||
|
||||
export default function PlayreelArchivePage() {
|
||||
function PlayreelArchivePageInner() {
|
||||
const [items, setItems] = useState<Entry[] | null>(null);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
@@ -78,3 +80,9 @@ export default function PlayreelArchivePage() {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
export default function PlayreelArchivePage() {
|
||||
if (!FEATURES.archive) return <DisabledNotice title="아카이브" backHref="/playreel" />;
|
||||
return <PlayreelArchivePageInner />;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import Link from "next/link";
|
||||
|
||||
/** 꺼둔 화면의 자리. lib/features.ts 에서 켠다. */
|
||||
export default function DisabledNotice({ title, backHref = "/" }: {
|
||||
title: string; backHref?: string;
|
||||
}) {
|
||||
return (
|
||||
<div>
|
||||
<Link href={backHref} className="btn-back">‹ 뒤로가기</Link>
|
||||
<h1 className="page-title">{title}</h1>
|
||||
<p className="page-subtitle">이 화면은 아직 열지 않았습니다.</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* 화면 켜고 끄기.
|
||||
* 백엔드에 대응하는 API가 없는 화면을 여기서 끈다 — 페이지 코드는 그대로 두고
|
||||
* 네비게이션에서 감추고 본문 대신 안내를 띄운다.
|
||||
*
|
||||
* styling /studio — /api/f2 없음
|
||||
* archive /archive · /playreel/archive — /api/archive 없음
|
||||
*/
|
||||
export const FEATURES = {
|
||||
styling: false,
|
||||
archive: false,
|
||||
} as const;
|
||||
@@ -1,13 +1,11 @@
|
||||
import type { NextConfig } from "next";
|
||||
|
||||
// 컨테이너에서는 서비스명(http://backend:30101)으로, 로컬에서는 localhost로 붙는다
|
||||
const API = process.env.API_ORIGIN ?? "http://localhost:30101";
|
||||
|
||||
// /api/* 프록시는 proxy.ts 에 있다 — 목적지를 런타임에 정해야 해서다
|
||||
const nextConfig: NextConfig = {
|
||||
async rewrites() {
|
||||
return [
|
||||
{ source: "/api/:path*", destination: `${API}/api/:path*` },
|
||||
];
|
||||
experimental: {
|
||||
// 기본 10MB에서는 포스터 업로드가 잘려 백엔드가 깨진 multipart를 받는다.
|
||||
// 백엔드 상한이 30MB라 multipart 오버헤드만큼 여유를 둔다
|
||||
proxyClientMaxBodySize: "32mb",
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import type { NextRequest } from "next/server";
|
||||
|
||||
/**
|
||||
* /api/* 를 백엔드로 넘긴다. CORS를 쓰지 않는 이유가 이것이다.
|
||||
*
|
||||
* next.config.ts 의 rewrites 로는 안 된다 — Next가 빌드할 때 목적지를 평가해
|
||||
* routes-manifest.json 에 박아버려서, 이미지를 구운 뒤에는 환경변수를 바꿔도 안 먹는다.
|
||||
* proxy 는 Node 런타임에서 요청마다 돌아 그때 환경변수를 읽는다.
|
||||
*
|
||||
* 컨테이너에서는 서비스명(http://backend:30101), 로컬에서는 localhost.
|
||||
*/
|
||||
const API_ORIGIN = process.env.API_ORIGIN ?? "http://localhost:30101";
|
||||
|
||||
export function proxy(request: NextRequest) {
|
||||
const { pathname, search } = request.nextUrl;
|
||||
return NextResponse.rewrite(new URL(pathname + search, API_ORIGIN));
|
||||
}
|
||||
|
||||
export const config = {
|
||||
matcher: "/api/:path*",
|
||||
};
|
||||
Reference in new issue
Block a user