forked from ou-developers/oci-helm-node-service
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_spec.yaml
102 lines (92 loc) · 2.99 KB
/
build_spec.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
version: 0.1
component: build
timeoutInSeconds: 6000
runAs: root
shell: bash
env:
# these are local variables to the build config
variables:
key: "value"
# the value of a vaultVariable is the secret-id (in OCI ID format) stored in the OCI Vault service
# you can then access the value of that secret in your build_spec.yaml commands
vaultVariables:
# exportedVariables are made available to use as parameters in sucessor Build Pipeline stages
# For this Build to run, the Build Pipeline needs to have a BUILDRUN_HASH parameter set
exportedVariables:
- BUILDRUN_HASH
steps:
- type: Command
name: "Define unique image tag"
timeoutInSeconds: 40
command: |
export BUILDRUN_HASH=`echo ${OCI_BUILD_RUN_ID} | rev | cut -c 1-7`
echo "BUILDRUN_HASH: " $BUILDRUN_HASH
- type: Command
timeoutInSeconds: 600
name: "Install Node Prereqs"
command: |
cd ${OCI_WORKSPACE_DIR}
ls
cd ${OCI_WORKSPACE_DIR}/node_express
ls
# install nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
nvm install lts/erbium
echo "NODE VERSION: $(node -v)"
echo "NPM VERSION: $(npm -v)"
onFailure:
- type: Command
command: |
echo "Handling Failure"
echo "Failure successfully handled"
timeoutInSeconds: 40
runAs: root
- type: Command
timeoutInSeconds: 600
name: "NPM install"
command: |
cd ${OCI_WORKSPACE_DIR}/node_express
npm install
onFailure:
- type: Command
command: |
echo "Handling Failure"
echo "Failure successfully handled"
timeoutInSeconds: 40
runAs: root
- type: Command
timeoutInSeconds: 1200
name: "Run Tests"
command: |
cd ${OCI_WORKSPACE_DIR}/node_express
ls
npm test
- type: Command
timeoutInSeconds: 1200
name: "Helm Build"
command: |
pwd
cd ${OCI_WORKSPACE_DIR}/node_express/helm/node-service
export BUILDRUN_HASH=${BUILDRUN_HASH}
originalChartfile="Chart.yaml"
tmpChartfile=$(mktemp)
cp --attributes-only --preserve $originalChartfile $tmpChartfile
cat $originalChartfile | envsubst > $tmpChartfile && mv $tmpChartfile $originalChartfile
cat Chart.yaml
helm package .
helm registry login ${HELM_REPO} -u ${HELM_REPO_USER} -p ${USER_AUTH_TOKEN}
helm push *.tgz ${HELM_REPO_URL}
- type: Command
timeoutInSeconds: 1200
name: "Build container image"
command: |
cd ${OCI_WORKSPACE_DIR}/node_express
docker build --pull --rm -t iad-dop-lab18-1-ocir-1/node-service-<userID> .
outputArtifacts:
- name: APPLICATION_DOCKER_IMAGE
type: DOCKER_IMAGE
# this location tag doesn't effect the tag used to deliver the container image
# to the Container Registry
location: iad-dop-lab18-1-ocir-1/node-service-<userID>:latest