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.
This commit is contained in:
Girish Ramakrishnan 2022-01-21 13:28:02 -08:00
parent c0b9c4167f
commit 6162ff540b
4 changed files with 18 additions and 12 deletions

View File

@ -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 && \ 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 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" ] CMD [ "/app/code/start.sh" ]

View File

@ -34,3 +34,6 @@ npm install
PATH=$PATH:node_modules/.bin mocha --bail test.js PATH=$PATH:node_modules/.bin mocha --bail test.js
``` ```
## Notes
MinIO Console is an embedded web-based object browser built into MinIO Server

9
env.sh Normal file
View File

@ -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

View File

@ -4,29 +4,23 @@ set -eu
mkdir -p /app/data/data /run/minio/config /run/minio/certs 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 [[ ! -f /app/data/env.sh ]] && cp /app/code/env.sh /app/data/env.sh
# are actually in correct chown state source /app/data/env.sh
echo "==> Changing ownership"
[[ $(stat --format '%U' /app/data/data) != "cloudron" ]] && chown -R cloudron:cloudron /app/data
# https://docs.min.io/minio/baremetal/reference/minio-server/minio-server.html#envvar.MINIO_SERVER_URL # 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_SERVER_URL="https://${API_SERVER_DOMAIN}"
export MINIO_BROWSER_REDIRECT_URL="https://${CLOUDRON_APP_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 if [[ ! -d /app/data/mc_config ]]; then
echo "==> Set /app/data/mc default config dir"
mkdir -p /app/data/mc_config mkdir -p /app/data/mc_config
/app/code/mc --config-dir /app/data/mc_config &> /dev/null || true /app/code/mc --config-dir /app/data/mc_config &> /dev/null || true
fi 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 # 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" 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 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