gaialive commited on
Commit
803d604
·
verified ·
1 Parent(s): f459307

Upload 12 files

Browse files
Files changed (8) hide show
  1. Dockerfile +55 -18
  2. build.bat +17 -0
  3. build.sh +20 -0
  4. docker-compose.yml +2 -2
  5. package-lock.json +0 -0
  6. package.json +17 -27
  7. startup.bat +6 -0
  8. startup.sh +7 -0
Dockerfile CHANGED
@@ -1,29 +1,66 @@
1
- # Use Node.js runtime
2
- FROM node:18-alpine as build
 
 
3
 
4
- # Set working directory
5
  WORKDIR /app
6
 
7
- # Copy package files
8
- COPY package*.json ./
9
 
10
- # Install dependencies
11
- RUN npm ci
12
 
13
- # Copy application code
14
- COPY . .
15
 
16
- # Build the application
17
  RUN npm run build
18
 
19
- # Use nginx to serve the static files
20
- FROM nginx:alpine
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
- # Copy built files to nginx
23
- COPY --from=build /app/dist /usr/share/nginx/html
24
 
25
- # Expose port
26
- EXPOSE 8501
 
27
 
28
- # Start nginx
29
- CMD ["nginx", "-g", "daemon off;"]
 
1
+ # Multi-stage Dockerfile for BioNexus Hub
2
+
3
+ # Build the client
4
+ FROM node:18-alpine AS client-builder
5
 
 
6
  WORKDIR /app
7
 
8
+ # Copy client package files
9
+ COPY client/package*.json ./
10
 
11
+ # Install client dependencies
12
+ RUN npm install
13
 
14
+ # Copy client source
15
+ COPY client/ ./
16
 
17
+ # Build client
18
  RUN npm run build
19
 
20
+ # Build the server
21
+ FROM node:18-alpine AS server-builder
22
+
23
+ WORKDIR /app
24
+
25
+ # Copy server package files
26
+ COPY server/package*.json ./
27
+
28
+ # Install server dependencies
29
+ RUN npm install --only=production
30
+
31
+ # Copy server source
32
+ COPY server/ ./
33
+
34
+ # Production image
35
+ FROM node:18-alpine
36
+
37
+ # Install nginx
38
+ RUN apk add --no-cache nginx
39
+
40
+ # Create app directory
41
+ WORKDIR /app
42
+
43
+ # Copy server build
44
+ COPY --from=server-builder /app ./
45
+
46
+ # Copy client build to nginx
47
+ COPY --from=client-builder /app/dist /usr/share/nginx/html
48
+
49
+ # Copy nginx configuration
50
+ COPY client/nginx.conf /etc/nginx/nginx.conf
51
+
52
+ # Copy startup script
53
+ COPY startup.sh .
54
+
55
+ # Make startup script executable
56
+ RUN chmod +x startup.sh
57
 
58
+ # Expose ports
59
+ EXPOSE 80 3001
60
 
61
+ # Health check
62
+ HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
63
+ CMD curl -f http://localhost/health || exit 1
64
 
65
+ # Start both nginx and node server
66
+ CMD ["./startup.sh"]
build.bat ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @echo off
2
+ echo Building BioNexus Hub...
3
+
4
+ REM Build client
5
+ echo Building client...
6
+ cd client
7
+ npm install
8
+ npm run build
9
+ cd ..
10
+
11
+ REM Build server
12
+ echo Building server...
13
+ cd server
14
+ npm install
15
+ cd ..
16
+
17
+ echo Build completed!
build.sh ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # Build script for BioNexus Hub
4
+
5
+ echo "Building BioNexus Hub..."
6
+
7
+ # Build client
8
+ echo "Building client..."
9
+ cd client
10
+ npm install
11
+ npm run build
12
+ cd ..
13
+
14
+ # Build server
15
+ echo "Building server..."
16
+ cd server
17
+ npm install
18
+ cd ..
19
+
20
+ echo "Build completed!"
docker-compose.yml CHANGED
@@ -9,8 +9,8 @@ services:
9
  - "80:80"
10
  depends_on:
11
  - server
12
- environment:
13
- - REACT_APP_API_URL=http://localhost:3001
14
 
15
  server:
16
  build:
 
9
  - "80:80"
10
  depends_on:
11
  - server
12
+ volumes:
13
+ - ./client/nginx.conf:/etc/nginx/nginx.conf
14
 
15
  server:
16
  build:
package-lock.json CHANGED
The diff for this file is too large to render. See raw diff
 
package.json CHANGED
@@ -1,32 +1,22 @@
1
  {
2
- "name": "bionexus-hub-client",
3
- "private": true,
4
- "version": "0.0.0",
5
- "type": "module",
6
  "scripts": {
7
- "dev": "vite",
8
- "build": "vite build",
9
- "lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0",
10
- "preview": "vite preview"
11
- },
12
- "dependencies": {
13
- "react": "^18.2.0",
14
- "react-dom": "^18.2.0",
15
- "react-router-dom": "^6.18.0"
 
16
  },
 
17
  "devDependencies": {
18
- "@tailwindcss/postcss": "^4.0.0",
19
- "@types/react": "^18.2.43",
20
- "@types/react-dom": "^18.2.17",
21
- "@vitejs/plugin-react": "^4.2.1",
22
- "autoprefixer": "^10.4.16",
23
- "eslint": "^8.55.0",
24
- "eslint-plugin-react": "^7.33.2",
25
- "eslint-plugin-react-hooks": "^4.6.0",
26
- "eslint-plugin-react-refresh": "^0.4.5",
27
- "postcss": "^8.4.32",
28
- "tailwindcss": "^4.0.0",
29
- "vite": "^5.0.8"
30
- },
31
- "proxy": "http://localhost:3001"
32
  }
 
1
  {
2
+ "name": "BioNexus-Hub",
3
+ "version": "1.0.0",
4
+ "description": "A lightweight, regional-to-global digital nexus that connects policymakers, companies, researchers, civil society and communities to accelerate bioeconomy solutions that reduce food loss & waste (FLW) and catalyse circular agrifood-system transformation.",
5
+ "main": "index.js",
6
  "scripts": {
7
+ "dev": "concurrently \"npm run dev:client\" \"npm run dev:server\"",
8
+ "dev:client": "cd client && npm run dev",
9
+ "dev:server": "cd server && npm run dev",
10
+ "build": "concurrently \"npm run build:client\" \"npm run build:server\"",
11
+ "build:client": "cd client && npm run build",
12
+ "build:server": "cd server && npm run build",
13
+ "start": "concurrently \"npm run start:client\" \"npm run start:server\"",
14
+ "start:client": "cd client && npm start",
15
+ "start:server": "cd server && npm start",
16
+ "test": "echo \"Error: no test specified\" && exit 1"
17
  },
18
+ "private": true,
19
  "devDependencies": {
20
+ "concurrently": "^8.2.0"
21
+ }
 
 
 
 
 
 
 
 
 
 
 
 
22
  }
startup.bat ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ @echo off
2
+ REM Start nginx in the background
3
+ start nginx
4
+
5
+ REM Start the Node.js server
6
+ node server/index.js
startup.sh ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ #!/bin/sh
2
+
3
+ # Start nginx in the background
4
+ nginx &
5
+
6
+ # Start the Node.js server
7
+ node server/index.js