From 6162ff540b03500cb95307e707c29c0a81519cfa Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Fri, 21 Jan 2022 13:28:02 -0800 Subject: [PATCH] Fix root password init We can now use MINIO_ROOT_USER and MINIO_ROOT_PASSWORD env vars. These default to minioadmin. When set, it will change/update the password. When not set, it keeps the old password from the last run. --- Dockerfile | 2 +- README.md | 3 +++ env.sh | 9 +++++++++ start.sh | 16 +++++----------- 4 files changed, 18 insertions(+), 12 deletions(-) create mode 100644 env.sh diff --git a/Dockerfile b/Dockerfile index b03af41..332cc67 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,6 +9,6 @@ ARG MC_VERSION=RELEASE.2022-01-07T06-01-38Z RUN wget https://dl.min.io/server/minio/release/linux-amd64/minio.${VERSION} -O /app/code/minio && chmod +x /app/code/minio && \ wget https://dl.min.io/client/mc/release/linux-amd64/mc.${MC_VERSION} -O /app/code/mc && chmod +x /app/code/mc -COPY minio-credentials start.sh /app/code/ +COPY env.sh minio-credentials start.sh /app/code/ CMD [ "/app/code/start.sh" ] diff --git a/README.md b/README.md index c5f6936..ff9a82c 100644 --- a/README.md +++ b/README.md @@ -34,3 +34,6 @@ npm install PATH=$PATH:node_modules/.bin mocha --bail test.js ``` +## Notes + +MinIO Console is an embedded web-based object browser built into MinIO Server diff --git a/env.sh b/env.sh new file mode 100644 index 0000000..6aad718 --- /dev/null +++ b/env.sh @@ -0,0 +1,9 @@ +# Add custom minio configuration to this file. Restart the app for changes to take effect. + +export CLOUDRON_MINIO_STARTUP_ARGS='server /app/data/data' + +# See https://docs.min.io/minio/baremetal/reference/minio-server/minio-server.html#envvar.MINIO_ROOT_USER +# You can use pwgen -1s 64 to generate usernames and passwords +export MINIO_ROOT_USER=minioadmin +export MINIO_ROOT_PASSWORD=minioadmin + diff --git a/start.sh b/start.sh index 7655f58..62c5b33 100755 --- a/start.sh +++ b/start.sh @@ -4,29 +4,23 @@ set -eu mkdir -p /app/data/data /run/minio/config /run/minio/certs -# minio is used for backups at times and has a large number of files. optimize by checking if files -# are actually in correct chown state -echo "==> Changing ownership" -[[ $(stat --format '%U' /app/data/data) != "cloudron" ]] && chown -R cloudron:cloudron /app/data +[[ ! -f /app/data/env.sh ]] && cp /app/code/env.sh /app/data/env.sh +source /app/data/env.sh # https://docs.min.io/minio/baremetal/reference/minio-server/minio-server.html#envvar.MINIO_SERVER_URL export MINIO_SERVER_URL="https://${API_SERVER_DOMAIN}" export MINIO_BROWSER_REDIRECT_URL="https://${CLOUDRON_APP_DOMAIN}" -if [[ ! -f /app/data/env.sh ]]; then - echo -e "# Add custom minio configuration to this file. Restart the app for changes to take effect.\n\nexport CLOUDRON_MINIO_STARTUP_ARGS='server /app/data/data'" > /app/data/env.sh -fi - if [[ ! -d /app/data/mc_config ]]; then - echo "==> Set /app/data/mc default config dir" mkdir -p /app/data/mc_config /app/code/mc --config-dir /app/data/mc_config &> /dev/null || true fi -source /app/data/env.sh +# minio is used for backups at times and has a large number of files. optimize by checking if files are actually in correct chown state +echo "==> Changing ownership" +[[ $(stat --format '%U' /app/data/data) != "cloudron" ]] && chown -R cloudron:cloudron /app/data # the --config-dir is deprecated and not used. but without it, minio will try to create $HOME/.minio :/ same for --certs-dir -# MinIO Console is an embedded web-based object browser built into MinIO Server echo "==> Starting minio" exec /usr/local/bin/gosu cloudron:cloudron /app/code/minio --certs-dir /run/minio/certs --config-dir /run/minio/config --quiet ${CLOUDRON_MINIO_STARTUP_ARGS} --address :9000 --console-address :8000