Skip to content

Commit 0271a0c

Browse files
authored
Merge pull request #256 from NFDI4Chem/development
Development
2 parents a062f2c + 99782de commit 0271a0c

File tree

330 files changed

+653481
-1182
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

330 files changed

+653481
-1182
lines changed

.github/workflows/prod-build.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# This worklflow will perform following actions when a release is published:
2+
# - Fetch Latest release.
3+
# - Build the latest docker image in production.
4+
# - Build release and commit to repo.
5+
# - Push the docker image to Github Artifact Registry-Prod.
6+
# - Rollout latest docker image to GKE.
7+
#
8+
# Maintainers:
9+
# - name: Nisha Sharma
10+
11+
12+
name : Build and Deploy to Prod
13+
14+
on:
15+
push:
16+
branches: [prod-helm-deploy]
17+
18+
env:
19+
DEPLOYMENT_NAME: nmrxiv-nmrium
20+
DOCKER_HUB_USERNAME : ${{ secrets.DOCKER_HUB_USERNAME }}
21+
DOCKER_HUB_PASSWORD : ${{ secrets.DOCKER_HUB_PASSWORD }}
22+
REPOSITORY_NAME: nmrium-react-wrapper
23+
REPOSITORY_NAMESPACE: nfdi4chem
24+
25+
jobs:
26+
setup-build-publish-deploy-prod:
27+
name: Deploy to prod
28+
if: github.ref == 'refs/heads/prod-helm-deploy'
29+
runs-on: ubuntu-latest
30+
steps:
31+
- name: Checkout
32+
uses: actions/[email protected]
33+
34+
# Login to Docker Hub
35+
- name: Log in to Docker Hub
36+
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
37+
with:
38+
username: ${{ env.DOCKER_HUB_USERNAME }}
39+
password: ${{ env.DOCKER_HUB_PASSWORD }}
40+
41+
#Fetch latest release
42+
- name: Fetch latest release
43+
id: fetch-latest-release
44+
uses: InsonusK/[email protected]
45+
with:
46+
myToken: ${{ github.token }}
47+
exclude_types: "draft|prerelease"
48+
view_top: 10
49+
- name: "Print release name"
50+
run: |
51+
echo "tag_name: ${{ steps.fetch-latest-release.outputs.tag_name }}"
52+
53+
#Build and push Docker image to Docker Hub
54+
- name: Build and push Docker image
55+
uses: docker/build-push-action@v4
56+
with:
57+
context: .
58+
file: ./Dockerfile.prod
59+
push: true
60+
build-args: |
61+
RELEASE_VERSION=${{ steps.fetch-latest-release.outputs.tag_name }}
62+
tags: ${{ env.REPOSITORY_NAMESPACE }}/${{ env.REPOSITORY_NAME }}:${{ steps.fetch-latest-release.outputs.tag_name }}, ${{ env.REPOSITORY_NAMESPACE }}/${{ env.REPOSITORY_NAME }}:latest
63+
username: ${{ env.DOCKER_HUB_USERNAME }}
64+
password: ${{ env.DOCKER_HUB_PASSWORD }}
65+
66+
# Build npm for release
67+
- name: Build npm
68+
run: |-
69+
npm install
70+
# Build for main distribution
71+
VITE_BUILD_OUT_DIR=dist npm run build
72+
# Build for specific version
73+
VITE_BUILD_OUT_DIR=releases/${{ steps.fetch-latest-release.outputs.tag_name }} npm run build
74+
75+
# Commit
76+
- name: Commit to repo
77+
uses: EndBug/[email protected]
78+
with:
79+
default_author: github_actions

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
# testing
1010
/coverage
1111

12-
# production
13-
/build
14-
1512
/lib
1613
/lib-cjs
1714

@@ -34,3 +31,6 @@ yarn.lock
3431

3532
/test-results
3633
/playwright-report
34+
35+
build/
36+
dist/

.ncurc.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Do not update to React 19 because some packages not compatible with React 19
2+
reject:
3+
- react
4+
- react-dom
5+
- '@types/react'
6+
- '@types/react-dom'

Dockerfile

Lines changed: 0 additions & 11 deletions
This file was deleted.

Dockerfile.dev

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# build environment
2-
FROM node:22-alpine as build
2+
FROM node:22-alpine3.18 AS build
3+
34
WORKDIR /app
45
ENV PATH /app/node_modules/.bin:$PATH
56
COPY package.json ./
@@ -12,7 +13,7 @@ RUN npm run build
1213

1314
# production environment
1415
FROM nginx:stable-alpine
15-
COPY --from=build /app/build /usr/share/nginx/html
16+
COPY --from=build /app/dist /usr/share/nginx/html
1617
COPY nginx/nginx.conf /etc/nginx/conf.d/default.conf
1718
EXPOSE 80
1819
CMD ["nginx", "-g", "daemon off;"]

Dockerfile.prod

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,40 @@
1-
# build environment
2-
FROM node:22-alpine3.18 as build
1+
# Build stage
2+
FROM node:22-alpine3.18 AS builder
33

4-
# ARG RELEASE_VERSION
5-
# ENV RELEASE_VERSION=${RELEASE_VERSION}
4+
# Declare build argument
5+
ARG RELEASE_VERSION
6+
ENV RELEASE_VERSION=${RELEASE_VERSION}
67

78
WORKDIR /app
8-
ENV PATH /app/node_modules/.bin:$PATH
9+
ENV PATH=/app/node_modules/.bin:$PATH
10+
11+
# Install dependencies first
912
COPY package.json ./
1013
RUN export NODE_OPTIONS=--max-old-space-size=8192
1114
RUN npm i --silent
1215
RUN npm i react-scripts@latest -g --silent
16+
17+
# Copy source and build
1318
COPY . ./
14-
RUN echo "export default { version: '$RELEASE_VERSION' };" > src/versionInfo.ts
15-
RUN npm run build -- --outDir=build
16-
RUN npm run build -- --outDir=build/releases/v0.0.1
19+
RUN echo "export default { version: '${RELEASE_VERSION}' };" > src/versionInfo.ts
1720

18-
# production environment
21+
# Create releases directory and build
22+
RUN mkdir -p /app/releases/${RELEASE_VERSION} && \
23+
npm run build && \
24+
cp -r dist/* /app/releases/${RELEASE_VERSION}/
25+
26+
# Production stage
1927
FROM nginx:stable-alpine
20-
COPY --from=build /app/build /usr/share/nginx/html
28+
29+
# Copy built files from builder
30+
COPY --from=builder /app/dist /usr/share/nginx/html
31+
COPY --from=builder /app/releases/${RELEASE_VERSION} /usr/share/nginx/html
32+
33+
# Copy nginx configuration
2134
COPY nginx/nginx.conf /etc/nginx/conf.d/default.conf
35+
36+
# Expose port 80
2237
EXPOSE 80
38+
39+
# Start nginx
2340
CMD ["nginx", "-g", "daemon off;"]

README.old.md

Lines changed: 0 additions & 70 deletions
This file was deleted.

docker-compose.local.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
services:
2+
# Development environment
3+
nmrium-dev:
4+
container_name: nmrium-dev
5+
build:
6+
context: .
7+
dockerfile: Dockerfile.dev
8+
restart: always
9+
networks:
10+
- nmrium-network
11+
environment:
12+
- NODE_ENV=development
13+
- CHOKIDAR_USEPOLLING=true
14+
15+
# Production environment
16+
nmrium-prod:
17+
container_name: nmrium-prod
18+
build:
19+
context: .
20+
dockerfile: Dockerfile.prod
21+
args:
22+
- RELEASE_VERSION=latest
23+
ports:
24+
- "80:80"
25+
restart: always
26+
networks:
27+
- nmrium-network
28+
29+
# Nginx reverse proxy
30+
nginx-proxy:
31+
container_name: nginx-proxy
32+
image: nginx:stable-alpine
33+
ports:
34+
- "8080:80" # Dev environment on port 8080
35+
- "8081:81" # Prod environment on port 8081
36+
volumes:
37+
- ./nginx/proxy.conf:/etc/nginx/conf.d/default.conf
38+
depends_on:
39+
- nmrium-dev
40+
- nmrium-prod
41+
networks:
42+
- nmrium-network
43+
44+
networks:
45+
nmrium-network:
46+
driver: bridge

docker-compose.yml

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,43 @@
11
version: '3.7'
22

33
services:
4+
# Development environment
5+
nmrium-dev:
6+
container_name: nmrium-dev
7+
image: nfdi4chem/nmrium-react-wrapper:dev-latest
8+
restart: always
9+
networks:
10+
- nmrium-network
11+
environment:
12+
- NODE_ENV=development
13+
- CHOKIDAR_USEPOLLING=true
414

5-
sample:
6-
container_name: nmrium-rw
7-
build:
8-
context: .
9-
dockerfile: Dockerfile
10-
volumes:
11-
- '.:/app'
12-
- '/app/node_modules'
13-
ports:
14-
- 3001:3000
15+
# Production environment
16+
nmrium-prod:
17+
container_name: nmrium-prod
18+
image: nfdi4chem/nmrium-react-wrapper:latest
19+
restart: always
20+
networks:
21+
- nmrium-network
1522
environment:
16-
- CHOKIDAR_USEPOLLING=true
23+
- NODE_ENV=production
24+
- RELEASE_VERSION=latest
25+
26+
# Nginx reverse proxy
27+
nginx-proxy:
28+
container_name: nginx-proxy
29+
image: nginx:stable-alpine
30+
ports:
31+
- "8080:80" # Dev environment on port 8080
32+
- "8081:81" # Prod environment on port 8081
33+
volumes:
34+
- ./nginx/proxy.conf:/etc/nginx/conf.d/default.conf
35+
depends_on:
36+
- nmrium-dev
37+
- nmrium-prod
38+
networks:
39+
- nmrium-network
40+
41+
networks:
42+
nmrium-network:
43+
driver: bridge

eslint.config.mjs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@ export default [
77
ignores: [
88
'dist',
99
'build',
10-
'coverage',
11-
'lib',
12-
'lib-cjs',
10+
'releases',
1311
'node_modules',
1412
'playwright-report',
1513
'public',
16-
'vite.config.ts'
14+
'vite.config.ts',
1715
],
1816
},
1917
...ts,

0 commit comments

Comments
 (0)