Skip to content

Commit

Permalink
Migrate Kubernetes deployment images to opensuse
Browse files Browse the repository at this point in the history
  • Loading branch information
Irfan Habib committed Oct 11, 2017
1 parent 744105d commit e06a07e
Show file tree
Hide file tree
Showing 23 changed files with 78 additions and 171 deletions.
9 changes: 3 additions & 6 deletions deploy/Dockerfile.bk-preflight.dev
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
FROM alpine:latest

RUN apk update && \
apk add ca-certificates openssl git &&\
mkdir -p /srv
FROM splatform/stratos-preflight-base:dev

RUN mkdir -p /srv
WORKDIR /srv
COPY outputs/* /srv/
COPY /deploy/db/scripts/run-preflight-job.sh /run-preflight-job.sh
COPY /deploy/tools/generate_cert.sh /generate_cert.sh
RUN chmod +x portal-proxy
EXPOSE 443
CMD ["sh", "-c", "/run-preflight-job.sh; /srv/portal-proxy"]
CMD ["bash", "-c", "/run-preflight-job.sh; /srv/portal-proxy"]
7 changes: 1 addition & 6 deletions deploy/Dockerfile.bk.k8s
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
FROM alpine:latest
FROM splatform/stratos-bk-base:dev

RUN apk update && \
apk add ca-certificates git &&\
mkdir -p /srv

WORKDIR /srv
COPY outputs/* /srv/
RUN chmod +x portal-proxy
EXPOSE 443
Expand Down
65 changes: 0 additions & 65 deletions deploy/build-base-images.sh

This file was deleted.

4 changes: 2 additions & 2 deletions deploy/ci/tasks/stratos-ui/prep-proxy-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ platform: linux
image_resource:
type: docker-image
source:
repository: ci-registry.ngrok.io:80/susetest/console-proxy-builder
tag: "latest"
repository: ci-registry.ngrok.io:80/splatform/stratos-proxy-builder
tag: "dev"
insecure_registries: [ "ci-registry.ngrok.io:80" ]

inputs:
Expand Down
2 changes: 1 addition & 1 deletion deploy/ci/tasks/stratos-ui/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ run:
cat ../build/secrets.json
for image in splatform/stratos-goose postgres:latest nginx:1.11 splatform/stratos-uaa java:openjdk-8u66-jre alpine:latest splatform/stratos-concourse; do
for image in splatform/stratos-goose-base:dev splatform/stratos-bk-base:dev splatform/stratos-nginx-base:dev splatform/stratos-uaa splatform/stratos-concourse; do
docker pull ${REGISTRY_NAME}/$image
docker tag ${REGISTRY_NAME}/$image $image
done
Expand Down
2 changes: 1 addition & 1 deletion deploy/containers/nginx/Dockerfile.dc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM nginx:1.11
FROM splatform/stratos-nginx-base:dev

RUN mkdir -p /etc/secrets/ && \
openssl req -batch -new -newkey rsa:2048 -days 365 -nodes -x509 -keyout /etc/secrets/server.key -out /etc/secrets/server.crt && \
Expand Down
2 changes: 1 addition & 1 deletion deploy/containers/nginx/Dockerfile.k8s
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM nginx:1.11
FROM splatform/stratos-nginx-base:dev

RUN mkdir -p /usr/share/doc/suse
COPY ./LICENSE.txt /usr/share/doc/suse/LICENSE.txt
Expand Down
6 changes: 2 additions & 4 deletions deploy/db/Dockerfile.k8s.postflight-job
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
FROM golang:1.8-alpine
FROM splatform/stratos-goose-base:dev

RUN apk update && \
apk add postgresql-client mariadb-client git gcc musl-dev
RUN go get bitbucket.org/liamstask/goose/lib/goose
RUN zypper -n in postgresql mariadb-client
RUN go get github.com/go-sql-driver/mysql
COPY goose /usr/local/bin/
COPY deploy/db/dbconf.yml db/dbconf.yml
Expand Down
3 changes: 1 addition & 2 deletions deploy/db/Dockerfile.preflight-job
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
FROM debian:jessie
RUN export DEBIAN_FRONTEND=noninteractive && apt-get update && apt-get install -y openssl
FROM splatform/stratos-preflight-base:dev
COPY /deploy/db/scripts/run-preflight-job.sh /run-preflight-job.sh
COPY /deploy/tools/generate_cert.sh /generate_cert.sh
CMD ["/run-preflight-job.sh"]
2 changes: 1 addition & 1 deletion deploy/db/scripts/run-postflight-job.k8s.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
set -e

function execStatement {
Expand Down
2 changes: 1 addition & 1 deletion deploy/db/scripts/run-preflight-job.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
set -e

# Step 1 - Set the lock file on the shared volume
Expand Down
10 changes: 5 additions & 5 deletions deploy/docker-compose/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ function buildProxy {
-e GROUP_ID=$(id -g) \
--name stratos-proxy-builder \
--volume $(pwd):/go/src/github.com/SUSE/stratos-ui \
${DOCKER_REGISTRY}/${DOCKER_ORG}/stratos-proxy-builder
${DOCKER_REGISTRY}/${DOCKER_ORG}/stratos-proxy-builder:dev
popd > /dev/null 2>&1
popd > /dev/null 2>&1

Expand All @@ -192,7 +192,7 @@ function buildGoose {
# Build the postflight container
echo
echo "-- Build & publish the runtime container image for the postflight job"
preloadImage splatform/stratos-goose:latest
preloadImage splatform/stratos-goose-base:dev
buildAndPublishImage stratos-dc-goose ./db/Dockerfile.goose.dev ${STRATOS_UI_PATH}/deploy
rm -f ${STRATOS_UI_PATH}/goose
}
Expand All @@ -202,7 +202,7 @@ function buildUI {
CURRENT_USER=$
echo
echo "-- Provision the UI"
preloadImage node:6.9.1
preloadImage splatform/stratos-nginx-base:dev
docker run --rm \
${RUN_ARGS} \
-v ${STRATOS_UI_PATH}:/usr/src/app \
Expand All @@ -211,7 +211,7 @@ function buildUI {
-e USER_ID=$(id -u) \
-e GROUP_ID=$(id -g) \
-w /usr/src/app \
node:6.9.1 \
splatform/stratos-nginx-base:dev \
/bin/bash ./deploy/provision.sh

# Copy the artifacts from the above to the nginx container
Expand All @@ -222,7 +222,7 @@ function buildUI {
# Build and push an image based on the nginx container
echo
echo "-- Building/publishing the runtime container image for the Console web server"
preloadImage nginx:1.11
preloadImage splatform/stratos-nginx-base:dev
buildAndPublishImage stratos-dc-console Dockerfile.dc ${STRATOS_UI_PATH}/deploy/containers/nginx
}

Expand Down
10 changes: 3 additions & 7 deletions deploy/kubernetes/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ function buildProxy {
-e GROUP_ID=$(id -g) \
--name stratos-proxy-builder \
--volume $(pwd):/go/src/github.com/SUSE/stratos-ui \
${DOCKER_REGISTRY}/${DOCKER_ORG}/stratos-proxy-builder:test
${DOCKER_REGISTRY}/${DOCKER_ORG}/stratos-proxy-builder:dev
popd > /dev/null 2>&1
popd > /dev/null 2>&1

Expand All @@ -201,15 +201,13 @@ function buildPostgres {
echo
echo "-- Build & publish the runtime container image for postgres"
# Pull base image locally and retag
preloadImage postgres:9.4.9
buildAndPublishImage stratos-postgres Dockerfile ${STRATOS_UI_PATH}/deploy/containers/postgres
}

function buildPreflightJob {
# Build the preflight container
echo
echo "-- Build & publish the runtime container image for the preflight job"
preloadImage debian:jessie
buildAndPublishImage stratos-preflight-job ./deploy/db/Dockerfile.preflight-job ${STRATOS_UI_PATH}
}

Expand All @@ -224,7 +222,7 @@ function buildPostflightJob {
--rm \
--name postflight-builder \
--volume $(pwd):/go/bin/ \
${DOCKER_REGISTRY}/${DOCKER_ORG}/stratos-postflight-builder:latest
${DOCKER_REGISTRY}/${DOCKER_ORG}/stratos-postflight-builder:dev
mv goose ${STRATOS_UI_PATH}/
buildAndPublishImage stratos-postflight-job ./deploy/db/Dockerfile.k8s.postflight-job ${STRATOS_UI_PATH}
rm -f ${STRATOS_UI_PATH}/goose
Expand All @@ -235,7 +233,6 @@ function buildUI {
CURRENT_USER=$
echo
echo "-- Provision the UI"
preloadImage node:6.9.1
docker run --rm \
${RUN_ARGS} \
-v ${STRATOS_UI_PATH}:/usr/src/app \
Expand All @@ -244,7 +241,7 @@ function buildUI {
-e USER_ID=$(id -u) \
-e GROUP_ID=$(id -g) \
-w /usr/src/app \
node:6.9.1 \
splatform/stratos-ui-base:dev \
/bin/bash ./deploy/provision.sh

# Copy the artifacts from the above to the nginx container
Expand All @@ -256,7 +253,6 @@ function buildUI {
echo
echo "-- Building/publishing the runtime container image for the Console web server"
# Download and retag image to save bandwidth
preloadImage nginx:1.11
buildAndPublishImage stratos-console Dockerfile.k8s ${STRATOS_UI_PATH}/deploy/containers/nginx
}

Expand Down
4 changes: 2 additions & 2 deletions deploy/provision.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

WORK_DIR=$(pwd)

Expand All @@ -24,4 +24,4 @@ if [ ! -z "${CREATE_USER}" ]; then
chown -R ${USER_ID}:${GROUP_ID} node_modules
chown -R ${USER_ID}:${GROUP_ID} bower_components
chown -R ${USER_ID}:${GROUP_ID} dist
fi
fi
17 changes: 3 additions & 14 deletions deploy/stratos-base-images/Dockerfile.stratos-bk-build-base.tmpl
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
FROM {{BASE_IMAGE}}
FROM splatform/stratos-go-base:dev

RUN zypper -n ref && \
zypper -n up && \
zypper in -y wget which tar git gcc
RUN wget https://nodejs.org/dist/v6.11.4/node-v6.11.4-linux-x64.tar.xz && \
RUN cd / && wget https://nodejs.org/dist/v6.11.4/node-v6.11.4-linux-x64.tar.xz && \
tar -xf node-v6.11.4-linux-x64.tar.xz
RUN wget https://storage.googleapis.com/golang/go1.8.4.linux-amd64.tar.gz && \
tar -xzf go1.8.4.linux-amd64.tar.gz -C /usr/local/ && \
mkdir -p /go/bin && \
mkdir -p /go/src
ENV PATH $PATH:/node-v6.11.4-linux-x64/bin:/usr/local/go/bin:/go/bin
ENV GOPATH /go
RUN wget https://glide.sh/get && \
chmod +x get && \
./get
ENV PATH $PATH:/node-v6.11.4-linux-x64/bin
15 changes: 15 additions & 0 deletions deploy/stratos-base-images/Dockerfile.stratos-go-base.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM {{BASE_IMAGE}}

RUN zypper -n ref && \
zypper -n up && \
zypper in -y wget which tar git gcc
RUN wget https://storage.googleapis.com/golang/go1.8.4.linux-amd64.tar.gz && \
tar -xzf go1.8.4.linux-amd64.tar.gz -C /usr/local/ && \
mkdir -p /go/bin && \
mkdir -p /go/src
ENV PATH $PATH:/usr/local/go/bin:/go/bin
ENV GOPATH /go
RUN wget https://glide.sh/get && \
chmod +x get && \
./get
WORKDIR /go
Original file line number Diff line number Diff line change
@@ -1,8 +1,2 @@
FROM {{BASE_IMAGE}}
RUN zypper -n ref && \
zypper -n up && \
zypper in -y go git
RUN mkdir /go
ENV GOPATH /go
WORKDIR /go
FROM splatform/stratos-go-base:dev
RUN go get bitbucket.org/liamstask/goose/cmd/goose
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FROM {{BASE_IMAGE}}
WORKDIR /
6 changes: 3 additions & 3 deletions deploy/stratos-base-images/Dockerfile.stratos-ui-base.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ FROM {{BASE_IMAGE}}
RUN zypper -n ref && \
zypper -n up && \
zypper in -y wget tar git
RUN wget https://nodejs.org/dist/v8.6.0/node-v8.6.0-linux-x64.tar.xz && \
tar -xf node-v8.6.0-linux-x64.tar.xz
ENV PATH $PATH:/node-v8.6.0-linux-x64/bin
RUN cd / && wget https://nodejs.org/dist/v6.11.4/node-v6.11.4-linux-x64.tar.xz && \
tar -xf node-v6.11.4-linux-x64.tar.xz
ENV PATH $PATH:/node-v6.11.4-linux-x64/bin
28 changes: 25 additions & 3 deletions deploy/stratos-base-images/build-base-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,22 @@ curl -sSO https://raw.githubusercontent.com/tests-always-included/mo/master/mo
chmod +x mo

for i in ${DOCKERFILES}; do
./mo ${__DIRNAME}/$i > ${i/.tmpl}
BASE_IMAGE=${BASE_IMAGE} ./mo ${__DIRNAME}/$i > ${i/.tmpl}
done


pwd
build_and_push_image() {
image_name=$1
docker_file=$2
docker build . -f $docker_file -t ${REGISTRY}/${ORGANIZATION}/${image_name}:${TAG}
docker push ${REGISTRY}/${ORGANIZATION}/${image_name}:${TAG}
}
# Base image with node installed
build_go_base(){
build_and_push_image stratos-go-base Dockerfile.stratos-go-base
}

# Base image with node installed
build_ui_base(){
build_and_push_image stratos-ui-base Dockerfile.stratos-ui-base
Expand All @@ -48,12 +55,23 @@ build_goose_base(){
}

build_portal_proxy_builder(){
export TAG=dev
pushd ${DEPLOY_PATH}/
tools/build-push-proxy-builder-image.sh
TAG=dev tools/build-push-proxy-builder-image.sh
popd
}

build_postflight_job_base(){
pushd ${DEPLOY_PATH}/
TAG=dev tools/build-postflight-image-builder.sh
popd
}

build_preflight_job_base(){
build_and_push_image stratos-preflight-base Dockerfile.stratos-preflight-base
}

# Base with go
# build_go_base
# Used building the UI
build_ui_base;
# Used for running the backend
Expand All @@ -66,4 +84,8 @@ build_nginx_base;
build_bk_build_base;
# Used for building the backend
build_portal_proxy_builder;
# Used for building the postflight job image
build_postflight_job_base;
# Used for building the preflight job image
build_preflight_job_base;
rm -f mo;
Loading

0 comments on commit e06a07e

Please sign in to comment.