Skip to content

Commit 229b372

Browse files
Updated react docker sample
1 parent 94743db commit 229b372

File tree

10 files changed

+168
-0
lines changed

10 files changed

+168
-0
lines changed

.dockerignore

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

.gitignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# production
12+
/build
13+
14+
# misc
15+
.DS_Store
16+
.env.local
17+
.env.development.local
18+
.env.test.local
19+
.env.production.local
20+
21+
npm-debug.log*
22+
yarn-debug.log*
23+
yarn-error.log*

Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Use an existing node alpine image as a base image
2+
FROM node:18-alpine
3+
4+
# Set the working directory
5+
WORKDIR /app
6+
7+
# Copy the package.json file
8+
COPY package.json .
9+
10+
# Install application dependencies
11+
RUN npm install
12+
13+
# Copy the rest of the application files
14+
COPY . .
15+
16+
# Expose the port
17+
EXPOSE 3000
18+
19+
# Run the application
20+
CMD ["npm", "start"]

docker-compose.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Dockerfile
2+
3+
# Refer compose file version 3
4+
version: "3"
5+
6+
services:
7+
# Service name is react-app
8+
react-app:
9+
# build from Dockerfile
10+
build: .
11+
# expose 3000 as hosting port & 3000 in container port
12+
ports:
13+
- "3000:3000"
14+
environment:
15+
#Provide your license key for activation as environment variable to docker container
16+
REACT_APP_SYNCFUSION_LICENSE_KEY: ${REACT_APP_SYNCFUSION_LICENSE_KEY}

package.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"name": "my-app",
3+
"version": "0.1.0",
4+
"private": true,
5+
"dependencies": {
6+
"@syncfusion/ej2-react-grids": "*",
7+
"react": "^18.2.0",
8+
"react-dom": "^18.2.0",
9+
"react-scripts": "5.0.1"
10+
},
11+
"scripts": {
12+
"start": "react-scripts start",
13+
"build": "react-scripts build",
14+
"test": "react-scripts test",
15+
"eject": "react-scripts eject"
16+
},
17+
"eslintConfig": {
18+
"extends": [
19+
"react-app",
20+
"react-app/jest"
21+
]
22+
},
23+
"browserslist": {
24+
"production": [
25+
">0.2%",
26+
"not dead",
27+
"not op_mini all"
28+
],
29+
"development": [
30+
"last 1 chrome version",
31+
"last 1 firefox version",
32+
"last 1 safari version"
33+
]
34+
}
35+
}

public/favicon.ico

3.78 KB
Binary file not shown.

public/index.html

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1" />
7+
<meta name="theme-color" content="#000000" />
8+
<meta
9+
name="description"
10+
content="Web site created using create-react-app"
11+
/>
12+
<title>React App in Docker</title>
13+
</head>
14+
<body>
15+
<noscript>You need to enable JavaScript to run this app.</noscript>
16+
<div id="root"></div>
17+
</body>
18+
</html>

src/App.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import * as React from 'react';
2+
import { ColumnDirective, ColumnsDirective, GridComponent, Inject, Page, Sort } from '@syncfusion/ej2-react-grids';
3+
import { registerLicense } from '@syncfusion/ej2-base';
4+
5+
registerLicense(process.env.REACT_APP_SYNCFUSION_LICENSE_KEY);
6+
7+
export default function App() {
8+
9+
const data = [
10+
{ OrderID: 10248, CustomerID: 'VINET', ShipCountry: 'France' },
11+
{ OrderID: 10249, CustomerID: 'TOMSP', ShipCountry: 'Germany' },
12+
{ OrderID: 10250, CustomerID: 'HANAR', ShipCountry: 'Brazil' },
13+
{ OrderID: 10251, CustomerID: 'VICTE', ShipCountry: 'Venezuela' },
14+
{ OrderID: 10252, CustomerID: 'SUPRD', ShipCountry: 'Belgium' },
15+
{ OrderID: 10253, CustomerID: 'CHOPS', ShipCountry: 'Switzerland' }
16+
];
17+
18+
return (<React.Fragment>
19+
<h2>Syncfusion React Grid Component</h2>
20+
<GridComponent dataSource={data} allowPaging={true} pageSettings={{ pageSize: 5 }}>
21+
<ColumnsDirective>
22+
<ColumnDirective field='OrderID' width='100'/>
23+
<ColumnDirective field='CustomerID' width='100'/>
24+
<ColumnDirective field='ShipCountry' width='100'/>
25+
</ColumnsDirective>
26+
<Inject services={[Page, Sort]}/>
27+
</GridComponent>
28+
</React.Fragment>);
29+
};

src/index.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
@import '../node_modules/@syncfusion/ej2-base/styles/material.css';
2+
@import '../node_modules/@syncfusion/ej2-buttons/styles/material.css';
3+
@import '../node_modules/@syncfusion/ej2-calendars/styles/material.css';
4+
@import '../node_modules/@syncfusion/ej2-dropdowns/styles/material.css';
5+
@import '../node_modules/@syncfusion/ej2-inputs/styles/material.css';
6+
@import '../node_modules/@syncfusion/ej2-navigations/styles/material.css';
7+
@import '../node_modules/@syncfusion/ej2-popups/styles/material.css';
8+
@import '../node_modules/@syncfusion/ej2-splitbuttons/styles/material.css';
9+
@import '../node_modules/@syncfusion/ej2-notifications/styles/material.css';
10+
@import "../node_modules/@syncfusion/ej2-react-grids/styles/material.css";

src/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import React from 'react';
2+
import ReactDOM from 'react-dom/client';
3+
import './index.css';
4+
import App from './App';
5+
6+
const root = ReactDOM.createRoot(document.getElementById('root'));
7+
root.render(
8+
<React.StrictMode>
9+
<App />
10+
</React.StrictMode>
11+
);

0 commit comments

Comments
 (0)