Add R2 image storage, upload endpoint, and CDN support
All checks were successful
ci/woodpecker/push/deploy Pipeline was successful
All checks were successful
ci/woodpecker/push/deploy Pipeline was successful
- Backend: R2StorageService, upload controller (POST /api/upload) - Frontend: CDN url helper, NEXT_PUBLIC_CDN_URL build arg - Deploy: pass R2 secrets from Woodpecker CI to containers via .env - Docs: update CLAUDE.md with CDN and upload conventions Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -3,3 +3,6 @@ INTERNAL_API_URL=http://gb-prod-backend:5000
|
||||
|
||||
# URL бэкенда для проксирования /api/* в локальной разработке (не задавать на сервере!)
|
||||
# LOCAL_API_URL=http://localhost:5000
|
||||
|
||||
# CDN URL для изображений (Cloudflare R2)
|
||||
NEXT_PUBLIC_CDN_URL=https://cdn.goodbrick.com.ua
|
||||
|
||||
@@ -7,6 +7,7 @@ FROM node:20-alpine AS builder
|
||||
WORKDIR /app
|
||||
ARG NEXT_PUBLIC_POSTHOG_KEY
|
||||
ARG NEXT_PUBLIC_POSTHOG_HOST
|
||||
ARG NEXT_PUBLIC_CDN_URL
|
||||
COPY --from=deps /app/node_modules ./node_modules
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
|
||||
@@ -2,6 +2,11 @@ import type { NextConfig } from "next";
|
||||
|
||||
const nextConfig: NextConfig = {
|
||||
output: "standalone",
|
||||
images: {
|
||||
remotePatterns: [
|
||||
{ protocol: "https", hostname: "cdn.goodbrick.com.ua" },
|
||||
],
|
||||
},
|
||||
async rewrites() {
|
||||
const apiUrl = process.env.LOCAL_API_URL;
|
||||
if (!apiUrl) return [];
|
||||
|
||||
5
frontend/public/robots.txt
Normal file
5
frontend/public/robots.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
User-agent: *
|
||||
Allow: /
|
||||
Allow: /_next/image
|
||||
|
||||
Sitemap: https://new.goodbrick.com.ua/sitemap.xml
|
||||
6
frontend/src/lib/cdn.ts
Normal file
6
frontend/src/lib/cdn.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
const CDN_BASE_URL =
|
||||
process.env.NEXT_PUBLIC_CDN_URL || "https://cdn.goodbrick.com.ua";
|
||||
|
||||
export function cdnUrl(path: string): string {
|
||||
return `${CDN_BASE_URL.replace(/\/+$/, "")}/${path.replace(/^\/+/, "")}`;
|
||||
}
|
||||
Reference in New Issue
Block a user