Skip to content

Commit

Permalink
Build and push base images on push to develop (#11)
Browse files Browse the repository at this point in the history
* Add action to build base images/push to ghcr.io

* Upgrade go to 1.20.7

* set all docker related env variables to anynines/ghcr.io/centos7
  • Loading branch information
bmo-at-a9s authored Aug 18, 2023
1 parent 081a242 commit 6f7e34d
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 13 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/container-push-base-images-develop.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: container-push-base-images-develop

on:
push:
branches:
- develop
workflow_dispatch:

jobs:
push-store-image:
runs-on: ubuntu-latest
permissions:
packages: write

steps:
- name: 'Log into GHCR'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{secrets.DOCKERHUB_USERNAME}}
password: ${{secrets.DOCKERHUB_TOKEN}}
- name: 'Checkout current develop'
uses: actions/checkout@v3
with:
ref: "devlop"
- name: 'Build stratos base images'
run: |
./deploy/stratos-base-images/build-base-images.sh -r ghcr.io -o anynines -p -s
8 changes: 4 additions & 4 deletions deploy/all-in-one/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ BOLD="\033[1m"

# Set defaults
PROD_RELEASE=false
DOCKER_REGISTRY=docker.io
DOCKER_ORG=splatform
BASE_IMAGE_TAG=leap15_1
DOCKER_REGISTRY=ghcr.io
DOCKER_ORG=anynines
BASE_IMAGE_TAG=centos7
TAG=$(date -u +"%Y%m%dT%H%M%SZ")
ADD_OFFICIAL_TAG="false"
TAG_LATEST="false"
Expand Down Expand Up @@ -151,7 +151,7 @@ function patchDockerfile {
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}
sed -i.bak "s/leap15_2/${BASE_IMAGE_TAG}/g" ${FOLDER}/${PATCHED_DOCKER_FILE}
popd > /dev/null 2>&1
}

Expand Down
4 changes: 2 additions & 2 deletions deploy/kubernetes/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ BOLD="\033[1m"

# Set defaults
PROD_RELEASE=false
DOCKER_REGISTRY=docker.io
DOCKER_ORG=internalservices
DOCKER_REGISTRY=ghcr.io
DOCKER_ORG=anynines
BASE_IMAGE_TAG=centos7
OFFICIAL_TAG=cap
TAG=$(date -u +"%Y%m%dT%H%M%SZ")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ FROM {{BASE_IMAGE}}
RUN yum update -y && \
yum install -y git gcc wget gzip xz unzip

RUN wget https://storage.googleapis.com/golang/go1.13.4.linux-{{GO_ARCH}}.tar.gz && \
tar -xzf go1.13.4.linux-{{GO_ARCH}}.tar.gz -C /usr/local/ && \
rm go1.13.4.linux-{{GO_ARCH}}.tar.gz && \
RUN wget https://storage.googleapis.com/golang/go1.20.7.linux-{{GO_ARCH}}.tar.gz && \
tar -xzf go1.20.7.linux-{{GO_ARCH}}.tar.gz -C /usr/local/ && \
rm go1.20.7.linux-{{GO_ARCH}}.tar.gz && \
mkdir -p /home/stratos/go/bin && \
mkdir -p /home/stratos/go/src

Expand Down
13 changes: 9 additions & 4 deletions deploy/stratos-base-images/build-base-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ RESET="\033[0m"
BOLD="\033[1m"

BASE_IMAGE=centos:7
REGISTRY=docker.io
ORGANIZATION=internalservices
REGISTRY=ghcr.io
ORGANIZATION=anynines
TAG=centos7
ARCH=amd64
PROG=$(basename ${BASH_SOURCE[0]})
Expand All @@ -24,19 +24,20 @@ GOSU_ARCH=amd64
NGINX_ARCH=centos/7/x86_64

function usage {
echo "usage: $PROG [-b BASE] [-r REGISTRY] [-o ORGANIZATION] [-t TAG] [-p] [h]"
echo "usage: $PROG [-b BASE] [-r REGISTRY] [-o ORGANIZATION] [-t TAG] [-s] [-p] [h]"
echo " -a Value System Architecture (amd64 or arm64)"
echo " -b Value Base Image"
echo " -r Value Docker registry"
echo " -o Value Organization in Docker registry"
echo " -s Don't squash images"
echo " -t Value Tag for images"
echo " -p Push images to registry"
echo " -h Help"
exit 1
}


while getopts "a:b:r:o:t:ph" opt ; do
while getopts "a:b:r:o:t:ph:s" opt ; do
case $opt in
a)
ARCH=${OPTARG}
Expand Down Expand Up @@ -74,6 +75,9 @@ while getopts "a:b:r:o:t:ph" opt ; do
h)
usage
;;
s)
SQUASH_ARGS=""
;;
\?)
echo "Invalid option -$OPTARG" >&2
usage
Expand All @@ -92,6 +96,7 @@ echo "BASE IMAGE : ${BASE_IMAGE}"
echo "REGISTRY : ${REGISTRY}"
echo "ORG : ${ORGANIZATION}"
echo "TAG : ${TAG}"
echo "SQUASH: : ${SQUASH_ARGS}"
echo "PUSH IMAGES : ${PUSH_IMAGES}"
echo ""
printf "${RESET}"
Expand Down

0 comments on commit 6f7e34d

Please sign in to comment.