Move bootstrap container to python 3 03/116803/1 3.0.0
authorJack Lucas <jflos@sonoris.net>
Wed, 13 Jan 2021 17:50:10 +0000 (12:50 -0500)
committerJack Lucas <jflos@sonoris.net>
Wed, 13 Jan 2021 17:50:10 +0000 (12:50 -0500)
Move to an Alpine python base image and install
a Python 3 version of the Cloudify CLI.
Also remove loading of k8s plugin configurations.
(Will move to CM via an init container.)

Issue-ID: DCAEGEN2-2543
Issue-ID: DCAEGEN2-2582
Signed-off-by: Jack Lucas <jflos@sonoris.net>
Change-Id: I6d147bbbce863ee8e04d2bd70d7189dc63fa9950

Dockerfile [moved from Dockerfile-template with 66% similarity]
pom.xml
scripts/bootstrap.sh

similarity index 66%
rename from Dockerfile-template
rename to Dockerfile
index 6bf6bfb..51c704c 100644 (file)
@@ -2,6 +2,7 @@
 # org.onap.dcae
 # ================================================================================
 # Copyright (c) 2018-2020 AT&T Intellectual Property. All rights reserved.
+# Copyright (c) 2021 J. F. Lucas.  All rights reserved.
 # ================================================================================
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # limitations under the License.
 # ============LICENSE_END=========================================================
 
-FROM centos:7.4.1708
-LABEL maintainer="maintainer"
+# cloudify CLI requires python 3.6
+# won't work with 3.7 or later, hence won't work
+# with the ONAP integration-python base images
+FROM python:3.6-alpine
+LABEL maintainer="ONAP DCAE Team"
+LABEL Description="DCAE bootstrap image"
 
-# Install gcc
-RUN yum install -y gcc python-devel
+ARG user=onap
+ARG group=onap
+
+# Install packages needed for cloudify and for running bootstrap script
+RUN apk --no-cache add build-base libffi-dev openssl-dev curl bash
 
 # Install jq
 RUN curl -Ssf -L "https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64"  > /bin/jq \
 && chmod +x /bin/jq
 
 # Install pip and Cloudify CLI
-RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py \
-  && python get-pip.py \
-  && rm get-pip.py \
-  && pip install cloudify==20.03.03
+RUN pip install cloudify==5.1.1
 
 # Copy scripts
 RUN mkdir scripts
@@ -45,9 +50,10 @@ ENTRYPOINT exec "/scripts/bootstrap.sh"
 # Make scripts executable & set up a non-root user
 RUN chmod +x /scripts/*.sh \
   && mkdir -p /opt/bootstrap \
-  && useradd -d /opt/bootstrap bootstrap \
-  && chown -R bootstrap:bootstrap /opt/bootstrap \
-  && chown -R bootstrap:bootstrap /scripts \
-  && chown -R bootstrap:bootstrap /blueprints
+  && addgroup -S $group \
+  && adduser -S -D -h /opt/bootstrap -s /bin/bash $user $group \
+  && chown -R $user:$group /opt/bootstrap \
+  && chown -R $user:$group /scripts \
+  && chown -R $user:$group /blueprints
 
-USER bootstrap
+USER $user
diff --git a/pom.xml b/pom.xml
index a3958ff..c3ad56f 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -29,7 +29,7 @@ ECOMP is a trademark and service mark of AT&T Intellectual Property.
   <groupId>org.onap.dcaegen2.deployments</groupId>
   <artifactId>k8s-bootstrap-container</artifactId>
   <name>dcaegen2-deployments-k8s-bootstrap-container</name>
-  <version>2.2.4-SNAPSHOT</version>
+  <version>3.0.0-SNAPSHOT</version>
   <url>http://maven.apache.org</url>
   <packaging>pom</packaging>
 
index 9cd69c8..8089439 100755 (executable)
@@ -1,6 +1,7 @@
 #!/bin/bash
 # ================================================================================
 # Copyright (c) 2018-2020 AT&T Intellectual Property. All rights reserved.
+# Copyright (c) 2021 J. F. Lucas. All rights reserved.
 # ================================================================================
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 #   CM password in CMPASS environment variable (assumes user is "admin")
 #   ONAP common Kubernetes namespace in ONAP_NAMESPACE environment variable
 #   If DCAE components are deployed in a separate Kubernetes namespace, that namespace in DCAE_NAMESPACE variable.
-#   Consul address with port in CONSUL variable
-#      Blueprints for components to be installed in /blueprints
+#   Blueprints for components to be installed in /blueprints
 #   Input files for components to be installed in /inputs
-#   Configuration JSON files that need to be loaded into Consul in /dcae-configs
-#   Consul is installed in /opt/consul/bin/consul, with base config in /opt/consul/config/00consul.json
 # Optionally, allows:
 #   CM protocol in CMPROTO environment variable (defaults to HTTP)
 #   CM port in CMPORT environment variable (defaults to 80)
@@ -137,16 +135,6 @@ cfy status
 # Store the CM password into a Cloudify secret
 cfy secret create -s ${CMPASS} cmpass
 
-# Load configurations into Consul KV store
-for config in /dcae-configs/*.json
-do
-    # The basename of the file is the Consul key
-    key=$(basename ${config} .json)
-    # Strip out comments, empty lines
-    egrep -v "^#|^$" ${config} > /tmp/dcae-upload
-    curl -v -X PUT -H "Content-Type: application/json" --data-binary @/tmp/dcae-upload ${CONSUL}/v1/kv/${key}
-done
-
 # After this point, failures should not stop the script or block later commands
 trap - ERR
 set +e