Skip to content

Commit fb0f8ec

Browse files
Merge pull request #11 from Annotation-Garden/feature/cloudflare-pages
Migrate to Cloudflare Pages
2 parents 988b6cd + b382a58 commit fb0f8ec

File tree

6 files changed

+38
-48
lines changed

6 files changed

+38
-48
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ frontend/public/*
119119
!frontend/public/AGI-square.png
120120
!frontend/public/favicon.ico
121121
!frontend/public/image-list.json
122+
!frontend/public/copy-static-assets.sh
122123

123124
# Image files (but keep README, and downsampled)
124125
images/original/*.png

frontend/README.md

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ npm run dev
1717

1818
Visit http://localhost:3000 to see the dashboard.
1919

20-
## 📦 Deployment
20+
## Deployment
2121

2222
### Building for Production
2323

2424
```bash
25-
# Build and export static site for GitHub Pages
25+
# Build and export static site
2626
npm run build:static
2727

2828
# This will:
@@ -31,23 +31,15 @@ npm run build:static
3131
# 3. Export as static HTML to out/
3232
```
3333

34-
### Manual Deployment to GitHub Pages
34+
The site is deployed to Cloudflare Pages automatically via GitHub Actions.
3535

36-
```bash
37-
# Deploy to GitHub Pages (after building)
38-
npm run deploy
39-
```
40-
41-
The site will be available at: https://annotation-garden.github.io/image-annotation
42-
43-
## 🛠️ Available Scripts
36+
## Available Scripts
4437

4538
- `npm run dev` - Start development server
4639
- `npm run build` - Build for production
47-
- `npm run build:static` - Build static site for GitHub Pages
40+
- `npm run build:static` - Build static site with assets
4841
- `npm run copy-assets` - Copy images and annotations to public folder
4942
- `npm run clean` - Clean build artifacts and copied assets
50-
- `npm run deploy` - Deploy to GitHub Pages (requires gh-pages package)
5143

5244
## 📁 Project Structure
5345

frontend/app/page.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,14 @@ export default function Dashboard() {
3939
useEffect(() => {
4040
async function loadImageList() {
4141
try {
42-
const basePath = process.env.NEXT_PUBLIC_BASE_PATH || ''
43-
const response = await fetch(`${basePath}/image-list.json`)
42+
const response = await fetch('/image-list.json')
4443
if (response.ok) {
4544
const data = await response.json()
4645
const imageList: ImageData[] = data.images.map((imageName: string) => ({
4746
id: imageName,
48-
thumbnailPath: `${basePath}/thumbnails/${imageName}.jpg`,
49-
imagePath: `${basePath}/downsampled/${imageName}.jpg`,
50-
annotationPath: `${basePath}/annotations/nsd/${imageName}_annotations.json`
47+
thumbnailPath: `/thumbnails/${imageName}.jpg`,
48+
imagePath: `/downsampled/${imageName}.jpg`,
49+
annotationPath: `/annotations/nsd/${imageName}_annotations.json`
5150
}))
5251
setImages(imageList)
5352
} else {
@@ -109,8 +108,7 @@ export default function Dashboard() {
109108
async function loadAnnotationsForImage(imageId: string) {
110109
setImageLoading(true)
111110
try {
112-
const basePath = process.env.NEXT_PUBLIC_BASE_PATH || ''
113-
const response = await fetch(`${basePath}/annotations/nsd/${imageId}_annotations.json`)
111+
const response = await fetch(`/annotations/nsd/${imageId}_annotations.json`)
114112
if (response.ok) {
115113
const data = await response.json()
116114
setAnnotations(prev => ({ ...prev, [imageId]: data.annotations || [] }))
@@ -184,7 +182,7 @@ export default function Dashboard() {
184182
className="flex items-center gap-3 md:gap-4 hover:opacity-90 transition-opacity"
185183
>
186184
<img
187-
src={`${process.env.NEXT_PUBLIC_BASE_PATH || ''}/AGI-square.svg`}
185+
src="/AGI-square.svg"
188186
alt="AGI Logo"
189187
className="w-10 h-10 md:w-12 md:h-12"
190188
/>

frontend/next.config.js

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,12 @@
11
/** @type {import('next').NextConfig} */
22

3-
// Determine if we're building for production GitHub Pages
4-
const isProd = process.env.NODE_ENV === 'production'
5-
const basePath = isProd ? '/image-annotation' : ''
6-
73
const nextConfig = {
84
reactStrictMode: true,
95
images: {
106
domains: ['localhost'],
117
unoptimized: true,
128
},
13-
// GitHub Pages deployment configuration
14-
basePath: basePath,
15-
assetPrefix: basePath,
169
output: 'export',
17-
// Pass the base path to the client
18-
env: {
19-
NEXT_PUBLIC_BASE_PATH: basePath
20-
},
21-
// Allow serving static files from public directory
22-
async rewrites() {
23-
return [
24-
{
25-
source: '/images/:path*',
26-
destination: '/images/:path*',
27-
},
28-
{
29-
source: '/annotations/:path*',
30-
destination: '/annotations/:path*',
31-
},
32-
];
33-
},
3410
}
3511

3612
module.exports = nextConfig

frontend/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@
88
"start": "next start",
99
"lint": "next lint",
1010
"copy-assets": "bash ./public/copy-static-assets.sh",
11-
"build:static": "npm run copy-assets && next build && next export",
12-
"clean": "rm -rf .next out public/thumbnails public/downsampled public/annotations",
13-
"deploy": "npm run build:static && npx gh-pages -d out"
11+
"build:static": "npm run copy-assets && next build",
12+
"clean": "rm -rf .next out public/thumbnails public/downsampled public/annotations"
1413
},
1514
"dependencies": {
1615
"next": "^14.2.5",
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
# Copy static assets from parent directories to public folder for build
3+
4+
set -e
5+
6+
echo "Copying static assets..."
7+
8+
# Create directories
9+
mkdir -p public/thumbnails public/downsampled public/annotations/nsd
10+
11+
# Copy thumbnails
12+
cp -r ../data/thumbnails/* public/thumbnails/ 2>/dev/null || echo "No thumbnails to copy"
13+
14+
# Copy downsampled images
15+
cp -r ../images/downsampled/* public/downsampled/ 2>/dev/null || echo "No images to copy"
16+
17+
# Copy annotations
18+
cp -r ../annotations/nsd/*.json public/annotations/nsd/ 2>/dev/null || echo "No annotations to copy"
19+
20+
# Copy image list if it exists
21+
cp ../data/image-list.json public/ 2>/dev/null || echo "No image-list.json to copy"
22+
23+
echo "Assets copied successfully"
24+
ls -la public/

0 commit comments

Comments
 (0)