Skip to content

Commit 3b412c3

Browse files
Merge branch 'main' into virkam-changes
2 parents 28aa80a + 783a80f commit 3b412c3

File tree

5 files changed

+177
-0
lines changed

5 files changed

+177
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<!--
2+
Copyright (c) 2024 Oracle and/or its affiliates.
3+
4+
The Universal Permissive License (UPL), Version 1.0
5+
6+
Subject to the condition set forth below, permission is hereby granted to any
7+
person obtaining a copy of this software, associated documentation and/or data
8+
(collectively the "Software"), free of charge and under any and all copyright
9+
rights in the Software, and any and all patent rights owned or freely
10+
licensable by each licensor hereunder covering either (i) the unmodified
11+
Software as contributed to or provided by such licensor, or (ii) the Larger
12+
Works (as defined below), to deal in both
13+
14+
(a) the Software, and
15+
(b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
16+
one is included with the Software (each a "Larger Work" to which the Software
17+
is contributed by such licensors),
18+
19+
without restriction, including without limitation the rights to copy, create
20+
derivative works of, display, perform, and distribute the Software and make,
21+
use, sell, offer for sale, import, export, have made, and have sold the
22+
Software and the Larger Work(s), and to sublicense the foregoing rights on
23+
either these or other terms.
24+
25+
This license is subject to the following condition:
26+
The above copyright notice and either this complete permission notice or at
27+
a minimum a reference to the UPL must be included in all copies or
28+
substantial portions of the Software.
29+
30+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
31+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
32+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
33+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
34+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
35+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
36+
SOFTWARE.
37+
-->
38+
39+
### Guide
40+
41+
Please see the <a href="https://medium.com/@mika.rinne/ci-cd-for-nodejs-on-oci-without-kubernetes-a6f94b4b2948">setup guide on Medium</a>.
42+
43+
### License
44+
45+
Copyright (c) 2024 Oracle and/or its affiliates.
46+
47+
Licensed under the Universal Permissive License (UPL), Version 1.0.
48+
49+
See [LICENSE](https://github.com/oracle-devrel/technology-engineering/blob/main/LICENSE) for more details.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
version: 0.1
2+
component: build
3+
timeoutInSeconds: 180
4+
shell: bash
5+
failImmediatelyOnError: true
6+
env:
7+
exportedVariables:
8+
- buildId
9+
steps:
10+
- type: Command
11+
name: "create build-id for the artifact"
12+
command: |
13+
buildId=`echo ${OCI_BUILD_RUN_ID} | rev | cut -c 1-6 | rev`
14+
echo "Build ID: $buildId"
15+
- type: Command
16+
name: "build and run NodeJS app, create zip artifact if runs ok"
17+
command: |
18+
cd source
19+
npm install
20+
npm start &
21+
sleep 2
22+
res=$(curl -s localhost:5000)
23+
echo ">>>> $res"
24+
cd ..
25+
zip -q -r nodejs.zip source
26+
outputArtifacts:
27+
- name: nodejs
28+
type: BINARY
29+
location: ./nodejs.zip
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
version: 1.0
2+
component: deployment
3+
runAs: ocarun
4+
env:
5+
variables:
6+
version: ${buildId}
7+
files:
8+
- source: /nodejs.zip
9+
destination: /tmp
10+
steps:
11+
- stepType: Command
12+
name: kill NodeJS
13+
command: "pkill -f 'node /home/opc/source/server.js'"
14+
timeoutInSeconds: 60
15+
runAs: root
16+
- stepType: Command
17+
name: copy NodeJS
18+
command: "cp /tmp/nodejs.zip /home/opc/nodejs.zip"
19+
timeoutInSeconds: 60
20+
runAs: root
21+
- stepType: Command
22+
name: cd to home
23+
command: "cd /home/opc"
24+
timeoutInSeconds: 60
25+
runAs: root
26+
- stepType: Command
27+
name: unzip
28+
command: "unzip -o nodejs.zip -d /home/opc"
29+
timeoutInSeconds: 60
30+
runAs: root
31+
- stepType: Command
32+
name: start NodeJS
33+
command: "nohup node /home/opc/source/server.js &"
34+
timeoutInSeconds: 60
35+
runAs: root
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "node",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "server.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1",
8+
"start": "node server.js"
9+
},
10+
"author": "",
11+
"license": "ISC",
12+
"dependencies": {
13+
"express": "^4.18.2"
14+
}
15+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
Copyright (c) 2024 Oracle and/or its affiliates.
3+
4+
The Universal Permissive License (UPL), Version 1.0
5+
6+
Subject to the condition set forth below, permission is hereby granted to any
7+
person obtaining a copy of this software, associated documentation and/or data
8+
(collectively the "Software"), free of charge and under any and all copyright
9+
rights in the Software, and any and all patent rights owned or freely
10+
licensable by each licensor hereunder covering either (i) the unmodified
11+
Software as contributed to or provided by such licensor, or (ii) the Larger
12+
Works (as defined below), to deal in both
13+
14+
(a) the Software, and
15+
(b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
16+
one is included with the Software (each a "Larger Work" to which the Software
17+
is contributed by such licensors),
18+
19+
without restriction, including without limitation the rights to copy, create
20+
derivative works of, display, perform, and distribute the Software and make,
21+
use, sell, offer for sale, import, export, have made, and have sold the
22+
Software and the Larger Work(s), and to sublicense the foregoing rights on
23+
either these or other terms.
24+
25+
This license is subject to the following condition:
26+
The above copyright notice and either this complete permission notice or at
27+
a minimum a reference to the UPL must be included in all copies or
28+
substantial portions of the Software.
29+
30+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
31+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
32+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
33+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
34+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
35+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
36+
SOFTWARE.
37+
*/
38+
39+
const express = require('express')
40+
const app = express()
41+
const port = 5000
42+
43+
app.get('/', (req, res) => {
44+
res.send('Hello from NodeJS on OCI <3')
45+
})
46+
47+
app.listen(port, () => {
48+
console.log(`Listening on port ${port}`)
49+
})

0 commit comments

Comments
 (0)