Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ops/aas with minio gateway #15587

Merged
merged 11 commits into from
Feb 21, 2025
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
scripts/resources/minio filter=lfs diff=lfs merge=lfs -text
9 changes: 7 additions & 2 deletions hosting/single/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ARG BASEIMG=budibase/couchdb:v3.3.3-sqs-v2.1.1
FROM node:20-slim as build
FROM node:20-slim AS build

# install node-gyp dependencies
RUN apt-get update && apt-get install -y --no-install-recommends g++ make python3 jq
Expand Down Expand Up @@ -34,7 +34,7 @@ COPY packages/worker/dist packages/worker/dist
COPY packages/worker/pm2.config.js packages/worker/pm2.config.js


FROM $BASEIMG as runner
FROM $BASEIMG AS runner
ARG TARGETARCH
ENV TARGETARCH $TARGETARCH
#TARGETBUILD can be set to single (for single docker image) or aas (for azure app service)
Expand Down Expand Up @@ -67,6 +67,11 @@ RUN mkdir -p /var/log/nginx && \

# setup minio
WORKDIR /minio

# a 2022 version of minio that supports gateway mode
COPY scripts/resources/minio /minio

# handles the installation of minio in non-aas environments
COPY scripts/install-minio.sh ./install.sh
RUN chmod +x install.sh && ./install.sh

Expand Down
47 changes: 24 additions & 23 deletions hosting/single/runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,7 @@ declare -a DOCKER_VARS=("APP_PORT" "APPS_URL" "ARCHITECTURE" "BUDIBASE_ENVIRONME
[[ -z "${SERVER_TOP_LEVEL_PATH}" ]] && export SERVER_TOP_LEVEL_PATH=/app
# export CUSTOM_DOMAIN=budi001.custom.com

# Azure App Service customisations
if [[ "${TARGETBUILD}" = "aas" ]]; then
export DATA_DIR="${DATA_DIR:-/home}"
WEBSITES_ENABLE_APP_SERVICE_STORAGE=true
/etc/init.d/ssh start
else
export DATA_DIR=${DATA_DIR:-/data}
fi
export DATA_DIR=${DATA_DIR:-/data}
mkdir -p ${DATA_DIR}
# Mount NFS or GCP Filestore if env vars exist for it
if [[ ! -z ${FILESHARE_IP} && ! -z ${FILESHARE_NAME} ]]; then
Expand All @@ -42,8 +35,7 @@ if [ -f "${DATA_DIR}/.env" ]; then
for LINE in $(cat ${DATA_DIR}/.env); do export $LINE; done
fi
# randomise any unset environment variables
for ENV_VAR in "${ENV_VARS[@]}"
do
for ENV_VAR in "${ENV_VARS[@]}"; do
if [[ -z "${!ENV_VAR}" ]]; then
eval "export $ENV_VAR=$(uuidgen | sed -e 's/-//g')"
fi
Expand All @@ -58,17 +50,15 @@ fi

if [ ! -f "${DATA_DIR}/.env" ]; then
touch ${DATA_DIR}/.env
for ENV_VAR in "${ENV_VARS[@]}"
do
for ENV_VAR in "${ENV_VARS[@]}"; do
temp=$(eval "echo \$$ENV_VAR")
echo "$ENV_VAR=$temp" >> ${DATA_DIR}/.env
echo "$ENV_VAR=$temp" >>${DATA_DIR}/.env
done
for ENV_VAR in "${DOCKER_VARS[@]}"
do
for ENV_VAR in "${DOCKER_VARS[@]}"; do
temp=$(eval "echo \$$ENV_VAR")
echo "$ENV_VAR=$temp" >> ${DATA_DIR}/.env
echo "$ENV_VAR=$temp" >>${DATA_DIR}/.env
done
echo "COUCH_DB_URL=${COUCH_DB_URL}" >> ${DATA_DIR}/.env
echo "COUCH_DB_URL=${COUCH_DB_URL}" >>${DATA_DIR}/.env
fi

# Read in the .env file and export the variables
Expand All @@ -79,31 +69,42 @@ ln -s ${DATA_DIR}/.env /worker/.env
# make these directories in runner, incase of mount
mkdir -p ${DATA_DIR}/minio
mkdir -p ${DATA_DIR}/redis
chown -R couchdb:couchdb ${DATA_DIR}/couch
#mkdir -p ${DATA_DIR}/couch
#chown -R couchdb:couchdb ${DATA_DIR}/couch

REDIS_CONFIG="/etc/redis/redis.conf"
sed -i "s#DATA_DIR#${DATA_DIR}#g" "${REDIS_CONFIG}"

if [[ -n "${USE_DEFAULT_REDIS_CONFIG}" ]]; then
REDIS_CONFIG=""
REDIS_CONFIG=""
fi

if [[ -n "${REDIS_PASSWORD}" ]]; then
redis-server "${REDIS_CONFIG}" --requirepass $REDIS_PASSWORD > /dev/stdout 2>&1 &
redis-server "${REDIS_CONFIG}" --requirepass $REDIS_PASSWORD >/dev/stdout 2>&1 &
else
redis-server "${REDIS_CONFIG}" > /dev/stdout 2>&1 &
redis-server "${REDIS_CONFIG}" >/dev/stdout 2>&1 &
fi
/bbcouch-runner.sh &

# only start minio if use s3 isn't passed
if [[ -z "${USE_S3}" ]]; then
/minio/minio server --console-address ":9001" ${DATA_DIR}/minio > /dev/stdout 2>&1 &
if [[ $TARGETBUILD == aas ]]; then
echo "Starting MinIO in Azure Gateway mode"
if [[ -z "${AZURE_STORAGE_ACCOUNT}" || -z "${AZURE_STORAGE_KEY}" ]]; then
echo "AZURE_STORAGE_ACCOUNT and AZURE_STORAGE_KEY must be set when deploying in Azure App Service mode"
exit 1
fi
/minio/minio gateway azure --console-address ":9001" >/dev/stdout 2>&1 &
else
echo "Starting MinIO in standalone mode"
/minio/minio server --console-address ":9001" ${DATA_DIR}/minio >/dev/stdout 2>&1 &
fi
fi

/etc/init.d/nginx restart
if [[ ! -z "${CUSTOM_DOMAIN}" ]]; then
# Add monthly cron job to renew certbot certificate
echo -n "* * 2 * * root exec /app/letsencrypt/certificate-renew.sh ${CUSTOM_DOMAIN}" >> /etc/cron.d/certificate-renew
echo -n "* * 2 * * root exec /app/letsencrypt/certificate-renew.sh ${CUSTOM_DOMAIN}" >>/etc/cron.d/certificate-renew
chmod +x /etc/cron.d/certificate-renew
# Request the certbot certificate
/app/letsencrypt/certificate-request.sh ${CUSTOM_DOMAIN}
Expand Down
14 changes: 11 additions & 3 deletions scripts/install-minio.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
#!/bin/bash
if [[ $TARGETARCH == arm* ]] ;
then

if [[ $TARGETBUILD == "aas" ]]; then
echo "A aas-compatible version of Minio is already installed."
exit 0
fi

if [[ $TARGETARCH == arm* ]]; then
echo "INSTALLING ARM64 MINIO"
rm -f minio
wget https://dl.min.io/server/minio/release/linux-arm64/minio
else
echo "INSTALLING AMD64 MINIO"
rm -f minio
wget https://dl.min.io/server/minio/release/linux-amd64/minio
fi
chmod +x minio

chmod +x minio
3 changes: 3 additions & 0 deletions scripts/resources/minio
Git LFS file not shown
Loading