Reputation: 3464
I'm trying to build and deploy an app using CLI
and a template taken from an example app.
My steps:
Result:
An app reachable to the outside world (built from the remote github repo source code)
Problem:
It's all good, but I would like to use my own source files located in my current working directory .
As I understand it, in order to do this I need to modify BuildConfig
part of the template.
{
"kind": "BuildConfig",
"apiVersion": "v1",
"metadata": {
"name": "${NAME}",
"annotations": {
"description": "Defines how to build the application",
"template.alpha.openshift.io/wait-for-ready": "true"
}
},
"spec": {
"source": {
"type": "Git",
"git": {
"uri": "${SOURCE_REPOSITORY_URL}",
"ref": "${SOURCE_REPOSITORY_REF}"
},
"contextDir": "${CONTEXT_DIR}"
},
"strategy": {
"type": "Source",
"sourceStrategy": {
"from": {
"kind": "ImageStreamTag",
"namespace": "${NAMESPACE}",
"name": "nodejs:6"
},
"env": [
{
"name": "NPM_MIRROR",
"value": "${NPM_MIRROR}"
}
]
}
},
"output": {
"to": {
"kind": "ImageStreamTag",
"name": "${NAME}:latest"
}
},
"triggers": [
{
"type": "ImageChange"
},
{
"type": "ConfigChange"
},
{
"type": "GitHub",
"github": {
"secret": "${GITHUB_WEBHOOK_SECRET}"
}
},
{
"type": "Generic",
"generic": {
"secret": "${GENERIC_WEBHOOK_SECRET}"
}
}
],
"postCommit": {
"script": "npm test"
}
}
}
Can you please help me edit this file?
Upvotes: 0
Views: 881
Reputation: 426
As far as I can see you are developing for nodejs:
A possible solution is to build (aka do all npm stuff) on your local machine (to skip the assemble phase in the s2i build container) then start with a binary source deployment [1][2].
You can do this with these steps:
oc new-app <IMAGE-NAME>~/tmp/nocontent --name=<APPLICATION_NAME>
oc start-build <APPLICATION_NAME> --from-dir=<PATH_TO_DIR>/my-built-app
The <PATH_TO_DIR>/my-built-app
dir has to contain the binary (or javascript files) on the root.
The command will stream files to a new build container in openshift (this works also on minishift).
You can also do more customization adding a .s2i dir in the <PATH_TO_DIR>/my-built-app
eg: <PATH_TO_DIR>/my-built-app/.s2i
[3]
Note: You have to read documentation and/or explore a pod of your s2i image to know where the files should be placed and where the files are moved by the s2i default scripts shipped with the images itself.
[2]:https://docs.openshift.com/container-platform/3.6/dev_guide/builds/basic_build_operations.html
Upvotes: 1