153 |
154 |
155 |
156 |
--------------------------------------------------------------------------------
/quarkus-backend/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 | org.eclipse.chedemos
6 | quarkus-backend
7 | 1.0.0-SNAPSHOT
8 |
9 | UTF-8
10 | true
11 | 2.22.0
12 | 1.4.2.Final
13 | UTF-8
14 | 11
15 | 3.8.1
16 | 11
17 |
18 |
19 |
20 |
21 | io.quarkus
22 | quarkus-bom
23 | ${quarkus.version}
24 | pom
25 | import
26 |
27 |
28 |
29 |
30 |
31 | io.quarkus
32 | quarkus-resteasy
33 |
34 |
35 | io.quarkus
36 | quarkus-junit5
37 | test
38 |
39 |
40 | io.rest-assured
41 | rest-assured
42 | test
43 |
44 |
45 | io.quarkus
46 | quarkus-mongodb-panache
47 |
48 |
49 | io.quarkus
50 | quarkus-resteasy-jsonb
51 |
52 |
53 |
54 |
55 |
56 | io.quarkus
57 | quarkus-maven-plugin
58 | ${quarkus.version}
59 |
60 |
61 |
62 | build
63 |
64 |
65 |
66 |
67 |
68 | maven-compiler-plugin
69 | ${compiler-plugin.version}
70 |
71 |
72 | maven-surefire-plugin
73 | ${surefire-plugin.version}
74 |
75 |
76 | org.jboss.logmanager.LogManager
77 |
78 |
79 |
80 |
81 | maven-antrun-plugin
82 | 1.7
83 |
84 |
85 | package
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 | run
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 | native
103 |
104 |
105 | native
106 |
107 |
108 |
109 |
110 |
111 | io.quarkus
112 | quarkus-maven-plugin
113 | ${quarkus.version}
114 |
115 |
116 |
117 | native-image
118 |
119 |
120 | true
121 |
122 |
123 |
124 |
125 |
126 | maven-failsafe-plugin
127 | ${surefire-plugin.version}
128 |
129 |
130 |
131 | integration-test
132 | verify
133 |
134 |
135 |
136 | ${project.build.directory}/${project.build.finalName}-runner
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
--------------------------------------------------------------------------------
/node-frontend/src/serviceWorker.js:
--------------------------------------------------------------------------------
1 | // This optional code is used to register a service worker.
2 | // register() is not called by default.
3 |
4 | // This lets the app load faster on subsequent visits in production, and gives
5 | // it offline capabilities. However, it also means that developers (and users)
6 | // will only see deployed updates on subsequent visits to a page, after all the
7 | // existing tabs open on the page have been closed, since previously cached
8 | // resources are updated in the background.
9 |
10 | // To learn more about the benefits of this model and instructions on how to
11 | // opt-in, read https://bit.ly/CRA-PWA
12 |
13 | const isLocalhost = Boolean(
14 | window.location.hostname === 'localhost' ||
15 | // [::1] is the IPv6 localhost address.
16 | window.location.hostname === '[::1]' ||
17 | // 127.0.0.1/8 is considered localhost for IPv4.
18 | window.location.hostname.match(
19 | /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
20 | )
21 | );
22 |
23 | export function register(config) {
24 | if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
25 | // The URL constructor is available in all browsers that support SW.
26 | const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);
27 | if (publicUrl.origin !== window.location.origin) {
28 | // Our service worker won't work if PUBLIC_URL is on a different origin
29 | // from what our page is served on. This might happen if a CDN is used to
30 | // serve assets; see https://github.com/facebook/create-react-app/issues/2374
31 | return;
32 | }
33 |
34 | window.addEventListener('load', () => {
35 | const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
36 |
37 | if (isLocalhost) {
38 | // This is running on localhost. Let's check if a service worker still exists or not.
39 | checkValidServiceWorker(swUrl, config);
40 |
41 | // Add some additional logging to localhost, pointing developers to the
42 | // service worker/PWA documentation.
43 | navigator.serviceWorker.ready.then(() => {
44 | console.log(
45 | 'This web app is being served cache-first by a service ' +
46 | 'worker. To learn more, visit https://bit.ly/CRA-PWA'
47 | );
48 | });
49 | } else {
50 | // Is not localhost. Just register service worker
51 | registerValidSW(swUrl, config);
52 | }
53 | });
54 | }
55 | }
56 |
57 | function registerValidSW(swUrl, config) {
58 | navigator.serviceWorker
59 | .register(swUrl)
60 | .then(registration => {
61 | registration.onupdatefound = () => {
62 | const installingWorker = registration.installing;
63 | if (installingWorker == null) {
64 | return;
65 | }
66 | installingWorker.onstatechange = () => {
67 | if (installingWorker.state === 'installed') {
68 | if (navigator.serviceWorker.controller) {
69 | // At this point, the updated precached content has been fetched,
70 | // but the previous service worker will still serve the older
71 | // content until all client tabs are closed.
72 | console.log(
73 | 'New content is available and will be used when all ' +
74 | 'tabs for this page are closed. See https://bit.ly/CRA-PWA.'
75 | );
76 |
77 | // Execute callback
78 | if (config && config.onUpdate) {
79 | config.onUpdate(registration);
80 | }
81 | } else {
82 | // At this point, everything has been precached.
83 | // It's the perfect time to display a
84 | // "Content is cached for offline use." message.
85 | console.log('Content is cached for offline use.');
86 |
87 | // Execute callback
88 | if (config && config.onSuccess) {
89 | config.onSuccess(registration);
90 | }
91 | }
92 | }
93 | };
94 | };
95 | })
96 | .catch(error => {
97 | console.error('Error during service worker registration:', error);
98 | });
99 | }
100 |
101 | function checkValidServiceWorker(swUrl, config) {
102 | // Check if the service worker can be found. If it can't reload the page.
103 | fetch(swUrl)
104 | .then(response => {
105 | // Ensure service worker exists, and that we really are getting a JS file.
106 | const contentType = response.headers.get('content-type');
107 | if (
108 | response.status === 404 ||
109 | (contentType != null && contentType.indexOf('javascript') === -1)
110 | ) {
111 | // No service worker found. Probably a different app. Reload the page.
112 | navigator.serviceWorker.ready.then(registration => {
113 | registration.unregister().then(() => {
114 | window.location.reload();
115 | });
116 | });
117 | } else {
118 | // Service worker found. Proceed as normal.
119 | registerValidSW(swUrl, config);
120 | }
121 | })
122 | .catch(() => {
123 | console.log(
124 | 'No internet connection found. App is running in offline mode.'
125 | );
126 | });
127 | }
128 |
129 | export function unregister() {
130 | if ('serviceWorker' in navigator) {
131 | navigator.serviceWorker.ready.then(registration => {
132 | registration.unregister();
133 | });
134 | }
135 | }
136 |
--------------------------------------------------------------------------------
/che-devfile.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: 1.0.0
2 | metadata:
3 | generateName: postit-app-
4 |
5 | projects:
6 |
7 | - source:
8 | type: git
9 | location: 'https://github.com/redhat-developer-demos/quarkus-reactjs-postit-app'
10 | name: postit-app
11 |
12 |
13 | components:
14 |
15 | - alias: quarkus-backend-dev
16 | type: dockerimage
17 | image: quay.io/quarkus/centos-quarkus-maven:20.0.0-java8
18 | memoryLimit: 5Gi
19 | command: ['sleep']
20 | args: ['infinity']
21 | mountSources: true
22 | env:
23 | - name: MAVEN_OPTS
24 | value: '-Dmaven.repo.local=/.m2/repository'
25 | - name: username
26 | value: 'user'
27 | - name: password
28 | value: 'password'
29 | - name: admin_password
30 | value: 'password'
31 | - name: uri
32 | value: 'mongodb://localhost'
33 | endpoints:
34 | - name: 'quarkus-dev'
35 | port: 8080
36 | volumes:
37 | - name: m2
38 | containerPath: /.m2
39 |
40 | - mountSources: true
41 | memoryLimit: 64M
42 | type: dockerimage
43 | image: quay.io/sunix/postit-app-dev-data
44 | alias: data
45 | volumes:
46 | - name: m2
47 | containerPath: /work/volumes/.m2
48 |
49 | - alias: node-frontend-dev
50 | mountSources: true
51 | image: 'quay.io/eclipse/che-nodejs8-centos:7.2.0'
52 | memoryLimit: 768Mi
53 | type: dockerimage
54 | endpoints:
55 | - name: '3000-tcp'
56 | port: 3000
57 | env:
58 | - name: FRONTEND_PORT
59 | value: '3000'
60 |
61 | - alias: quarkus-backend-native-prod
62 | type: dockerimage
63 | image: quay.io/quarkus/ubi-quarkus-native-image:19.2.0.1
64 | memoryLimit: 32M
65 | mountSources: true
66 | command: ['tail']
67 | args: ['-f', '/dev/null']
68 | endpoints:
69 | - name: '8080-tcp'
70 | port: 8080
71 | env:
72 | - name: username
73 | value: 'user'
74 | - name: password
75 | value: 'password'
76 | - name: admin_password
77 | value: 'password'
78 | - name: uri
79 | value: 'mongodb://localhost'
80 |
81 | - alias: mongo
82 | type: dockerimage
83 | image: centos/mongodb-34-centos7
84 | memoryLimit: 512Mi
85 | env:
86 | - name: MONGODB_USER
87 | value: user
88 | - name: MONGODB_PASSWORD
89 | value: password
90 | - name: MONGODB_DATABASE
91 | value: sampledb
92 | - name: MONGODB_ADMIN_PASSWORD
93 | value: password
94 |
95 | - id: redhat/quarkus-java11/latest
96 | type: chePlugin
97 |
98 | - id: redhat/vscode-openshift-connector/0.1.2
99 | type: chePlugin
100 | alias: vscode-openshift
101 |
102 |
103 | - alias: git
104 | type: dockerimage
105 | image: sunix/git-devtools
106 | mountSources: true
107 | memoryLimit: 64M
108 | args: ['sleep', 'infinity']
109 |
110 | commands:
111 |
112 | - name: start DEVMODE quarkus-backend
113 | actions:
114 | - type: exec
115 | command: pkill java; mvn compile quarkus:dev
116 | component: quarkus-backend-dev
117 | workdir: /projects/postit-app/quarkus-backend
118 |
119 | # - name: build JVM quarkus-backend
120 | # actions:
121 | # - type: exec
122 | # command: pkill java; mvn package
123 | # component: quarkus-backend-dev
124 | # workdir: /projects/postit-app/quarkus-backend
125 |
126 | - name: build NATIVE quarkus-backend
127 | actions:
128 | - type: exec
129 | command: pkill java; mvn package -Pnative
130 | component: quarkus-backend-dev
131 | workdir: /projects/postit-app/quarkus-backend
132 |
133 | - name: start NATIVE quarkus-backend
134 | actions:
135 | - type: exec
136 | command: ./quarkus-backend-1.0.0-SNAPSHOT-runner -Dquarkus.http.host=0.0.0.0
137 | component: quarkus-backend-native-prod
138 | workdir: /projects/postit-app/quarkus-backend/target
139 |
140 | - name: Attach remote debugger
141 | actions:
142 | - referenceContent: |
143 | {
144 | "version": "0.2.0",
145 | "configurations": [
146 | {
147 | "type": "java",
148 | "request": "attach",
149 | "name": "Attach to Remote Quarkus App",
150 | "hostName": "localhost",
151 | "port": 5005
152 | }
153 | ]
154 | }
155 | type: vscode-launch
156 |
157 | # - name: build PROD node-frontend
158 | # actions:
159 | # - type: exec
160 | # command: tar zxvf /projects/local/node_modules.tar.gz ; rm /projects/local/node_modules.tar.gz ; npm install
161 | # component: node-frontend-dev
162 | # workdir: /projects/postit-app/node-frontend/
163 |
164 | - name: start DEVMODE node-frontend
165 | actions:
166 | - type: exec
167 | command: npm run devmode
168 | component: node-frontend-dev
169 | workdir: /projects/postit-app/node-frontend/
170 |
171 | - name: start PROD node-frontend
172 | actions:
173 | - type: exec
174 | command: npm start
175 | component: node-frontend-dev
176 | workdir: /projects/postit-app/node-frontend/
177 |
178 |
179 | - name: oc - deploy app (quarkus NATIVE) from github
180 | actions:
181 | - type: exec
182 | command: |-
183 | # mongodb
184 | oc new-app -e MONGODB_USER=user -e MONGODB_PASSWORD=password -e MONGODB_DATABASE=sampledb -e MONGODB_ADMIN_PASSWORD=password centos/mongodb-36-centos7 --name=mongo
185 | # s2i quarkus app from source
186 | oc new-app quay.io/quarkus/ubi-quarkus-native-s2i:20.0.0-java8~https://github.com/redhat-developer-demos/quarkus-reactjs-postit-app --name=quarkus-backend --context-dir=quarkus-backend -e uri=mongodb://mongo -e username=user -e password=password
187 | # s2i node frontend from source
188 | oc new-app nodejs~https://github.com/redhat-developer-demos/quarkus-reactjs-postit-app --context-dir=node-frontend --name=node-frontend -e PORT=8080 -e COMPONENT_QUARKUS_BACKEND_HOST=quarkus-backend
189 | oc expose svc/node-frontend
190 | # quarkus native build need more cpu and memory
191 | # wait for quakus-backend build to start and cancel it to reconfigure it
192 | for i in 1 2 3 4 5 6 7 8 9; do
193 | pods="$(oc get build -o go-template='{{range .items}}{{$bc := index .metadata.annotations "openshift.io/build-config.name"}}{{$status := index .status.phase}}{{if eq $bc "quarkus-backend"}}{{if eq $status "Running"}}{{.metadata.name}}{{"\t"}}{{.status.phase}}{{"\n"}}{{end}}{{end}}{{end}}')";
194 | echo $pods;
195 | if [ -n "$pods" ]; then
196 | break;
197 | fi
198 | echo "Waiting for quarkus-backend build to be ready...";
199 | sleep "2";
200 | done
201 | oc cancel-build bc/quarkus-backend
202 | oc patch bc/quarkus-backend -p '{"spec":{"resources":{"limits":{"cpu":"6", "memory":"6Gi"}}}}'
203 | oc start-build quarkus-backend
204 | oc expose svc/quarkus-backend
205 | # logs
206 | oc logs -f bc/quarkus-backend
207 | oc logs -f bc/node-frontend
208 | echo node-frontend url http://$(oc get route node-frontend --template='{{ .spec.host }}')
209 | component: vscode-openshift
210 | workdir: /projects/postit-app/node-frontend/
211 |
212 | - name: oc - deploy app (quarkus JVM) from github
213 | actions:
214 | - type: exec
215 | command: |-
216 | # mongodb
217 | oc new-app -e MONGODB_USER=user -e MONGODB_PASSWORD=password -e MONGODB_DATABASE=sampledb -e MONGODB_ADMIN_PASSWORD=password centos/mongodb-36-centos7 --name=mongo
218 | # s2i quarkus app from source
219 | oc new-app java~https://github.com/redhat-developer-demos/quarkus-reactjs-postit-app --name=quarkus-backend --context-dir=quarkus-backend -e uri=mongodb://mongo -e username=user -e password=password --env=JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0"
220 | oc expose svc/quarkus-backend
221 | # s2i node frontend from source
222 | oc new-app nodejs~https://github.com/redhat-developer-demos/quarkus-reactjs-postit-app --context-dir=node-frontend --name=node-frontend -e PORT=8080 -e COMPONENT_QUARKUS_BACKEND_HOST=quarkus-backend
223 | oc expose svc/node-frontend
224 | oc logs -f bc/quarkus-backend
225 | oc logs -f bc/node-frontend
226 | echo node-frontend url http://$(oc get route node-frontend --template='{{ .spec.host }}')
227 | component: vscode-openshift
228 | workdir: /projects/postit-app/node-frontend/
229 |
230 | - name: oc - redeploy quarkus-backend (from local sources)
231 | actions:
232 | - type: exec
233 | command: |-
234 | oc start-build quarkus-backend --from-dir=.
235 | oc logs -f bc/quarkus-backend
236 | component: vscode-openshift
237 | workdir: /projects/postit-app/
238 |
239 |
240 | - name: oc - redeploy node-frontend (from local sources)
241 | actions:
242 | - type: exec
243 | command: |-
244 | oc start-build node-frontend --from-dir=.
245 | oc logs -f bc/node-frontend
246 |
247 | component: vscode-openshift
248 | workdir: /projects/postit-app/
249 |
250 |
251 |
252 | - name: oc - scale node-frontend
253 | actions:
254 | - type: exec
255 | command: |-
256 | echo "Scale node-frontend. Enter the number of desired replicas:";
257 | read replicas;
258 | oc scale dc/node-frontend --replicas=${replicas}
259 | component: vscode-openshift
260 | workdir: /projects/postit-app/
261 |
262 | - name: oc - scale quarkus-backend
263 | actions:
264 | - type: exec
265 | command: |-
266 | echo "Scale quarkus-frontend. Enter the number of desired replicas:";
267 | read replicas;
268 | oc scale dc/quarkus-backend --replicas=${replicas}
269 | component: vscode-openshift
270 | workdir: /projects/postit-app/
271 |
272 | - name: oc - get node-frontend URL
273 | actions:
274 | - type: exec
275 | command: |-
276 | echo node-frontend url http://$(oc get route node-frontend --template='{{ .spec.host }}')
277 | component: vscode-openshift
278 | workdir: /projects/postit-app/node-frontend/
279 |
280 |
281 |
282 |
283 |
284 |
285 | - name: oc login
286 | actions:
287 | - type: exec
288 | command: |-
289 | rm oc; curl https://mirror.openshift.com/pub/openshift-v4/clients/oc/latest/linux/oc.tar.gz -s | tar zxv && ./oc login --server=${KUBERNETES_SERVICE_HOST}:443
290 | component: vscode-openshift
291 | workdir: /tmp
292 |
293 | - name: show posts
294 | actions:
295 | - workdir: /tmp
296 | type: exec
297 | command: >-
298 | mongo mongodb://user:password@localhost/sampledb --eval
299 | "printjson(db.getCollection('Posts').find().toArray())"
300 | component: mongo
301 |
--------------------------------------------------------------------------------
/devfile.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: 1.0.0
2 | metadata:
3 | generateName: postit-app-
4 |
5 |
6 | components:
7 |
8 | # Runtime Containers
9 | - alias: mongo
10 | type: dockerimage
11 | image: centos/mongodb-34-centos7
12 | memoryLimit: 512Mi
13 | env:
14 | - name: MONGODB_USER
15 | value: user
16 | - name: MONGODB_PASSWORD
17 | value: password
18 | - name: MONGODB_DATABASE
19 | value: sampledb
20 | - name: MONGODB_ADMIN_PASSWORD
21 | value: password
22 |
23 | - type: dockerimage
24 | alias: quarkus-backend-native-prod
25 | image: 'registry.access.redhat.com/ubi8/ubi-minimal'
26 | memoryLimit: 32M
27 | mountSources: true
28 | endpoints:
29 | - name: 'quarkus-prod'
30 | port: 8080
31 | command: ['tail']
32 | args: ['-f', '/dev/null']
33 | env:
34 | - name: username
35 | value: 'user'
36 | - name: password
37 | value: 'password'
38 | - name: admin_password
39 | value: 'password'
40 | - name: uri
41 | value: 'mongodb://localhost'
42 |
43 | - alias: node-frontend-dev
44 | mountSources: true
45 | image: 'quay.io/eclipse/che-nodejs12-community:nightly'
46 | memoryLimit: 768Mi
47 | type: dockerimage
48 | endpoints:
49 | - name: 'node-dev'
50 | port: 3000
51 | env:
52 | - name: FRONTEND_PORT
53 | value: '3000'
54 |
55 |
56 | # Dev/build containers
57 | - alias: quarkus-backend-dev
58 | type: dockerimage
59 | image: quay.io/quarkus/centos-quarkus-maven:20.1.0-java11
60 | memoryLimit: 4Gi
61 | command: ['sleep']
62 | args: ['infinity']
63 | mountSources: true
64 | env:
65 | - name: MAVEN_OPTS
66 | value: '-Dmaven.repo.local=/.m2/repository'
67 | - name: username
68 | value: 'user'
69 | - name: password
70 | value: 'password'
71 | - name: admin_password
72 | value: 'password'
73 | - name: uri
74 | value: 'mongodb://localhost'
75 | endpoints:
76 | - name: 'quarkus-dev'
77 | port: 8080
78 | volumes:
79 | - name: m2
80 | containerPath: /.m2
81 |
82 | - alias: git
83 | type: dockerimage
84 | image: sunix/git-devtools
85 | mountSources: true
86 | memoryLimit: 64M
87 | args: ['sleep', 'infinity']
88 |
89 | - mountSources: true
90 | memoryLimit: 64M
91 | type: dockerimage
92 | image: quay.io/sunix/postit-app-dev-data
93 | alias: data
94 | volumes:
95 | - name: m2
96 | containerPath: /work/volumes/.m2
97 |
98 | # Plugins
99 | - id: redhat/quarkus-java11/latest
100 | type: chePlugin
101 |
102 | - id: redhat/vscode-openshift-connector/latest
103 | type: chePlugin
104 | alias: vscode-openshift
105 |
106 | - id: vscode/typescript-language-features/latest
107 | type: chePlugin
108 |
109 | - alias: didact-plugin
110 | type: chePlugin
111 | id: redhat/vscode-didact/latest
112 | preferences:
113 | didact.openDefaultTutorialAtStartup: true
114 | che.welcome.enable: false
115 | didact.defaultUrl: /projects/quarkus-reactjs-postit-app/.che-didact-guide.md
116 | registryUrl: 'https://che-plugin-registry-main.surge.sh/v3'
117 |
118 |
119 | commands:
120 |
121 | - name: start DEVMODE quarkus-backend
122 | actions:
123 | - type: exec
124 | command: pkill java; mvn compile quarkus:dev
125 | component: quarkus-backend-dev
126 | workdir: /projects/quarkus-reactjs-postit-app/quarkus-backend
127 |
128 | # - name: build JVM quarkus-backend
129 | # actions:
130 | # - type: exec
131 | # command: pkill java; mvn package
132 | # component: quarkus-backend-dev
133 | # workdir: /projects/quarkus-reactjs-postit-app/quarkus-backend
134 |
135 | - name: build NATIVE quarkus-backend
136 | actions:
137 | - type: exec
138 | command: "pkill java; mvn package -Dnative -Dmaven.test.skip -Dquarkus.native.native-image-xmx=2G"
139 | component: quarkus-backend-dev
140 | workdir: /projects/quarkus-reactjs-postit-app/quarkus-backend
141 |
142 | - name: start NATIVE quarkus-backend
143 | actions:
144 | - type: exec
145 | command: ./quarkus-backend-1.0.0-SNAPSHOT-runner -Dquarkus.http.host=0.0.0.0
146 | component: quarkus-backend-native-prod
147 | workdir: /projects/quarkus-reactjs-postit-app/quarkus-backend/target
148 |
149 | - name: connect java debugger quarkus-backend
150 | actions:
151 | - type: vscode-launch
152 | referenceContent: |
153 | {
154 | "version": "0.2.0",
155 | "configurations": [
156 | {
157 | "type": "java",
158 | "name": "Debug (Attach) - Remote",
159 | "request": "attach",
160 | "hostName": "localhost",
161 | "port": 5005
162 | }]
163 | }
164 |
165 |
166 | # - name: build PROD node-frontend
167 | # actions:
168 | # - type: exec
169 | # command: tar zxvf /projects/local/node_modules.tar.gz ; rm /projects/local/node_modules.tar.gz ; npm install
170 | # component: node-frontend-dev
171 | # workdir: /projects/quarkus-reactjs-postit-app/node-frontend/
172 |
173 | - name: start DEVMODE node-frontend
174 | actions:
175 | - type: exec
176 | command: npm run devmode
177 | component: node-frontend-dev
178 | workdir: /projects/quarkus-reactjs-postit-app/node-frontend/
179 |
180 | - name: start PROD node-frontend
181 | actions:
182 | - type: exec
183 | command: npm start
184 | component: node-frontend-dev
185 | workdir: /projects/quarkus-reactjs-postit-app/node-frontend/
186 |
187 |
188 | - name: oc - deploy app (quarkus NATIVE) from github
189 | actions:
190 | - type: exec
191 | command: |-
192 | # mongodb
193 | oc new-app -e MONGODB_USER=user -e MONGODB_PASSWORD=password -e MONGODB_DATABASE=sampledb -e MONGODB_ADMIN_PASSWORD=password centos/mongodb-36-centos7 --name=mongo
194 | # s2i quarkus app from source
195 | oc new-app quay.io/quarkus/ubi-quarkus-native-s2i:20.0.0-java8~https://github.com/redhat-developer-demos/quarkus-reactjs-postit-app --name=quarkus-backend --context-dir=quarkus-backend -e uri=mongodb://mongo -e username=user -e password=password
196 | # s2i node frontend from source
197 | oc new-app nodejs~https://github.com/redhat-developer-demos/quarkus-reactjs-postit-app --context-dir=node-frontend --name=node-frontend -e PORT=8080 -e COMPONENT_QUARKUS_BACKEND_HOST=quarkus-backend
198 | oc expose svc/node-frontend
199 | # quarkus native build need more cpu and memory
200 | # wait for quakus-backend build to start and cancel it to reconfigure it
201 | for i in 1 2 3 4 5 6 7 8 9; do
202 | pods="$(oc get build -o go-template='{{range .items}}{{$bc := index .metadata.annotations "openshift.io/build-config.name"}}{{$status := index .status.phase}}{{if eq $bc "quarkus-backend"}}{{if eq $status "Running"}}{{.metadata.name}}{{"\t"}}{{.status.phase}}{{"\n"}}{{end}}{{end}}{{end}}')";
203 | echo $pods;
204 | if [ -n "$pods" ]; then
205 | break;
206 | fi
207 | echo "Waiting for quarkus-backend build to be ready...";
208 | sleep "2";
209 | done
210 | oc cancel-build bc/quarkus-backend
211 | oc patch bc/quarkus-backend -p '{"spec":{"resources":{"limits":{"cpu":"6", "memory":"6Gi"}}}}'
212 | oc start-build quarkus-backend
213 | oc expose svc/quarkus-backend
214 | # labels
215 | oc label deployment mongo app.openshift.io/runtime=mongodb
216 | oc label deployment node-frontend app.openshift.io/runtime=nodejs
217 | oc label deployment quarkus-backend app.openshift.io/runtime=quarkus
218 | # logs
219 | oc logs -f bc/quarkus-backend
220 | oc logs -f bc/node-frontend
221 | echo node-frontend url http://$(oc get route node-frontend --template='{{ .spec.host }}')
222 | component: vscode-openshift
223 | workdir: /projects/quarkus-reactjs-postit-app/node-frontend/
224 |
225 | - name: oc - deploy app (quarkus JVM) from github
226 | actions:
227 | - type: exec
228 | command: |-
229 | # mongodb
230 | oc new-app -e MONGODB_USER=user -e MONGODB_PASSWORD=password -e MONGODB_DATABASE=sampledb -e MONGODB_ADMIN_PASSWORD=password centos/mongodb-36-centos7 --name=mongo
231 | # s2i quarkus app from source
232 | oc new-app java~https://github.com/redhat-developer-demos/quarkus-reactjs-postit-app --name=quarkus-backend --context-dir=quarkus-backend -e uri=mongodb://mongo -e username=user -e password=password --env=JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0"
233 | oc expose svc/quarkus-backend
234 | # s2i node frontend from source
235 | oc new-app nodejs~https://github.com/redhat-developer-demos/quarkus-reactjs-postit-app --context-dir=node-frontend --name=node-frontend -e PORT=8080 -e COMPONENT_QUARKUS_BACKEND_HOST=quarkus-backend
236 | oc expose svc/node-frontend
237 | # labels
238 | oc label deployment mongo app.openshift.io/runtime=mongodb
239 | oc label deployment node-frontend app.openshift.io/runtime=nodejs
240 | oc label deployment quarkus-backend app.openshift.io/runtime=quarkus
241 | # logs
242 | oc logs -f bc/quarkus-backend
243 | oc logs -f bc/node-frontend
244 | echo node-frontend url http://$(oc get route node-frontend --template='{{ .spec.host }}')
245 | component: vscode-openshift
246 | workdir: /projects/quarkus-reactjs-postit-app/node-frontend/
247 |
248 | - name: oc - redeploy quarkus-backend (from local sources)
249 | actions:
250 | - type: exec
251 | command: |-
252 | oc start-build quarkus-backend --from-dir=.
253 | oc logs -f bc/quarkus-backend
254 | component: vscode-openshift
255 | workdir: /projects/quarkus-reactjs-postit-app/
256 |
257 |
258 | - name: oc - redeploy node-frontend (from local sources)
259 | actions:
260 | - type: exec
261 | command: |-
262 | oc start-build node-frontend --from-dir=.
263 | oc logs -f bc/node-frontend
264 |
265 | component: vscode-openshift
266 | workdir: /projects/quarkus-reactjs-postit-app/
267 |
268 |
269 |
270 | - name: oc - scale node-frontend
271 | actions:
272 | - type: exec
273 | command: |-
274 | echo "Scale node-frontend. Enter the number of desired replicas:";
275 | read replicas;
276 | oc scale dc/node-frontend --replicas=${replicas}
277 | component: vscode-openshift
278 | workdir: /projects/quarkus-reactjs-postit-app/
279 |
280 | - name: oc - scale quarkus-backend
281 | actions:
282 | - type: exec
283 | command: |-
284 | echo "Scale quarkus-frontend. Enter the number of desired replicas:";
285 | read replicas;
286 | oc scale dc/quarkus-backend --replicas=${replicas}
287 | component: vscode-openshift
288 | workdir: /projects/quarkus-reactjs-postit-app/
289 |
290 | - name: oc - get node-frontend URL
291 | actions:
292 | - type: exec
293 | command: |-
294 | echo node-frontend url http://$(oc get route node-frontend --template='{{ .spec.host }}')
295 | component: vscode-openshift
296 | workdir: /projects/quarkus-reactjs-postit-app/node-frontend/
297 |
298 |
299 |
300 |
301 |
302 |
303 | - name: oc login
304 | actions:
305 | - type: exec
306 | command: |-
307 | rm oc; curl https://mirror.openshift.com/pub/openshift-v4/clients/oc/latest/linux/oc.tar.gz -s | tar zxv && ./oc login --server=${KUBERNETES_SERVICE_HOST}:443
308 | component: vscode-openshift
309 | workdir: /tmp
310 |
311 | - name: show posts
312 | actions:
313 | - workdir: /tmp
314 | type: exec
315 | command: >-
316 | mongo mongodb://user:password@localhost/sampledb --eval
317 | "printjson(db.getCollection('Posts').find().toArray())"
318 | component: mongo
319 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Eclipse Public License - v 2.0
2 |
3 | THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE
4 | PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION
5 | OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
6 |
7 | 1. DEFINITIONS
8 |
9 | "Contribution" means:
10 |
11 | a) in the case of the initial Contributor, the initial content
12 | Distributed under this Agreement, and
13 |
14 | b) in the case of each subsequent Contributor:
15 | i) changes to the Program, and
16 | ii) additions to the Program;
17 | where such changes and/or additions to the Program originate from
18 | and are Distributed by that particular Contributor. A Contribution
19 | "originates" from a Contributor if it was added to the Program by
20 | such Contributor itself or anyone acting on such Contributor's behalf.
21 | Contributions do not include changes or additions to the Program that
22 | are not Modified Works.
23 |
24 | "Contributor" means any person or entity that Distributes the Program.
25 |
26 | "Licensed Patents" mean patent claims licensable by a Contributor which
27 | are necessarily infringed by the use or sale of its Contribution alone
28 | or when combined with the Program.
29 |
30 | "Program" means the Contributions Distributed in accordance with this
31 | Agreement.
32 |
33 | "Recipient" means anyone who receives the Program under this Agreement
34 | or any Secondary License (as applicable), including Contributors.
35 |
36 | "Derivative Works" shall mean any work, whether in Source Code or other
37 | form, that is based on (or derived from) the Program and for which the
38 | editorial revisions, annotations, elaborations, or other modifications
39 | represent, as a whole, an original work of authorship.
40 |
41 | "Modified Works" shall mean any work in Source Code or other form that
42 | results from an addition to, deletion from, or modification of the
43 | contents of the Program, including, for purposes of clarity any new file
44 | in Source Code form that contains any contents of the Program. Modified
45 | Works shall not include works that contain only declarations,
46 | interfaces, types, classes, structures, or files of the Program solely
47 | in each case in order to link to, bind by name, or subclass the Program
48 | or Modified Works thereof.
49 |
50 | "Distribute" means the acts of a) distributing or b) making available
51 | in any manner that enables the transfer of a copy.
52 |
53 | "Source Code" means the form of a Program preferred for making
54 | modifications, including but not limited to software source code,
55 | documentation source, and configuration files.
56 |
57 | "Secondary License" means either the GNU General Public License,
58 | Version 2.0, or any later versions of that license, including any
59 | exceptions or additional permissions as identified by the initial
60 | Contributor.
61 |
62 | 2. GRANT OF RIGHTS
63 |
64 | a) Subject to the terms of this Agreement, each Contributor hereby
65 | grants Recipient a non-exclusive, worldwide, royalty-free copyright
66 | license to reproduce, prepare Derivative Works of, publicly display,
67 | publicly perform, Distribute and sublicense the Contribution of such
68 | Contributor, if any, and such Derivative Works.
69 |
70 | b) Subject to the terms of this Agreement, each Contributor hereby
71 | grants Recipient a non-exclusive, worldwide, royalty-free patent
72 | license under Licensed Patents to make, use, sell, offer to sell,
73 | import and otherwise transfer the Contribution of such Contributor,
74 | if any, in Source Code or other form. This patent license shall
75 | apply to the combination of the Contribution and the Program if, at
76 | the time the Contribution is added by the Contributor, such addition
77 | of the Contribution causes such combination to be covered by the
78 | Licensed Patents. The patent license shall not apply to any other
79 | combinations which include the Contribution. No hardware per se is
80 | licensed hereunder.
81 |
82 | c) Recipient understands that although each Contributor grants the
83 | licenses to its Contributions set forth herein, no assurances are
84 | provided by any Contributor that the Program does not infringe the
85 | patent or other intellectual property rights of any other entity.
86 | Each Contributor disclaims any liability to Recipient for claims
87 | brought by any other entity based on infringement of intellectual
88 | property rights or otherwise. As a condition to exercising the
89 | rights and licenses granted hereunder, each Recipient hereby
90 | assumes sole responsibility to secure any other intellectual
91 | property rights needed, if any. For example, if a third party
92 | patent license is required to allow Recipient to Distribute the
93 | Program, it is Recipient's responsibility to acquire that license
94 | before distributing the Program.
95 |
96 | d) Each Contributor represents that to its knowledge it has
97 | sufficient copyright rights in its Contribution, if any, to grant
98 | the copyright license set forth in this Agreement.
99 |
100 | e) Notwithstanding the terms of any Secondary License, no
101 | Contributor makes additional grants to any Recipient (other than
102 | those set forth in this Agreement) as a result of such Recipient's
103 | receipt of the Program under the terms of a Secondary License
104 | (if permitted under the terms of Section 3).
105 |
106 | 3. REQUIREMENTS
107 |
108 | 3.1 If a Contributor Distributes the Program in any form, then:
109 |
110 | a) the Program must also be made available as Source Code, in
111 | accordance with section 3.2, and the Contributor must accompany
112 | the Program with a statement that the Source Code for the Program
113 | is available under this Agreement, and informs Recipients how to
114 | obtain it in a reasonable manner on or through a medium customarily
115 | used for software exchange; and
116 |
117 | b) the Contributor may Distribute the Program under a license
118 | different than this Agreement, provided that such license:
119 | i) effectively disclaims on behalf of all other Contributors all
120 | warranties and conditions, express and implied, including
121 | warranties or conditions of title and non-infringement, and
122 | implied warranties or conditions of merchantability and fitness
123 | for a particular purpose;
124 |
125 | ii) effectively excludes on behalf of all other Contributors all
126 | liability for damages, including direct, indirect, special,
127 | incidental and consequential damages, such as lost profits;
128 |
129 | iii) does not attempt to limit or alter the recipients' rights
130 | in the Source Code under section 3.2; and
131 |
132 | iv) requires any subsequent distribution of the Program by any
133 | party to be under a license that satisfies the requirements
134 | of this section 3.
135 |
136 | 3.2 When the Program is Distributed as Source Code:
137 |
138 | a) it must be made available under this Agreement, or if the
139 | Program (i) is combined with other material in a separate file or
140 | files made available under a Secondary License, and (ii) the initial
141 | Contributor attached to the Source Code the notice described in
142 | Exhibit A of this Agreement, then the Program may be made available
143 | under the terms of such Secondary Licenses, and
144 |
145 | b) a copy of this Agreement must be included with each copy of
146 | the Program.
147 |
148 | 3.3 Contributors may not remove or alter any copyright, patent,
149 | trademark, attribution notices, disclaimers of warranty, or limitations
150 | of liability ("notices") contained within the Program from any copy of
151 | the Program which they Distribute, provided that Contributors may add
152 | their own appropriate notices.
153 |
154 | 4. COMMERCIAL DISTRIBUTION
155 |
156 | Commercial distributors of software may accept certain responsibilities
157 | with respect to end users, business partners and the like. While this
158 | license is intended to facilitate the commercial use of the Program,
159 | the Contributor who includes the Program in a commercial product
160 | offering should do so in a manner which does not create potential
161 | liability for other Contributors. Therefore, if a Contributor includes
162 | the Program in a commercial product offering, such Contributor
163 | ("Commercial Contributor") hereby agrees to defend and indemnify every
164 | other Contributor ("Indemnified Contributor") against any losses,
165 | damages and costs (collectively "Losses") arising from claims, lawsuits
166 | and other legal actions brought by a third party against the Indemnified
167 | Contributor to the extent caused by the acts or omissions of such
168 | Commercial Contributor in connection with its distribution of the Program
169 | in a commercial product offering. The obligations in this section do not
170 | apply to any claims or Losses relating to any actual or alleged
171 | intellectual property infringement. In order to qualify, an Indemnified
172 | Contributor must: a) promptly notify the Commercial Contributor in
173 | writing of such claim, and b) allow the Commercial Contributor to control,
174 | and cooperate with the Commercial Contributor in, the defense and any
175 | related settlement negotiations. The Indemnified Contributor may
176 | participate in any such claim at its own expense.
177 |
178 | For example, a Contributor might include the Program in a commercial
179 | product offering, Product X. That Contributor is then a Commercial
180 | Contributor. If that Commercial Contributor then makes performance
181 | claims, or offers warranties related to Product X, those performance
182 | claims and warranties are such Commercial Contributor's responsibility
183 | alone. Under this section, the Commercial Contributor would have to
184 | defend claims against the other Contributors related to those performance
185 | claims and warranties, and if a court requires any other Contributor to
186 | pay any damages as a result, the Commercial Contributor must pay
187 | those damages.
188 |
189 | 5. NO WARRANTY
190 |
191 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT
192 | PERMITTED BY APPLICABLE LAW, THE PROGRAM IS PROVIDED ON AN "AS IS"
193 | BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR
194 | IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF
195 | TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR
196 | PURPOSE. Each Recipient is solely responsible for determining the
197 | appropriateness of using and distributing the Program and assumes all
198 | risks associated with its exercise of rights under this Agreement,
199 | including but not limited to the risks and costs of program errors,
200 | compliance with applicable laws, damage to or loss of data, programs
201 | or equipment, and unavailability or interruption of operations.
202 |
203 | 6. DISCLAIMER OF LIABILITY
204 |
205 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT
206 | PERMITTED BY APPLICABLE LAW, NEITHER RECIPIENT NOR ANY CONTRIBUTORS
207 | SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
208 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST
209 | PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
210 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
211 | ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE
212 | EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE
213 | POSSIBILITY OF SUCH DAMAGES.
214 |
215 | 7. GENERAL
216 |
217 | If any provision of this Agreement is invalid or unenforceable under
218 | applicable law, it shall not affect the validity or enforceability of
219 | the remainder of the terms of this Agreement, and without further
220 | action by the parties hereto, such provision shall be reformed to the
221 | minimum extent necessary to make such provision valid and enforceable.
222 |
223 | If Recipient institutes patent litigation against any entity
224 | (including a cross-claim or counterclaim in a lawsuit) alleging that the
225 | Program itself (excluding combinations of the Program with other software
226 | or hardware) infringes such Recipient's patent(s), then such Recipient's
227 | rights granted under Section 2(b) shall terminate as of the date such
228 | litigation is filed.
229 |
230 | All Recipient's rights under this Agreement shall terminate if it
231 | fails to comply with any of the material terms or conditions of this
232 | Agreement and does not cure such failure in a reasonable period of
233 | time after becoming aware of such noncompliance. If all Recipient's
234 | rights under this Agreement terminate, Recipient agrees to cease use
235 | and distribution of the Program as soon as reasonably practicable.
236 | However, Recipient's obligations under this Agreement and any licenses
237 | granted by Recipient relating to the Program shall continue and survive.
238 |
239 | Everyone is permitted to copy and distribute copies of this Agreement,
240 | but in order to avoid inconsistency the Agreement is copyrighted and
241 | may only be modified in the following manner. The Agreement Steward
242 | reserves the right to publish new versions (including revisions) of
243 | this Agreement from time to time. No one other than the Agreement
244 | Steward has the right to modify this Agreement. The Eclipse Foundation
245 | is the initial Agreement Steward. The Eclipse Foundation may assign the
246 | responsibility to serve as the Agreement Steward to a suitable separate
247 | entity. Each new version of the Agreement will be given a distinguishing
248 | version number. The Program (including Contributions) may always be
249 | Distributed subject to the version of the Agreement under which it was
250 | received. In addition, after a new version of the Agreement is published,
251 | Contributor may elect to Distribute the Program (including its
252 | Contributions) under the new version.
253 |
254 | Except as expressly stated in Sections 2(a) and 2(b) above, Recipient
255 | receives no rights or licenses to the intellectual property of any
256 | Contributor under this Agreement, whether expressly, by implication,
257 | estoppel or otherwise. All rights in the Program not expressly granted
258 | under this Agreement are reserved. Nothing in this Agreement is intended
259 | to be enforceable by any entity that is not a Contributor or Recipient.
260 | No third-party beneficiary rights are created under this Agreement.
261 |
262 | Exhibit A - Form of Secondary Licenses Notice
263 |
264 | "This Source Code may also be made available under the following
265 | Secondary Licenses when the conditions for such availability set forth
266 | in the Eclipse Public License, v. 2.0 are satisfied: {name license(s),
267 | version(s), and exceptions or additional permissions here}."
268 |
269 | Simply including a copy of this Agreement, including this Exhibit A
270 | is not sufficient to license the Source Code under Secondary Licenses.
271 |
272 | If it is not possible or desirable to put the notice in a particular
273 | file, then You may include the notice in a location (such as a LICENSE
274 | file in a relevant directory) where a recipient would be likely to
275 | look for such a notice.
276 |
277 | You may add additional accurate notices of copyright ownership.
278 |
--------------------------------------------------------------------------------
/factory-contribute.svg:
--------------------------------------------------------------------------------
1 |
2 |
15 |
16 |
119 |
--------------------------------------------------------------------------------