Skip to content

Commit 40a5ede

Browse files
committed
- Removed old testing libraries from the package.json
- Dockerised react-wrapper - Added nginx config for the docker
1 parent df98dfa commit 40a5ede

7 files changed

Lines changed: 101 additions & 4 deletions

File tree

.dockerignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node_modules
2+
build
3+
.dockerignore
4+
Dockerfile
5+
Dockerfile.prod
6+
.git

Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM node:18-alpine3.14
2+
3+
WORKDIR /app
4+
5+
ENV PATH /app/node_modules/.bin:$PATH
6+
7+
COPY package.json ./
8+
COPY package-lock.json ./
9+
RUN npm install --silent
10+
RUN npm install react-scripts@latest -g --silent
11+
12+
COPY . ./
13+
14+
CMD ["npm", "run" , "serve"]

Dockerfile.prod

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# build environment
2+
FROM node:18-alpine3.14 as build
3+
WORKDIR /app
4+
ENV PATH /app/node_modules/.bin:$PATH
5+
COPY package.json ./
6+
COPY package-lock.json ./
7+
RUN export NODE_OPTIONS=--max-old-space-size=8192
8+
RUN npm ci --silent
9+
RUN npm install react-scripts@latest -g --silent
10+
COPY . ./
11+
RUN npm run build
12+
13+
# production environment
14+
FROM nginx:stable-alpine
15+
COPY --from=build /app/build /usr/share/nginx/html
16+
COPY nginx/nginx.conf /etc/nginx/conf.d/default.conf
17+
EXPOSE 80
18+
CMD ["nginx", "-g", "daemon off;"]

README.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,30 @@
11
# nmr_displayer
2-
Wrapping NMRium
2+
3+
Wrapping NMRium
4+
5+
### local development
6+
7+
```docker build -t nmrium-rw:dev .```
8+
9+
```
10+
docker run \
11+
-it \
12+
--rm \
13+
-v ${PWD}:/app \
14+
-v /app/node_modules \
15+
-p 3001:3000 \
16+
-e CHOKIDAR_USEPOLLING=true \
17+
nmrium-rw:dev
18+
```
19+
20+
### local development (docker-compose)
21+
22+
```docker-compose up -d --build```
23+
24+
```docker-compose stop```
25+
26+
### production build
27+
28+
```docker build -f Dockerfile.prod -t nmrium-rw:prod -m 8g .```
29+
30+
```docker run -it --rm -p 1337:80 nmrium-rw:prod```

docker-compose.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
version: '3.7'
2+
3+
services:
4+
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+
environment:
16+
- CHOKIDAR_USEPOLLING=true

nginx/nginx.conf

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
server {
2+
3+
listen 80;
4+
5+
location / {
6+
root /usr/share/nginx/html;
7+
index index.html index.htm;
8+
try_files $uri $uri/ /index.html;
9+
}
10+
11+
error_page 500 502 503 504 /50x.html;
12+
13+
location = /50x.html {
14+
root /usr/share/nginx/html;
15+
}
16+
17+
}

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
],
1616
"scripts": {
1717
"start": "vite --host localhost --port 3000 --open",
18+
"serve": "vite --host",
1819
"build": "vite build --outDir build",
1920
"test": "jest --coverage",
2021
"eslint": "eslint src/* ",
@@ -28,9 +29,6 @@
2829
"@babel/plugin-transform-modules-commonjs": "^7.17.7",
2930
"@babel/preset-react": "^7.16.7",
3031
"@babel/preset-typescript": "^7.16.7",
31-
"@testing-library/jest-dom": "^5.16.3",
32-
"@testing-library/react": "^13.0.0",
33-
"@testing-library/user-event": "^14.0.4",
3432
"@types/jest": "^27.4.1",
3533
"@types/node": "^17.0.23",
3634
"@types/react": "^17.0.43",

0 commit comments

Comments
 (0)