Add offline install script

This commit is contained in:
Mihaela Blendea
2019-04-12 14:56:38 -07:00
parent d2f2834644
commit 0dbe872343
2 changed files with 125 additions and 0 deletions
@@ -0,0 +1,39 @@
# Push SQL Server big data cluster Docker images to your own private Docker repository
Big data clusters must have access to a Docker repository from which to pull container images. If you need to deploy to an environment that can't access the registry provided by Microsoft, you need to first push necessary images to your own private repository that the environment can access. This repository is then used as the target for a new deployment.
Using this sample Python script, you can pull all images from the Microsoft repository to your local Docker environment, and then push them to your own private repo.
## Prerequisites
- Docker Engine 1.8+ on any supported Linux distribution or Docker for Mac/Windows. For more information, see [Install Docker](https://docs.docker.com/engine/installation/).
- Running the script will require: Python minimum version 3.0
## Instructions
Run the script using:
```
python push-bdc-images-to-custom-private-repo.py
```
>**Note**
>
>If you have both python3 and python2 on your client machine and in the path, you will have to run the command using python3:
>```
>python3 push-bdc-images-to-custom-private-repo.py
>```
When prompted, provide your input for:
- Docker registry, repository and credentials to access Microsoft private registry where the images will be pulled from (source)
- Docker registry, repository and credentials to access your private registry where the images will be pushed to (target)
## Deploy with from your private repository
To deploy from your private repository, use the steps described in the [deployment guide](deployment-guidance.md), but customize the following environment variables to match your private Docker repository.
- **DOCKER_REGISTRY**
- **DOCKER_REPOSITORY**
- **DOCKER_USERNAME**
- **DOCKER_PASSWORD**
- **DOCKER_EMAIL**
- **DOCKER_IMAGE_TAG**
@@ -0,0 +1,86 @@
# requires installation of Docker: https://docs.docker.com/install/
from subprocess import check_output, CalledProcessError, STDOUT, Popen, PIPE
import os
import getpass
def execute_cmd (cmd):
if os.name=="nt":
process = Popen(cmd.split(),stdin=PIPE, shell=True)
else:
process = Popen(cmd.split(),stdin=PIPE)
stdout, stderr = process.communicate()
if (stderr is not None):
raise Exception(stderr)
SOURCE_DOCKER_REGISTRY = input("Provide Docker registry source - press ENTER for using `private-repo.microsoft.com`:") or "private-repo.microsoft.com"
SOURCE_DOCKER_REPOSITORY = input("Provide Docker repository source - press ENTER for using `mssql-private-preview`:") or "mssql-private-preview"
SOURCE_DOCKER_USERNAME = input("Provide Docker username for the source registry:")
SOURCE_DOCKER_PASSWORD=getpass.getpass("Provide Docker password for the source registry:")
SOURCE_DOCKER_TAG = input("Provide Docker tag for the images at the source: ") or "latest"
TARGET_DOCKER_REGISTRY = input("Provide Docker registry target:")
TARGET_DOCKER_REPOSITORY = input("Provide Docker repository target:")
TARGET_DOCKER_USERNAME = input("Provide Docker username for the target registry:")
TARGET_DOCKER_PASSWORD = getpass.getpass("Provide Docker password for the target registry:")
TARGET_DOCKER_TAG = input("Provide Docker tag for the images at the target: ") or "latest"
images = [ 'mssql-appdeploy-init',
'mssql-monitor-fluentbit',
'mssql-monitor-collectd',
'mssql-server-data',
'mssql-hadoop',
'mssql-java',
'mssql-mlservices-pythonserver',
'mssql-mlservices-rserver',
'mssql-monitor-elasticsearch',
'mssql-monitor-influxdb',
'mssql-security-knox',
'mssql-mlserver-r-runtime',
'mssql-mlserver-py-runtime',
'mssql-controller',
'mssql-portal',
'mssql-server-controller',
'mssql-monitor-grafana',
'mssql-monitor-kibana',
'mssql-service-proxy',
'mssql-app-service-proxy',
'mssql-ssis-app-runtime',
'mssql-monitor-telegraf']
print("Execute docker login to source registry: " + SOURCE_DOCKER_REGISTRY)
cmd = "docker login " + SOURCE_DOCKER_REGISTRY + " -u " + SOURCE_DOCKER_USERNAME + " -p " + SOURCE_DOCKER_PASSWORD
execute_cmd(cmd)
print("")
print("Pulling images from source repository: " + SOURCE_DOCKER_REGISTRY + "/" + SOURCE_DOCKER_REPOSITORY)
cmd = ""
for image in images:
cmd += "docker pull " + SOURCE_DOCKER_REGISTRY + "/" + SOURCE_DOCKER_REPOSITORY + "/" + image + ":" + SOURCE_DOCKER_TAG + " & "
cmd = cmd[:len(cmd)-3]
execute_cmd(cmd)
print("Execute docker login to target registry:" + TARGET_DOCKER_REGISTRY)
cmd = "docker login " + TARGET_DOCKER_REGISTRY + " -u " + TARGET_DOCKER_USERNAME + " -p " + TARGET_DOCKER_PASSWORD
execute_cmd(cmd)
print("")
print("Tagging local images...")
cmd = ""
for image in images:
cmd += "docker tag " + SOURCE_DOCKER_REGISTRY + "/" + SOURCE_DOCKER_REPOSITORY + "/" + image + ":" + SOURCE_DOCKER_TAG + " " + TARGET_DOCKER_REGISTRY + "/" + TARGET_DOCKER_REPOSITORY + "/" + image + ":" + TARGET_DOCKER_TAG + " & "
cmd = cmd[:len(cmd)-3]
execute_cmd(cmd)
print("Push images to target Docker repository: " + TARGET_DOCKER_REGISTRY + "/" + TARGET_DOCKER_REPOSITORY)
cmd = ""
for image in images:
cmd += "docker push " + TARGET_DOCKER_REGISTRY + "/" + TARGET_DOCKER_REPOSITORY + "/" + image + ":" + TARGET_DOCKER_TAG + " & "
cmd = cmd[:len(cmd)-3]
execute_cmd(cmd)
print("Images are now pushed to the target repository.")
cmd = "docker images"
execute_cmd(cmd)