Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

Commit

Permalink
Merge pull request #346 from SUSE/aio-fix
Browse files Browse the repository at this point in the history
Docker all-in-one improvements
  • Loading branch information
richard-cox committed Apr 7, 2020
2 parents 22467ee + a733605 commit eea51bb
Show file tree
Hide file tree
Showing 5 changed files with 235 additions and 14 deletions.
23 changes: 9 additions & 14 deletions deploy/Dockerfile.all-in-one
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Docker build for all-in-one Stratos
# ---------------------------------------------------------------------------------------------------
FROM splatform/stratos-aio-base:leap15_1 as jetstream-builder
FROM splatform/stratos-bk-build-base:leap15_1 as jetstream-builder

# Ensure that we copy the custom-src folder
COPY --chown=stratos:users . ./
Expand All @@ -10,17 +10,8 @@ COPY --chown=stratos:users deploy/all-in-one/config.all-in-one.properties config
ARG USE_PREBUILT_UI=false

USER root
RUN if [ $USE_PREBUILT_UI = "true" ] ; then \
unzip stratos-frontend-prebuild.zip -d ./dist ; \
else \
npm install \
&& npm run build ; \
fi

# Build backend
RUN npm run build-backend \
&& cp src/jetstream/jetstream . \
&& mv dist ui
RUN node --version
RUN deploy/all-in-one/src-build.sh

USER stratos

Expand All @@ -31,7 +22,6 @@ RUN CERTS_PATH=/home/stratos/dev-certs ./generate_cert.sh
# Docker build for FDB Server component
FROM splatform/stratos-bk-build-base:leap15_1 as fdbserver-builder


# Install FoundationDB Binaries
ARG FDB_VERSION=6.2.15
ARG FDB_WEBSITE=https://www.foundationdb.org
Expand Down Expand Up @@ -86,10 +76,14 @@ WORKDIR /go/src/github.com/helm/monocular
ARG VERSION
RUN GO111MODULE=on GOPROXY=https://gocenter.io CGO_ENABLED=0 go build -a -installsuffix cgo -ldflags "-X main.version=$VERSION" .


# ---------------------------------------------------------------------------------------------------
# Final AIO Container
# ---------------------------------------------------------------------------------------------------
# use --target=aio to build All-in-one image

FROM splatform/stratos-bk-base:leap15_1
ARG CANARY_BUILD

COPY --from=jetstream-builder /home/stratos/deploy/db /src/deploy/db
COPY --from=jetstream-builder /home/stratos/dev-certs /srv/dev-certs
COPY --from=jetstream-builder /home/stratos/ui /srv/ui
Expand Down Expand Up @@ -132,6 +126,7 @@ ENV FDB_PROCESS_CLASS unset
ENV CLUSTER_ID docker:docker
ENV FDB_COORDINATOR localhost
ENV FDB_DOC_PORT 27016
ENV FDB_LISTEN_IP 0.0.0.0

# Pull in binaries from chartrepo-builder
COPY --from=chartrepo-builder /go/src/github.com/helm/monocular/chartrepo /chartrepo
Expand Down
180 changes: 180 additions & 0 deletions deploy/all-in-one/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
#!/usr/bin/env bash

#####
#
# Use this script to build the All-in-one image
#
# Note: This is not used by Concourse
#
#####

set -u

CYAN="\033[96m"
YELLOW="\033[93m"
RESET="\033[0m"
BOLD="\033[1m"

# Set defaults
PROD_RELEASE=false
DOCKER_REGISTRY=docker.io
DOCKER_ORG=splatform
BASE_IMAGE_TAG=leap15_1
TAG=$(date -u +"%Y%m%dT%H%M%SZ")
ADD_OFFICIAL_TAG="false"
TAG_LATEST="false"
NO_PUSH="true"
DOCKER_REG_DEFAULTS="true"
HAS_CUSTOM_BUILD="false"

while getopts ":ho:r:t:Tlb:Opc" opt; do
case $opt in
h)
echo
echo "--- To build images of Stratos: "
echo
echo " ./build.sh -t 1.0.13"
echo
echo "-p to push images"
exit 0
;;
r)
DOCKER_REGISTRY="${OPTARG}"
DOCKER_REG_DEFAULTS="false"
;;
o)
DOCKER_ORG="${OPTARG}"
DOCKER_REG_DEFAULTS="false"
;;
t)
TAG="${OPTARG}"
;;
b)
BASE_IMAGE_TAG="${OPTARG}"
;;
T)
TAG="$(git describe $(git rev-list --tags --max-count=1))"
;;
l)
TAG_LATEST="true"
;;
p)
NO_PUSH="false"
;;
\?)
echo "Invalid option: -${OPTARG}" >&2
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done

echo
printf "${CYAN}${BOLD}"

echo "==========================================================================="
echo "== Stratos All-in-one build =="
echo "==========================================================================="

printf "${RESET}${CYAN}"
echo
echo "PRODUCTION BUILD/RELEASE : ${PROD_RELEASE}"
echo "REGISTRY : ${DOCKER_REGISTRY}"
echo "ORG : ${DOCKER_ORG}"
echo "TAG : ${TAG}"
echo "BASE_IMAGE_TAG : ${BASE_IMAGE_TAG}"

printf "${RESET}"
echo

if [ "${NO_PUSH}" != "false" ]; then
printf "${YELLOW}Images will ${BOLD}NOT${RESET}${YELLOW} be pushed${RESET}\n"
else
printf "${YELLOW}${BOLD}Images will be pushed${RESET}\n"
echo " REGISTRY : ${DOCKER_REGISTRY}"
echo " ORG : ${DOCKER_ORG}"
fi

echo
printf "${CYAN}${BOLD}Starting build${RESET}\n"
echo

function log {
set +e
printf "${BOLD}${YELLOW}"
echo
echo "==========================================================================="
echo "$1"
echo "==========================================================================="
echo
printf "${RESET}"
set -e
}

set -e

__DIRNAME="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
STRATOS_PATH=${__DIRNAME}/../../
source ${STRATOS_PATH}/deploy/common-build.sh

function patchAndPushImage {
NAME=${1}
DOCKER_FILE=${2}
FOLDER=${3}
TARGET=${4:-none}
PATCHED_DOCKER_FILE="${DOCKER_FILE}.patched"

patchDockerfile ${DOCKER_FILE} ${FOLDER}
buildAndPublishImage ${NAME} "${PATCHED_DOCKER_FILE}" ${FOLDER} ${TARGET}

rm -rf ${FOLDER}/${PATCHED_DOCKER_FILE}
rm -rf ${FOLDER}/${PATCHED_DOCKER_FILE}.bak
}

function patchDockerfile {
DOCKER_FILE=${1}
FOLDER=${2}
PATCHED_DOCKER_FILE=${DOCKER_FILE}.patched

# Replace registry/organization
pushd ${FOLDER} > /dev/null 2>&1
ls
rm -rf ${PATCHED_DOCKER_FILE}
cp ${DOCKER_FILE} ${PATCHED_DOCKER_FILE}
if [ "${DOCKER_REG_DEFAULTS}" == "false" ]; then
sed -i.bak "s@splatform@${DOCKER_REGISTRY}/${DOCKER_ORG}@g" ${FOLDER}/${PATCHED_DOCKER_FILE}
fi
sed -i.bak "s/opensuse/${BASE_IMAGE_TAG}/g" ${FOLDER}/${PATCHED_DOCKER_FILE}
popd > /dev/null 2>&1
}


#
# MAIN -------------------------------------------------------------------------------------------
#

pushd "${STRATOS_PATH}" > /dev/null 2>&1
STRATOS_PATH="$(pwd)"
popd > /dev/null 2>&1
echo "Base path: ${STRATOS_PATH}"

# cleanup output, intermediate artifacts
cleanup

log "-- Build & publish the runtime container image for All-in-one"
patchAndPushImage stratos-aio deploy/Dockerfile.all-in-one "${STRATOS_PATH}"

set +e

printf "${BOLD}${YELLOW}"
echo
echo "Build complete...."
printf "${CYAN}"
echo " Registry : ${DOCKER_REGISTRY}"
echo " Org : ${DOCKER_ORG}"
echo " Tag : ${TAG}"
printf "${RESET}"
echo ""
29 changes: 29 additions & 0 deletions deploy/all-in-one/src-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

echo "Building Stratos: Use Prebuild: ${USE_PREBUILT_UI}"

# Use pre-built UI package (speed up building if alreay built)
if [ "${USE_PREBUILT_UI}" = "true" ]; then
echo "Using pre-built UI: unpacking..."
unzip stratos-frontend-prebuild.zip -d ./dist
else
echo "Building frontend"
npm install
npm run customize
npm run build
if [ $? -ne 0 ]; then
echo "Frontend build failed"
exit 1
fi
fi

# Build backend

echo "Building backend"
npm run build-backend
if [ $? -ne 0 ]; then
echo "Backend build failed"
exit 1
fi
cp src/jetstream/jetstream .
mv dist ui
9 changes: 9 additions & 0 deletions deploy/containers/monocular/fdb-doclayer/fdbdoc.bash
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,18 @@ else
LISTEN_IP=${PUBLIC_IP}
fi

echo "===================================================================================="
echo "FDB Document Layer starting"
echo "===================================================================================="
echo ""

echo "Connecting to FDB server at: $CLUSTER_ID@$coordinator_ip:$coordinator_port"
echo "Cluster file contents: "
cat $FDB_CLUSTER_FILE

echo "Listen IP is ${LISTEN_IP}"
echo "Public IP is ${PUBLIC_IP}"

if [[ "$ENABLE_TLS" == "true" ]]; then
echo "Starting FDB Document Layer on $LISTEN_IP:$FDB_DOC_PORT:tls. TLS enabled."
fdbdoc -V --listen_address $LISTEN_IP:$FDB_DOC_PORT:tls --tls_certificate_file $SERVER_CRT --tls_ca_file $CA_CRT --tls_key_file $SERVER_KEY --logdir /var/fdb/logs
Expand Down
8 changes: 8 additions & 0 deletions deploy/containers/monocular/fdb-server/fdb.bash
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,13 @@ else
LISTEN_IP=${PUBLIC_IP}
fi

echo "===================================================================================="
echo "FDB Server starting"
echo "===================================================================================="
echo ""

echo "Listen IP is ${LISTEN_IP}"
echo "Public IP is ${PUBLIC_IP}"

fdbserver --listen_address $LISTEN_IP:$FDB_PORT --public_address $PUBLIC_IP:$FDB_PORT \
--datadir /var/fdb/data --logdir /var/fdb/logs

0 comments on commit eea51bb

Please sign in to comment.