Skip to content

Commit 64801aa

Browse files
authored
Merge pull request #1 from SuriyaKumar2402/master
Updated the React Docker Sample
2 parents 94743db + aae5986 commit 64801aa

11 files changed

Lines changed: 184 additions & 1 deletion

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+
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"]

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,19 @@
1-
# Dockerizing-React-applications-with-the-Syncfusion-Grid-component
1+
# Dockerizing React applications with the Syncfusion Grid component
2+
23
This repository holds a project showcasing how to dockerizing a React application that utilizes Syncfusion React Grid component.
4+
5+
## Prerequisites
6+
7+
- [Docker Desktop](https://docs.docker.com/desktop/install/windows-install/)
8+
9+
## Install Docker Desktop
10+
11+
Please follow the installation steps outlined in the official Docker documentation for installing Docker Desktop on a Windows operating system. You can find the instructions on the Docker website under [Docker on Windows](https://docs.docker.com/desktop/install/windows-install/#install-docker-desktop-on-windows).
12+
13+
## Run the Docker Image
14+
15+
To run the React application in Docker, use the below Docker Compose command,
16+
17+
```sh
18+
Docker-compose up
19+
```

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": "dockerizing-react-applications-with-the-syncfusion-grid-component",
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: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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 name="description" content="Web site created using create-react-app" />
9+
<title>React App in Docker</title>
10+
</head>
11+
<body>
12+
<noscript>You need to enable JavaScript to run this app.</noscript>
13+
<div id="root"></div>
14+
</body>
15+
</html>

src/App.js

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

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";

0 commit comments

Comments
 (0)