Skip to content
This repository was archived by the owner on Jan 18, 2025. It is now read-only.

Commit d1041bf

Browse files
committed
More documentation.
Added reload feature to install script.
1 parent 8f4a080 commit d1041bf

File tree

3 files changed

+59
-7
lines changed

3 files changed

+59
-7
lines changed

README.md

+43-2
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@ You can just create you component(s) through any development process you'll like
126126

127127
Before creating the zipfile, you need to build your docker image with the correct labels on them.
128128

129+
***
130+
*note: You can install this docker image directly as an asset into the platform, bypassing the whole quarantine registry. This is a good way to test the labels. Skip directly to [Install asset locally](#installLocally) for this.
131+
***
132+
133+
129134
#### Create asset zipfile
130135

131136
To facilitate the creation of the zipfile for distributing the assets, the platform provides a tool, called `label2manifest.js`, which you can find in the root folder of the source distribution and/or in the *tools* folder of the binary distribution.
@@ -175,7 +180,7 @@ The script will create a zipfile in the folder where you run the script, called
175180
176181
#### Deploy asset to local quarantine registry
177182
In the final setup of the platform, all assets will be installed from the vf-OS Store, by downloading, checking, intermediate storing in the quarantine registry, and installation of the asset into the local docker environment. This is a complex, multi-step process that is annoying and slow during development testing.
178-
To ease this for developers, a script is provided that bypasses many of these steps and can deploy the asset from the zipfile, directly into the quarantine repository. This script is called *manifest2label.js* to mimic it's mirror counterpart.
183+
To ease this for developers, a script is provided that bypasses many of these steps and can deploy the asset from the zipfile, directly into the quarantine repository. This script is called *manifest2label.js* to mimic it's mirror counterpart. This script is provided in the tools folder of the binary distribution, and requires running *npm install* for it's dependencies.
179184
180185
```shell
181186
user@host:~/platform$ manifest2label.js $PWD/asset-c.zip true true
@@ -203,6 +208,42 @@ manifest2label <fullPath2zipfile> [<deleteArtifacts>] [<push2Repos>] [<registryH
203208
#### Deploy asset to vf-OS Store
204209
TODO
205210
206-
#### Install asset locally
211+
#### <a name="installLocally"></a>Install asset locally
212+
213+
To get the asset from the local quarantine registry into the actual running platform, requires the generation of the docker-compose file for this asset. This can be done through the REST API of the platform, but to simplify this a script *installAsset.js* is provided that does this. This script is provided in the tools folder of the binary distribution, and requires running *npm install* for it's dependencies.
214+
215+
***
216+
*note: You can also install an Asset directly from your local docker daemon, bypassing the whole quarantine registry. In the example below, you don't include the 'localhost:5000/' part for such images. (Just use the local imageid)
217+
***
218+
219+
Before running the script the platform should be running, to provide access to the registry. Run the script like:
207220
221+
```shell
222+
user@host:~/platform$ installAsset.js localhost:5000/asset-a true
223+
Got metadata from docker image: localhost:5000/asset-c
224+
Platform reloaded.
225+
user@host:~/platform$ ls .compose
226+
0_platform_compose.yml 1_networks_compose.yml 3_asset-c_compose.yml docker-compose
227+
user@host:~/platform$ docker container list
228+
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
229+
ccb18f1062d8 localhost:5000/vfos/deploy "/usr/src/app/entryp…" 23 seconds ago Up 19 seconds 9000/tcp vfos_deployment_1
230+
7cda48ac56a4 localhost:5000/vfos/system-dashboard "npm start" 23 seconds ago Up 18 seconds 9000/tcp vfos_dashboard_1
231+
067dd4ec6b0a localhost:5000/vfos/test-server "npm start" 23 seconds ago Up 15 seconds 9000/tcp vfos_testserver_1
232+
0afa60d16778 localhost:5000/vfos/exec-manager "npm start" 23 seconds ago Up 17 seconds 9000/tcp vfos_execution-manager_1
233+
f16f1a26a87c localhost:5000/asset-c "npm start" 23 seconds ago Up 15 seconds 9001/tcp vfos_asset-c_1
234+
789b38d393a8 localhost:5000/vfos/aim "/opt/jboss/tools/do…" 23 seconds ago Up 20 seconds 8080/tcp vfos_aim_1
235+
91187164867b localhost:5000/vfos/portal "npm start" 23 seconds ago Up 21 seconds 9000/tcp vfos_portal_1
236+
c06837648ca6 traefik:latest "/traefik --api --do…" 23 seconds ago Up 12 seconds 0.0.0.0:80->80/tcp, 0.0.0.0:8080->8080/tcp vfos_reverse-proxy_1
237+
f53130f4f819 registry:2 "/entrypoint.sh /etc…" About an hour ago Up About an hour 0.0.0.0:5000->5000/tcp vfos_registry_1
238+
2bfa81621399 docker/compose:1.22.0 "/bin/sh -c 'cat /de…" About an hour ago Up About an hour vf_os_platform_exec_control
239+
```
240+
As you can see in the example, the script creates a docker-compose file, called *3_assetId_compose.yml* which is included by the reload of the platform.
208241
242+
There are four parameters to this script:
243+
``` shell
244+
installAsset.js <imageUrl> [<reload>] [<targetFolder>] [<volumesFolder>]
245+
```
246+
* imageUrl: The imageId or url to the registry imageId.
247+
* reload: Should the platform reload its configfiles? (Basically running *docker-compose up*) Simple *true* or *false* parameter, defaults to *false*.
248+
* targetFolder: Path to the folder where the compose file needs to be generated. Defaults to $PWD/.compose.
249+
* volumesFolder: Absolute path in the host to the folder where the host side of volume mounts needs to be placed. Defaults to $PWD/.persist.

deploy.sh

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ cp stop.sh vfosPlatform/
1515
cp start.sh vfosPlatform/
1616

1717
cp label2manifest.js vfosPlatform/tools/
18+
cp manifest2label.js vfosPlatform/tools/
1819
cp installAsset.js vfosPlatform/tools/
1920
cp package.json vfosPlatform/tools/
2021

installAsset.js

+15-5
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ const exec = require('child_process').exec
55
const fs = require('fs')
66

77
let dockerImage = process.argv[2]
8-
let folder = process.argv[3]
9-
let volumeFolder = process.argv[4] ? process.argv[4] : process.cwd() + '/.persist/'
8+
let reload = process.argv[3] ? process.argv[3] : false
9+
let folder = process.argv[4] ? process.argv[4] : process.cwd() + '/.compose/'
10+
let volumeFolder = process.argv[5] ? process.argv[5] : process.cwd() + '/.persist/'
1011
if (!volumeFolder.endsWith('/')) volumeFolder += '/'
1112

12-
if (!dockerImage && process.argv.length < 4) {
13-
console.log('Call this script as: ' + process.argv[1] + ' <dockerImage> <targetFolder> <volumesFolder>')
13+
if (!dockerImage && process.argv.length < 3) {
14+
console.log('Call this script as: ' + process.argv[1] + ' <dockerUrl> [<reload>] [<targetFolder>] [<volumesFolder>]')
1415
process.exit(1)
1516
}
1617
let imageFile = dockerImage.replace(/.*\//gi, '')
@@ -119,8 +120,17 @@ new Promise((resolve, reject) => {
119120

120121
// Generate docker-compose file for this asset into folder
121122
fs.writeFileSync(folder + '/3_' + imageFile + '_compose.yml', 'version: "3"\nservices:\n ' + services)
123+
// If parameter: call docker-compose image to reload asset
124+
if (reload) {
125+
exec('docker exec vf_os_platform_exec_control docker-compose up -d', (error, stdout, stderr) => {
126+
if (error) {
127+
console.log('Failed to reload the platform.', stderr)
128+
} else {
129+
console.log('Platform reloaded.', stdout)
130+
}
131+
})
132+
}
122133
}
123-
// If parameter: call docker-compose image to reload asset
124134
})
125135
}).catch((e) => {
126136
console.error('failed to pull image', e)

0 commit comments

Comments
 (0)