- Add Dockerfile and .dockerignore for containerisation - Add .woodpecker.yml pipeline (build + deploy to yugioh network on .101) - Add .gitignore to stop tracking .env; replace with .env.example - Add npm start script - Fix index.js: move versionRoutes require before listen, add /health endpoint - 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,3 @@
|
||||
node_modules
|
||||
.env
|
||||
.git
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
DB_HOST=192.168.178.31
|
||||
DB_PORT=3306
|
||||
DB_USER=YuGiOh_API
|
||||
DB_PASSWORD='b26^c`eqJvOCVS4i3$H2bot;|q0#BtM&'
|
||||
DB_PASSWORD=your_db_password_here
|
||||
DB_NAME=YuGiOhDB
|
||||
YGOPRO_API_BASE=https://db.ygoprodeck.com/api/v7
|
||||
PORT=3000
|
||||
@@ -0,0 +1,2 @@
|
||||
node_modules
|
||||
.env
|
||||
@@ -0,0 +1,28 @@
|
||||
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-api:latest .
|
||||
|
||||
- name: deploy
|
||||
image: docker:cli
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
- /opt/docker/yugioh/.env:/opt/docker/yugioh/.env
|
||||
commands:
|
||||
- sed "s/='\(.*\)'$/=\1/; s/=\"\(.*\)\"$/=\1/" /opt/docker/yugioh/.env > /tmp/yugioh-api.env
|
||||
- docker stop yugioh-api || true
|
||||
- docker rm yugioh-api || true
|
||||
- docker network create yugioh || true
|
||||
- docker run -d
|
||||
--name yugioh-api
|
||||
--restart unless-stopped
|
||||
--network yugioh
|
||||
--env-file /tmp/yugioh-api.env
|
||||
yugioh-api:latest
|
||||
@@ -0,0 +1,7 @@
|
||||
FROM node:20-alpine
|
||||
WORKDIR /app
|
||||
COPY package*.json ./
|
||||
RUN npm ci --omit=dev
|
||||
COPY src/ ./src/
|
||||
EXPOSE 3000
|
||||
CMD ["node", "src/index.js"]
|
||||
@@ -4,6 +4,7 @@
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"start": "node src/index.js",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"repository": {
|
||||
|
||||
+7
-9
@@ -1,28 +1,26 @@
|
||||
//index.js
|
||||
const express = require('express');
|
||||
require('dotenv').config();
|
||||
const cors = require('cors');
|
||||
|
||||
// Routes
|
||||
const importRoutes = require('./routes/importRoutes');
|
||||
const collectionRoutes = require('./routes/collectionRoutes');
|
||||
const exportCardsRoutes = require('./routes/exportCardsRoutes');
|
||||
const cardImageRoutes = require('./routes/cardImageRoutes'); // <-- new
|
||||
const cardImageRoutes = require('./routes/cardImageRoutes');
|
||||
const versionRoutes = require('./routes/versionRoutes');
|
||||
|
||||
const app = express();
|
||||
app.use(cors()); // enable CORS for frontend
|
||||
app.use(cors());
|
||||
app.use(express.json());
|
||||
|
||||
// Mount routes
|
||||
app.get('/health', (_req, res) => res.json({ status: 'ok' }));
|
||||
|
||||
app.use('/import', importRoutes);
|
||||
app.use('/collection', collectionRoutes);
|
||||
app.use('/exportCards', exportCardsRoutes);
|
||||
app.use('/cardImage', cardImageRoutes);
|
||||
app.use('/db-version', versionRoutes);
|
||||
|
||||
const PORT = process.env.PORT || 3000;
|
||||
app.listen(PORT, () => {
|
||||
console.log(`Server running on http://localhost:${PORT}`);
|
||||
console.log(`Server running on port ${PORT}`);
|
||||
});
|
||||
|
||||
const versionRoutes = require('./routes/versionRoutes');
|
||||
app.use('/db-version', versionRoutes);
|
||||
Reference in New Issue
Block a user