Skip to content

Commit

Permalink
refactor: pull and push scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
MahdiBaghbani committed Dec 20, 2024
1 parent 80a820e commit c34bb10
Show file tree
Hide file tree
Showing 2 changed files with 221 additions and 62 deletions.
165 changes: 129 additions & 36 deletions docker/pull/all.sh
Original file line number Diff line number Diff line change
@@ -1,38 +1,131 @@
#!/usr/bin/env bash

# @michielbdejong halt on error in docker init scripts.
set -e

# 3rd party images.
docker pull redis:latest
docker pull mariadb:11.4.2
docker pull memcached:1.6.18
docker pull theasp/novnc:latest
docker pull rclone/rclone:latest
docker pull collabora/code:latest
docker pull jlesage/firefox:latest
docker pull cypress/included:13.13.1
docker pull cs3org/wopiserver:latest
docker pull seafileltd/seafile-mc:11.0.5
docker pull quay.io/keycloak/keycloak:latest

# dev-stock images.
docker pull pondersource/dev-stock-ocmstub:latest
docker pull pondersource/dev-stock-revad:latest
docker pull pondersource/dev-stock-php-base:latest
docker pull pondersource/dev-stock-nextcloud:latest
docker pull pondersource/dev-stock-nextcloud:v30.0.2
docker pull pondersource/dev-stock-nextcloud:v39.0.8
docker pull pondersource/dev-stock-nextcloud:v28.0.14
docker pull pondersource/dev-stock-nextcloud:v27.1.11
# docker pull pondersource/dev-stock-nextcloud-sunet:latest
# docker pull pondersource/dev-stock-simple-saml-php:latest
docker pull pondersource/dev-stock-nextcloud-solid:latest
docker pull pondersource/dev-stock-nextcloud-sciencemesh:latest
docker pull pondersource/dev-stock-owncloud:latest
docker pull pondersource/dev-stock-owncloud-sciencemesh:latest
docker pull pondersource/dev-stock-owncloud-surf-trashbin:latest
docker pull pondersource/dev-stock-owncloud-token-based-access:latest
docker pull pondersource/dev-stock-owncloud-opencloudmesh:latest
docker pull pondersource/dev-stock-owncloud-federatedgroups:latest
docker pull pondersource/dev-stock-owncloud-ocm-test-suite:latest
# -----------------------------------------------------------------------------------
# Docker Pull Script for PonderSource Development Images
# Author: Mohammad Mahdi Baghbani Pourvahid <mahdi@pondersource.com>
# -----------------------------------------------------------------------------------
# This script pulls various Docker images for the PonderSource development environment,
# including both third-party and PonderSource-specific images. It ensures that necessary
# Docker images are pulled from specified repositories for continuous integration,
# development, and testing purposes.
#
# The script allows users to control the execution mode via a command-line argument
# (either 'dev' or 'ci'). In 'ci' mode, the output is suppressed to avoid clutter.
# -----------------------------------------------------------------------------------

# -----------------------------------------------------------------------------------
# Exit Immediately if a Command Fails
# -----------------------------------------------------------------------------------
# Set the script to exit on the first error. This ensures that if any command fails,
# the script will stop and prevent further execution with potentially broken state.
# The `pipefail` option ensures that if a command in a pipeline fails, the whole pipeline
# will return a non-zero exit status.
set -eo pipefail

# -----------------------------------------------------------------------------------
# Constants and Default Values
# -----------------------------------------------------------------------------------

# Default execution mode is 'dev', which shows full output.
DEFAULT_SCRIPT_MODE="dev"

# -----------------------------------------------------------------------------------
# Function: run_quietly_if_ci
# Purpose: Run a command, suppressing stdout if in CI mode.
# Arguments:
# $@ - The command and its arguments to execute.
# -----------------------------------------------------------------------------------
run_quietly_if_ci() {
if [ "${SCRIPT_MODE}" = "ci" ]; then
"$@" >/dev/null 2>&1 # Suppress both stdout and stderr in CI mode.
else
"$@" # Run the command normally if not in CI mode.
fi
}

# -----------------------------------------------------------------------------------
# Function: parse_arguments
# Purpose: Parse command-line arguments and set global variables.
# Arguments:
# $@ - Command-line arguments
# -----------------------------------------------------------------------------------
parse_arguments() {
SCRIPT_MODE="${1:-$DEFAULT_SCRIPT_MODE}" # Default to 'dev' if no argument is provided.
}

# -----------------------------------------------------------------------------------
# Third-Party Docker Image Repositories and Tags
# -----------------------------------------------------------------------------------
CYPRESS_REPO="cypress/included"
CYPRESS_TAG="13.13.1"
FIREFOX_REPO="jlesage/firefox"
FIREFOX_TAG="v24.11.1"
MARIADB_REPO="mariadb"
MARIADB_TAG="11.4.4"
VNC_REPO="theasp/novnc"
VNC_TAG="latest"
REDIS_REPO="redis"
REDIS_TAG="latest"
MEMCACHED_REPO="memcached"
MEMCACHED_TAG="1.6.18"
RCLONE_REPO="rclone/rclone"
RCLONE_TAG="latest"
COLLABORA_REPO="collabora/code"
COLLABORA_TAG="latest"
WOPISERVER_REPO="cs3org/wopiserver"
WOPISERVER_TAG="latest"
SEAFILE_MC_REPO="seafileltd/seafile-mc"
SEAFILE_MC_TAG="11.0.5"
KEYCLOAK_REPO="quay.io/keycloak/keycloak"
KEYCLOAK_TAG="latest"

# -----------------------------------------------------------------------------------
# Parse Command-Line Arguments
# -----------------------------------------------------------------------------------
parse_arguments "$@" # Parse any arguments passed to the script.

# -----------------------------------------------------------------------------------
# Pull Third-Party Docker Images
# -----------------------------------------------------------------------------------
run_quietly_if_ci echo "Pulling third-party Docker images..."

# Use run_quietly_if_ci to suppress output in CI mode
run_quietly_if_ci docker pull "${REDIS_REPO}:${REDIS_TAG}"
run_quietly_if_ci docker pull "${MEMCACHED_REPO}:${MEMCACHED_TAG}"
run_quietly_if_ci docker pull "${RCLONE_REPO}:${RCLONE_TAG}"
run_quietly_if_ci docker pull "${COLLABORA_REPO}:${COLLABORA_TAG}"
run_quietly_if_ci docker pull "${VNC_REPO}:${VNC_TAG}"
run_quietly_if_ci docker pull "${CYPRESS_REPO}:${CYPRESS_TAG}"
run_quietly_if_ci docker pull "${MARIADB_REPO}:${MARIADB_TAG}"
run_quietly_if_ci docker pull "${FIREFOX_REPO}:${FIREFOX_TAG}"
run_quietly_if_ci docker pull "${WOPISERVER_REPO}:${WOPISERVER_TAG}"
run_quietly_if_ci docker pull "${SEAFILE_MC_REPO}:${SEAFILE_MC_TAG}"
run_quietly_if_ci docker pull "${KEYCLOAK_REPO}:${KEYCLOAK_TAG}"

# -----------------------------------------------------------------------------------
# Pull PonderSource-Specific Docker Images
# -----------------------------------------------------------------------------------
run_quietly_if_ci echo "Pulling PonderSource-specific Docker images..."

run_quietly_if_ci docker pull pondersource/revad:latest
run_quietly_if_ci docker pull pondersource/ocmstub:latest
run_quietly_if_ci docker pull pondersource/ocmstub:v1.0.0

# Nextcloud: Pull multiple versions of the Nextcloud Docker image.
run_quietly_if_ci docker pull pondersource/nextcloud-base:latest
nextcloud_versions=("latest" "v30.0.2" "v29.0.10" "v28.0.14" "v27.1.11")
for version in "${nextcloud_versions[@]}"; do
run_quietly_if_ci docker pull "pondersource/nextcloud:${version}"
done

# ownCloud: Pull multiple versions of the ownCloud Docker image.
run_quietly_if_ci docker pull pondersource/owncloud-base:latest
owncloud_versions=("latest" "v10.15.0")
for version in "${owncloud_versions[@]}"; do
run_quietly_if_ci docker pull "pondersource/owncloud:${version}"
done

# -----------------------------------------------------------------------------------
# End of Docker Pulls
# -----------------------------------------------------------------------------------
run_quietly_if_ci echo "Docker pull completed successfully."
118 changes: 92 additions & 26 deletions docker/push/all.sh
Original file line number Diff line number Diff line change
@@ -1,28 +1,94 @@
#!/usr/bin/env bash

# @michielbdejong halt on error in docker init scripts.
set -e

echo "Log in as pondersource"
docker login

docker push pondersource/dev-stock-ocmstub:latest
docker push pondersource/dev-stock-ocmstub:v1.0.0
docker push pondersource/dev-stock-revad:latest
docker push pondersource/dev-stock-php-base:latest
docker push pondersource/dev-stock-nextcloud:latest
docker push pondersource/dev-stock-nextcloud:v30.0.2
docker push pondersource/dev-stock-nextcloud:v29.0.10
docker push pondersource/dev-stock-nextcloud:v28.0.14
docker push pondersource/dev-stock-nextcloud:v27.1.11
# docker push pondersource/dev-stock-nextcloud-sunet
# docker push pondersource/dev-stock-simple-saml-php
docker push pondersource/dev-stock-nextcloud-solid:latest
docker push pondersource/dev-stock-nextcloud-sciencemesh:latest
docker push pondersource/dev-stock-owncloud:latest
docker push pondersource/dev-stock-owncloud-sciencemesh:latest
docker push pondersource/dev-stock-owncloud-surf-trashbin:latest
docker push pondersource/dev-stock-owncloud-token-based-access:latest
docker push pondersource/dev-stock-owncloud-opencloudmesh:latest
docker push pondersource/dev-stock-owncloud-federatedgroups:latest
docker push pondersource/dev-stock-owncloud-ocm-test-suite:latest
# -----------------------------------------------------------------------------------
# Docker Push Script for PonderSource Development Images
# Author: Mohammad Mahdi Baghbani Pourvahid <mahdi@pondersource.com>
# -----------------------------------------------------------------------------------
# This script pushes various Docker images for the PonderSource development environment,
# including both third-party and PonderSource-specific images. It ensures that necessary
# Docker images are pushed from specified repositories for continuous integration,
# development, and testing purposes.
#
# The script allows users to control the execution mode via a command-line argument
# (either 'dev' or 'ci'). In 'ci' mode, the output is suppressed to avoid clutter.
# -----------------------------------------------------------------------------------

# -----------------------------------------------------------------------------------
# Exit Immediately if a Command Fails
# -----------------------------------------------------------------------------------
# Exit on error. If any command fails, the script stops execution to avoid issues
# with potentially broken states. The `pipefail` option ensures that if any command
# in a pipeline fails, the entire pipeline returns a non-zero exit status.
set -eo pipefail

# -----------------------------------------------------------------------------------
# Constants and Default Values
# -----------------------------------------------------------------------------------

# Default execution mode is 'dev', which shows full output. 'ci' mode suppresses output.
DEFAULT_SCRIPT_MODE="dev"

# -----------------------------------------------------------------------------------
# Function: run_quietly_if_ci
# Purpose: Run a command, suppressing stdout if in CI mode.
# Arguments:
# $@ - The command and its arguments to execute.
# -----------------------------------------------------------------------------------
run_quietly_if_ci() {
if [ "${SCRIPT_MODE}" = "ci" ]; then
"$@" >/dev/null 2>&1 # Suppress both stdout and stderr in CI mode.
else
"$@" # Run the command normally if not in CI mode.
fi
}

# -----------------------------------------------------------------------------------
# Function: parse_arguments
# Purpose: Parse command-line arguments and set global variables.
# Arguments:
# $@ - Command-line arguments
# -----------------------------------------------------------------------------------
parse_arguments() {
SCRIPT_MODE="${1:-$DEFAULT_SCRIPT_MODE}" # Default to 'dev' if no argument is provided.
}

# -----------------------------------------------------------------------------------
# Parse Command-Line Arguments
# -----------------------------------------------------------------------------------
parse_arguments "$@" # Parse any arguments passed to the script.

# Ensure successful login to Docker before pushing images.
echo "Logging in to Docker as pondersource..."
if ! docker login; then
echo "Docker login failed. Exiting."
exit 1
fi

# -----------------------------------------------------------------------------------
# Push PonderSource-Specific Docker Images
# -----------------------------------------------------------------------------------
run_quietly_if_ci echo "Pushing PonderSource-specific Docker images..."

# Push the core PonderSource images.
run_quietly_if_ci docker push pondersource/revad:latest
run_quietly_if_ci docker push pondersource/ocmstub:latest
run_quietly_if_ci docker push pondersource/ocmstub:v1.0.0

# Nextcloud: push multiple versions of the Nextcloud Docker image.
run_quietly_if_ci docker push pondersource/nextcloud-base:latest
nextcloud_versions=("latest" "v30.0.2" "v29.0.10" "v28.0.14" "v27.1.11")
for version in "${nextcloud_versions[@]}"; do
run_quietly_if_ci docker push "pondersource/nextcloud:${version}"
done

# ownCloud: push multiple versions of the ownCloud Docker image.
run_quietly_if_ci docker push pondersource/owncloud-base:latest
owncloud_versions=("latest" "v10.15.0")
for version in "${owncloud_versions[@]}"; do
run_quietly_if_ci docker push "pondersource/owncloud:${version}"
done

# -----------------------------------------------------------------------------------
# End of Docker Push
# -----------------------------------------------------------------------------------
run_quietly_if_ci echo "Docker push completed successfully."

0 comments on commit c34bb10

Please sign in to comment.