Add Docker, Woodpecker CI/CD, and dev proxy setup
ci/woodpecker/manual/woodpecker Pipeline was successful
ci/woodpecker/manual/woodpecker Pipeline was successful
- Add multi-stage Dockerfile (Vite build → Nginx serve) - Add nginx.conf: serves SPA, proxies /api/ to yugioh-api:3000 - Add .woodpecker.yml pipeline (build + deploy on yugioh network, port 8041) - Add .dockerignore - Add .env.example with VITE_API_URL - Update .gitignore to exclude .env files - Update vite.config.js: proxy /api to backend in dev via VITE_API_URL - Fix git remote push URLs (were pointing at Dashboard repo) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
node_modules
|
||||||
|
dist
|
||||||
|
.env
|
||||||
|
.env.local
|
||||||
|
.git
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
# In development, Vite proxies /api to this URL.
|
||||||
|
# In production, Nginx handles the proxy — leave blank or omit.
|
||||||
|
VITE_API_URL=http://localhost:3000
|
||||||
@@ -1,3 +1,6 @@
|
|||||||
|
.env
|
||||||
|
.env.local
|
||||||
|
|
||||||
# Logs
|
# Logs
|
||||||
logs
|
logs
|
||||||
*.log
|
*.log
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
when:
|
||||||
|
branch: main
|
||||||
|
event: [push, manual]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: build
|
||||||
|
image: docker:cli
|
||||||
|
volumes:
|
||||||
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
|
commands:
|
||||||
|
- docker build -t yugioh-frontend:latest .
|
||||||
|
|
||||||
|
- name: deploy
|
||||||
|
image: docker:cli
|
||||||
|
volumes:
|
||||||
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
|
commands:
|
||||||
|
- docker stop yugioh-frontend || true
|
||||||
|
- docker rm yugioh-frontend || true
|
||||||
|
- docker network create yugioh || true
|
||||||
|
- docker run -d
|
||||||
|
--name yugioh-frontend
|
||||||
|
--restart unless-stopped
|
||||||
|
--network yugioh
|
||||||
|
-p 8041:80
|
||||||
|
yugioh-frontend:latest
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
FROM node:20-alpine AS builder
|
||||||
|
WORKDIR /app
|
||||||
|
COPY package*.json ./
|
||||||
|
RUN npm ci
|
||||||
|
COPY . .
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
FROM nginx:alpine
|
||||||
|
COPY --from=builder /app/dist /usr/share/nginx/html
|
||||||
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
|
EXPOSE 80
|
||||||
|
CMD ["nginx", "-g", "daemon off;"]
|
||||||
+19
@@ -0,0 +1,19 @@
|
|||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
index index.html;
|
||||||
|
|
||||||
|
# Proxy API calls to the yugioh-api container (strips /api prefix)
|
||||||
|
location /api/ {
|
||||||
|
proxy_pass http://yugioh-api:3000/;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
}
|
||||||
|
|
||||||
|
# SPA fallback
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ /index.html;
|
||||||
|
}
|
||||||
|
}
|
||||||
+14
-3
@@ -1,7 +1,18 @@
|
|||||||
import { defineConfig } from 'vite'
|
import { defineConfig, loadEnv } from 'vite'
|
||||||
import react from '@vitejs/plugin-react'
|
import react from '@vitejs/plugin-react'
|
||||||
|
|
||||||
// https://vite.dev/config/
|
export default defineConfig(({ mode }) => {
|
||||||
export default defineConfig({
|
const env = loadEnv(mode, process.cwd(), '')
|
||||||
|
return {
|
||||||
plugins: [react()],
|
plugins: [react()],
|
||||||
|
server: {
|
||||||
|
proxy: {
|
||||||
|
'/api': {
|
||||||
|
target: env.VITE_API_URL || 'http://localhost:3000',
|
||||||
|
changeOrigin: true,
|
||||||
|
rewrite: (path) => path.replace(/^\/api/, '')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user