diff --git a/DockerStandaloneHost/package/Classes/DockerStandaloneHost.yaml b/DockerStandaloneHost/package/Classes/DockerStandaloneHost.yaml index 58ed9d6..2919642 100644 --- a/DockerStandaloneHost/package/Classes/DockerStandaloneHost.yaml +++ b/DockerStandaloneHost/package/Classes/DockerStandaloneHost.yaml @@ -31,6 +31,9 @@ Properties: dockerRegistry: Contract: $.string() + dockerMirror: + Contract: $.string() + applicationEndpoints: Contract: - port: $.int().notNull().check($ > 0) @@ -65,11 +68,13 @@ Methods: - $resources: new(sys:Resources) - $template: $resources.yaml('StartDocker.template') - $.instance.agent.call($template, $resources) - - If: $.dockerRegistry != null and $.dockerRegistry != '' + - If: $.dockerMirror != null and $.dockerMirror != '' + or $.dockerRegistry != null and $.dockerRegistry != '' Then: - - $._environment.reporter.report($this, 'Configuring Docker registry') - - $template: $resources.yaml('SetupDockerRegistry.template').bind(dict( - dockerRegistry => $.dockerRegistry + - $._environment.reporter.report($this, 'Configuring Docker options') + - $template: $resources.yaml('SetupDockerOptions.template').bind(dict( + dockerRegistry => $.dockerRegistry, + dockerMirror => $.dockerMirror )) - $.instance.agent.call($template, $resources) - $._environment.reporter.report($this, 'Docker Server is up and running') diff --git a/DockerStandaloneHost/package/Resources/SetupDockerOptions.template b/DockerStandaloneHost/package/Resources/SetupDockerOptions.template new file mode 100644 index 0000000..e53df4e --- /dev/null +++ b/DockerStandaloneHost/package/Resources/SetupDockerOptions.template @@ -0,0 +1,53 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +FormatVersion: 2.0.0 +Version: 1.0.0 +Name: Setup Docker options + +Parameters: + dockerRegistry: $dockerRegistry + dockerMirror: $dockerMirror + +Body: | + if args.dockerRegistry: + setupRegistry(args.dockerRegistry) + if args.dockerMirror: + setupMirror(args.dockerMirror) + restartDocker() + +Scripts: + setupMirror: + Type: Application + Version: 1.0.0 + EntryPoint: setupDockerMirror.sh + Files: [] + Options: + captureStdout: true + captureStderr: true + + setupRegistry: + Type: Application + Version: 1.0.0 + EntryPoint: setupDockerRegistry.sh + Files: [] + Options: + captureStdout: true + captureStderr: true + + restartDocker: + Type: Application + Version: 1.0.0 + EntryPoint: restartDocker.sh + Options: + captureStdout: false + captureStderr: false \ No newline at end of file diff --git a/DockerStandaloneHost/package/Resources/SetupDockerRegistry.template b/DockerStandaloneHost/package/Resources/scripts/restartDocker.sh similarity index 61% rename from DockerStandaloneHost/package/Resources/SetupDockerRegistry.template rename to DockerStandaloneHost/package/Resources/scripts/restartDocker.sh index 7203ac1..1e14364 100644 --- a/DockerStandaloneHost/package/Resources/SetupDockerRegistry.template +++ b/DockerStandaloneHost/package/Resources/scripts/restartDocker.sh @@ -1,3 +1,4 @@ +#!/bin/bash # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at @@ -10,22 +11,4 @@ # License for the specific language governing permissions and limitations # under the License. -FormatVersion: 2.0.0 -Version: 1.0.0 -Name: Setup Docker registry - -Parameters: - dockerRegistry: $dockerRegistry - -Body: | - setupRegistry(args.dockerRegistry) - -Scripts: - setupRegistry: - Type: Application - Version: 1.0.0 - EntryPoint: setupDockerRegistry.sh - Files: [] - Options: - captureStdout: true - captureStderr: true +service docker restart \ No newline at end of file diff --git a/DockerStandaloneHost/package/Resources/scripts/setupDockerMirror.sh b/DockerStandaloneHost/package/Resources/scripts/setupDockerMirror.sh new file mode 100644 index 0000000..32cf7b8 --- /dev/null +++ b/DockerStandaloneHost/package/Resources/scripts/setupDockerMirror.sh @@ -0,0 +1,16 @@ +#!/bin/bash +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +source /etc/default/docker +DOCKER_OPTS+=" --registry-mirror=$1" +echo DOCKER_OPTS=\"$DOCKER_OPTS\" > /etc/default/docker \ No newline at end of file diff --git a/DockerStandaloneHost/package/Resources/scripts/setupDockerRegistry.sh b/DockerStandaloneHost/package/Resources/scripts/setupDockerRegistry.sh index ce83221..36f1950 100644 --- a/DockerStandaloneHost/package/Resources/scripts/setupDockerRegistry.sh +++ b/DockerStandaloneHost/package/Resources/scripts/setupDockerRegistry.sh @@ -12,7 +12,5 @@ # under the License. source /etc/default/docker -DOCKER_OPTS+=" --registry-mirror=$1" -echo DOCKER_OPTS=\"$DOCKER_OPTS\" > /etc/default/docker - -service docker restart \ No newline at end of file +DOCKER_OPTS+=" --insecure-registry $1" +echo DOCKER_OPTS=\"$DOCKER_OPTS\" > /etc/default/docker \ No newline at end of file diff --git a/DockerStandaloneHost/package/UI/ui.yaml b/DockerStandaloneHost/package/UI/ui.yaml index adad88e..e3d1d84 100644 --- a/DockerStandaloneHost/package/UI/ui.yaml +++ b/DockerStandaloneHost/package/UI/ui.yaml @@ -17,6 +17,7 @@ Application: type: io.murano.apps.docker.DockerStandaloneHost name: $.appConfiguration.name dockerRegistry: $.appConfiguration.dockerRegistry + dockerMirror: $.appConfiguration.dockerMirror instance: ?: type: io.murano.resources.LinuxMuranoInstance @@ -53,7 +54,13 @@ Forms: type: string label: Custom Docker registry URL description: >- - URL of docker repository mirror to use. Leave empty for Docker default + Host IP or domain name of custom Docker registry to use. Leave empty for Docker default + required: false + - name: dockerMirror + type: string + label: Docker registry mirror URL + description: >- + URL of Docker registry mirror to use. Leave empty to not use one required: false - instanceConfiguration: