Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
.DS_Store

node_modules

/coverage.data
/coverage/
63 changes: 63 additions & 0 deletions .harness/reacthdh.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
pipeline:
name: react-hdh
identifier: reacthdh
projectIdentifier: DhrubaCI
orgIdentifier: default
tags: {}
variables:
- name: DOCKERHUB_USERNAME
type: String
description: Your Docker Hub username
value: <+input>
stages:
- stage:
name: Build
identifier: Build
type: CI
spec:
cloneCodebase: true
execution:
steps:
- step:
type: Run
name: install node modules
identifier: install_node_modules
spec:
shell: Sh
command: npm install
- step:
type: Run
name: build app
identifier: build_app
spec:
shell: Sh
command: npm run build
- step:
type: Run
name: run tests
identifier: run_tests
spec:
shell: Sh
command: "# npm run test"
- step:
type: BuildAndPushDockerRegistry
name: Build and Push an image to Docker Registry
identifier: BuildandPushanimagetoDockerRegistry
spec:
connectorRef: harnesscommunitydocker
repo: <+pipeline.variables.DOCKERHUB_USERNAME>/test-react
tags:
- <+pipeline.sequenceId>
platform:
os: Linux
arch: Amd64
runtime:
type: Cloud
spec: {}
properties:
ci:
codebase:
connectorRef: dhrubaaccountconnector
repoName: react-pipeline-sample
build: <+input>
allowStageExecutions: true
8 changes: 7 additions & 1 deletion .harness/samplereactapp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ pipeline:
spec:
shell: Sh
command: npm install
- step:
type: Run
name: build app
identifier: run_tests
spec:
shell: Sh
command: npm run build
- step:
type: BuildAndPushDockerRegistry
name: build and push to docker
Expand All @@ -42,4 +49,3 @@ pipeline:
connectorRef: <+input>
repoName: sample-react-app-ci
build: <+input>

90 changes: 90 additions & 0 deletions .harness/testreact.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
pipeline:
name: test-react
identifier: testreact
projectIdentifier: DhrubaCI
orgIdentifier: default
tags: {}
variables:
- name: DOCKERHUB_USERNAME
type: String
description: Your Docker Hub username
value: <+input>
stages:
- stage:
name: Build
identifier: Build
type: CI
spec:
cloneCodebase: true
execution:
steps:
- step:
type: Run
name: build app
identifier: build_app
spec:
shell: Sh
command: npm run build
- step:
type: Run
name: run tests
identifier: run_tests
spec:
shell: Sh
command: npm run test
- step:
type: BuildAndPushDockerRegistry
name: Build and Push an image to Docker Registry
identifier: BuildandPushanimagetoDockerRegistry
spec:
connectorRef: DhrubajyotiDocker
repo: <+pipeline.variables.DOCKERHUB_USERNAME>/test-react
tags:
- <+pipeline.sequenceId>
platform:
os: Linux
arch: Amd64
runtime:
type: Cloud
spec: {}
- stage:
name: Run Connectivity Test
identifier: Run_Connectivity_Test
description: ""
type: CI
spec:
cloneCodebase: false
platform:
os: Linux
arch: Amd64
runtime:
type: Cloud
spec: {}
execution:
steps:
- step:
type: Background
name: Run Java HTTP Server
identifier: Run_Java_HTTP_Server
spec:
connectorRef: DhrubajyotiDocker
image: <+pipeline.variables.DOCKERHUB_USERNAME>/test-react:<+pipeline.sequenceId>
shell: Sh
portBindings:
"8888": "8888"
- step:
type: Run
name: Test Connection to Java HTTP Server
identifier: Test_Connection_to_Java_HTTP_Server
spec:
shell: Sh
command: |-
until curl --max-time 1 http://localhost:8888; do
sleep 2;
done
properties:
ci:
codebase:
connectorRef: dhrubaaccountconnector
repoName: react-pipeline-sample
build: <+input>
90 changes: 90 additions & 0 deletions .harness/testreact2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
pipeline:
name: test-react-2
identifier: testreact2
projectIdentifier: DhrubaCI
orgIdentifier: default
tags: {}
variables:
- name: DOCKERHUB_USERNAME
type: String
description: Your Docker Hub username
value: <+input>
stages:
- stage:
name: Build
identifier: Build
type: CI
spec:
cloneCodebase: true
execution:
steps:
- step:
type: Run
name: build app
identifier: build_app
spec:
shell: Sh
command: npm run build
- step:
type: Run
name: run tests
identifier: run_tests
spec:
shell: Sh
command: npm run test
- step:
type: BuildAndPushDockerRegistry
name: Build and Push an image to Docker Registry
identifier: BuildandPushanimagetoDockerRegistry
spec:
connectorRef: DhrubajyotiDocker
repo: <+pipeline.variables.DOCKERHUB_USERNAME>/test-react
tags:
- <+pipeline.sequenceId>
platform:
os: Linux
arch: Amd64
runtime:
type: Cloud
spec: {}
- stage:
name: Run Connectivity Test
identifier: Run_Connectivity_Test
description: ""
type: CI
spec:
cloneCodebase: false
platform:
os: Linux
arch: Amd64
runtime:
type: Cloud
spec: {}
execution:
steps:
- step:
type: Background
name: Test Server
identifier: Test_Server
spec:
connectorRef: DhrubajyotiDocker
image: <+pipeline.variables.DOCKERHUB_USERNAME>/test-react:<+pipeline.sequenceId>
shell: Sh
portBindings:
"8888": "8888"
- step:
type: Run
name: Test Connection to Java HTTP Server
identifier: Test_Connection_to_Java_HTTP_Server
spec:
shell: Sh
command: |-
until curl --max-time 1 http://localhost:8888; do
sleep 2;
done
properties:
ci:
codebase:
connectorRef: dhrubaaccountconnector
repoName: react-pipeline-sample
build: <+input>
90 changes: 90 additions & 0 deletions .harness/testreact3.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
pipeline:
name: test-react-2
identifier: testreact2
projectIdentifier: DhrubaCI
orgIdentifier: default
tags: {}
variables:
- name: DOCKERHUB_USERNAME
type: String
description: Your Docker Hub username
value: <+input>
stages:
- stage:
name: Build
identifier: Build
type: CI
spec:
cloneCodebase: true
execution:
steps:
- step:
type: Run
name: build app
identifier: build_app
spec:
shell: Sh
command: npm run build
- step:
type: Run
name: run tests
identifier: run_tests
spec:
shell: Sh
command: npm run test
- step:
type: BuildAndPushDockerRegistry
name: Build and Push an image to Docker Registry
identifier: BuildandPushanimagetoDockerRegistry
spec:
connectorRef: DhrubajyotiDocker
repo: <+pipeline.variables.DOCKERHUB_USERNAME>/test-react
tags:
- <+pipeline.sequenceId>
platform:
os: Linux
arch: Amd64
runtime:
type: Cloud
spec: {}
- stage:
name: Run Connectivity Test
identifier: Run_Connectivity_Test
description: ""
type: CI
spec:
cloneCodebase: false
platform:
os: Linux
arch: Amd64
runtime:
type: Cloud
spec: {}
execution:
steps:
- step:
type: Background
name: Test Server
identifier: Test_Server
spec:
connectorRef: DhrubajyotiDocker
image: <+pipeline.variables.DOCKERHUB_USERNAME>/test-react:<+pipeline.sequenceId>
shell: Sh
portBindings:
"8888": "8888"
- step:
type: Run
name: Test Connection to Java HTTP Server
identifier: Test_Connection_to_Java_HTTP_Server
spec:
shell: Sh
command: |-
until curl --max-time 1 http://localhost:8888; do
sleep 2;
done
properties:
ci:
codebase:
connectorRef: dhrubaaccountconnector
repoName: react-pipeline-sample
build: <+input>
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ COPY package.json ./
RUN npm install
COPY . .
RUN npm run build
EXPOSE 8080
FROM nginx:1.19
COPY ./nginx/nginx.conf /etc/nginx/nginx.conf
COPY --from=build /react-app/build /usr/share/nginx/html
EXPOSE 8080

Loading