Skip to content

Commit

Permalink
build: migrate init-minio.sh to use new "mc admin policy" commands
Browse files Browse the repository at this point in the history
Fixes the breaking changes that were introduced in the MinIO mc client earlier this year (2023) that
broke the init-minio.sh script provided in Dioptra's cookiecutter template. The init-minio.sh script
has been updated to use the new "mc admin policy" commands and handle the fact that the command for
attaching policies is no longer idempotent. The image tag for minio/mc has been unpinned and set
back to the "latest" tag in the dev branch.

Closes #207
Co-authored-by: James K. Glasbrenner <[email protected]>
  • Loading branch information
jtsextonMITRE authored and jkglasbrenner committed Sep 7, 2023
1 parent 79f37ae commit 9ca7a03
Show file tree
Hide file tree
Showing 4 changed files with 408 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
"mc": {
"image": "mc",
"namespace": "minio",
"tag": "RELEASE.2023-01-28T20-29-38Z",
"tag": "latest",
"registry": ""
},
"minio": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,16 @@ services:
image: {{ container_image(cookiecutter.__containers.mc) }}
hostname: {{ cookiecutter.__project_slug }}-mc
entrypoint:
- "/bin/sh"
- "/bin/bash"
{% if cookiecutter.__containers.networks -%}
{{ service_networks(cookiecutter.__containers.networks)|indent(4) }}
{% endif -%}
volumes:
- ./config/minio:/s3-policy:ro
- ./secrets:/secrets:ro
- minio-certs:/root/.mc/certs/CAs:ro
- init-repos:/init-repos:ro
- init-scripts:/scripts:ro

argbash:
image: {{ container_image(cookiecutter.__containers.argbash) }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ CONTAINER_SSL_DIR="/ssl"
INIT_ARGBASH_SERVICE="argbash"
INIT_DB_SERVICE="db"
INIT_FRONTEND_SERVICE="frontend-build"
INIT_MC_SERVICE="mc"
INIT_MINIO_SERVICE="minio"
INIT_MLFLOW_TRACKING_SSL_SERVICE="mlflow-tracking-ssl"
INIT_NAMED_VOLUMES_SERVICE="named-volumes"
INIT_NGINX_SSL_SERVICE="nginx-ssl"
Expand Down Expand Up @@ -295,6 +297,22 @@ start_db_service() {
docker_compose -f "${DOCKER_COMPOSE_INIT_YML}" up -d "${INIT_DB_SERVICE}"
}

###########################################################################################
# Starts a MinIO service as a background process
#
# Globals:
# DOCKER_COMPOSE_INIT_YML
# INIT_MINIO_SERVICE
# Arguments:
# None
# Returns:
# None
###########################################################################################

start_minio_service() {
docker_compose -f "${DOCKER_COMPOSE_INIT_YML}" up -d "${INIT_MINIO_SERVICE}"
}

###########################################################################################
# Enable/disable SSL for the Postgres database
#
Expand Down Expand Up @@ -487,20 +505,23 @@ init_named_volumes() {
# Wrapper for the init-minio.sh utility script
#
# Globals:
# SCRIPT_DIRPATH
# DOCKER_COMPOSE_INIT_YML
# INIT_MC_SERVICE
# Arguments:
# None
# Returns:
# None
###########################################################################################

init_minio() {
local script_path="${SCRIPT_DIRPATH}/scripts/init-minio.sh"
local args=(
"/scripts/init-minio.sh"
)

if ! /usr/bin/env bash "${script_path}" "${SCRIPT_DIRPATH}"; then
log_error "Encountered an error when executing ${script_path}, exiting..."
exit 1
fi
docker_compose -f "${DOCKER_COMPOSE_INIT_YML}" run \
--rm \
"${INIT_MC_SERVICE}" \
"${args[@]}"
}

###########################################################################################
Expand Down Expand Up @@ -544,7 +565,9 @@ main() {
init_scripts
init_extra_ca_certificates
init_named_volumes
start_minio_service
init_minio
stop_services
init_frontend
start_db_service
manage_postgres_ssl
Expand Down
Loading

0 comments on commit 9ca7a03

Please sign in to comment.