Skip to content

Commit

Permalink
Cleaning up a bit.
Browse files Browse the repository at this point in the history
  • Loading branch information
mihxil committed Nov 16, 2024
1 parent eb72f24 commit f7f3a6b
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 41 deletions.
14 changes: 7 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
FROM ubuntu:24.04

LABEL org.opencontainers.image.description="ubuntu with kubernates, docker, oc, helm, used in ci/cd tasks"

LABEL org.opencontainers.image.description="ubuntu with kubernetes, docker, oc, helm, used in ci/cd tasks"

RUN apt-get update &&\
apt-get -y upgrade &&\
Expand All @@ -28,13 +27,14 @@ RUN curl https://baltocdn.com/helm/signing.asc | gpg --dearmor | sudo tee /usr/s
apt-get clean && rm -rf /var/lib/apt/lists/*


COPY --from=ghcr.io/npo-poms/kaniko:main /docker-build-setup.sh /
COPY scripts/* /
ENV KANIKO_SCRIPTS=/
ENV HELM_SCRIPTS=/

COPY --from=ghcr.io/npo-poms/kaniko:main /dockerfile-functions.sh $KANIKO_SCRIPTS
COPY scripts/* $HELM_SCRIPTS


RUN chmod +x /setup-helm.sh && \
chmod +x /docker-build-setup.sh && \
chmod +x /script.sh && \
RUN chmod +x /script.sh && \
mkdir /workspace

WORKDIR /workspace
Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
.DEFAULT_GOAL := docker
IMAGE := vpro/openshift-helm:main

help: ## Show this help.
@sed -n 's/^##//p' $(MAKEFILE_LIST)
@grep -E '^[/%a-zA-Z._-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

docker: ## build image locally
docker build -t vpro/openshift-helm:dev .
docker build -t $(IMAGE) .

explore: ## look around
docker run -it --entrypoint /bin/bash vpro/openshift-helm:dev
docker run -it --entrypoint /bin/bash $(IMAGE)
2 changes: 1 addition & 1 deletion helm.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
#HELM_IMAGE=ghcr.io/vpro/openshift-helm:3.0
HELM_IMAGE=vpro/openshift-helm:dev
HELM_IMAGE=vpro/openshift-helm:main


docker run -v ~/conf:/conf -v ~:/root -v "$(pwd)":/workspace $HELM_IMAGE
Expand Down
53 changes: 28 additions & 25 deletions scripts/setup-helm.sh → scripts/helm-functions.sh
Original file line number Diff line number Diff line change
@@ -1,32 +1,37 @@
#!/bin/bash
echo "helm build setup"
. /docker-build-setup.sh
if ! type os_app_name &> /dev/null ; then
. "$KANIKO_SCRIPTS"dockerfile-functions.sh
fi

echo "Using shell $SHELL"
# Switch to the correct Openshift cluster (test/acc or prod)
export SERVER
if [ "$OS_ENV" = "prod" ]; then
SERVER=$OPENSHIFT_PROD_SERVER
CONTEXT=pomsp
else
SERVER=$OPENSHIFT_TEST_SERVER
CONTEXT=pomst
fi

if [ "$KUBECONFIG" != "" ]; then
echo "Fixing permissions on $KUBECONFIG"
chmod 700 $KUBECONFIG # avoid warning about permissions (https://gitlab.com/gitlab-org/gitlab/-/issues/363057)
fi
login_oc() {
# Switch to the correct Openshift cluster (test/acc or prod)
export SERVER
if [ "$OS_ENV" = "prod" ]; then
SERVER=$OPENSHIFT_PROD_SERVER
CONTEXT=pomsp
else
SERVER=$OPENSHIFT_TEST_SERVER
CONTEXT=pomst
fi

if [ "$KUBECONFIG" != "" ]; then
echo "Fixing permissions on $KUBECONFIG"
chmod 700 $KUBECONFIG # avoid warning about permissions (https://gitlab.com/gitlab-org/gitlab/-/issues/363057)
fi

# - Make sure we are oc logged in.
# using KUBECONFIG and CONTEXT
# - We selected the desired project $OS_PROJECT-$OS_ENV
# - The variable VALUES is resolved to a comma separated list of relevant values.yaml files
# The first argument can be a sub directory
echo "Using helm $(helm version)"
oc config use-context $CONTEXT
oc project $OS_PROJECT-$OS_ENV
oc projects
# - Make sure we are oc logged in.
# using KUBECONFIG and CONTEXT
# - We selected the desired project $OS_PROJECT-$OS_ENV
# - The variable VALUES is resolved to a comma separated list of relevant values.yaml files
# The first argument can be a sub directory
echo "Using helm $(helm version)"
oc config use-context $CONTEXT
oc project $OS_PROJECT-$OS_ENV
oc projects
}

echo "${BASH_VERSION} $LINENO Defining setup_oc_helm function"

Expand Down Expand Up @@ -68,8 +73,6 @@ function setup_oc_helm() {
export VALUES=$(printf '%s\n' "$(IFS=,; printf '%s' "${VALUES[*]}")")
}

# defining a bash ansi color (yellow) to make some of this stand out better.
TXT_HI="\e[93m" && TXT_CLEAR="\e[0m"
# deploys application using helm
# $1: The first argument is the directory where the docker file is living.
# The application name will be parsed from ARG NAME
Expand Down
16 changes: 10 additions & 6 deletions scripts/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ export OS_PROJECT=poms
export OS_ENV=test
export HELM_REPO=oci://registry.npohosting.nl/poms
export HELM_REGISTRY=https://registry.npohosting.nl
export DOCKER_AUTH_CONFIG_FILE=$HOME/.docker/config-gitlab.json



export HARBOR_USER
Expand All @@ -17,10 +15,16 @@ export HARBOR_PASSWORD

cd /workspace || exit 1

. /workspace/job.env
if [ -f job.env ] ; then
echo "Found job.env"
cat job.env
. ./job.env
else
echo "No job.env"
fi

. /setup-helm.sh
. "$HELM_SCRIPTS"helm-functions.sh

login_oc
setup_oc_helm

deploy_application "$(pwd)"
deploy_applications

0 comments on commit f7f3a6b

Please sign in to comment.