diff --git a/tools/docker/supabase-all-in-one/Dockerfile b/tools/docker/supabase-all-in-one/Dockerfile index 56a757acc1..9d968dc8b1 100644 --- a/tools/docker/supabase-all-in-one/Dockerfile +++ b/tools/docker/supabase-all-in-one/Dockerfile @@ -1,40 +1,71 @@ -FROM docker:24.0.2-dind +################################ +# Common Args +################################ -ARG SUPABSE_TAG="v0.22.10" +ARG supabase_tag="v0.24.03" +ARG freeze_tmp_dir="/opt/docker-freeze" -ENV FREEZE_TMP_DIR="/opt/docker-freeze" +################################ +# Build phase +################################ -# Install package dependencies -RUN apk update \ - && apk add --no-cache \ - git \ - curl \ - jq \ - bash \ - supervisor +FROM alpine:3.19.1 as builder + +ARG supabase_tag +ARG freeze_tmp_dir +ENV SUPABSE_TAG=$supabase_tag +ENV FREEZE_TMP_DIR=$freeze_tmp_dir -WORKDIR /home +RUN apk update && apk add --no-cache skopeo git curl + +WORKDIR "/build" RUN git clone --depth 1 --branch "${SUPABSE_TAG}" "https://github.com/supabase/supabase" -WORKDIR /home/supabase/docker -RUN cp .env.example .env +WORKDIR "/build/supabase/docker" +RUN mv .env.example .env # Freeze docker images COPY ./src/freeze-images.sh /usr/bin/freeze-images.sh -RUN bash /usr/bin/freeze-images.sh +RUN sh /usr/bin/freeze-images.sh + +################################ +# Runtime phase +################################ + +FROM docker:25.0.5-dind + +ARG freeze_tmp_dir +ENV FREEZE_TMP_DIR=$freeze_tmp_dir +ENV APP_ROOT="/home/supabase/docker" + +# Install package dependencies +RUN apk update \ + && apk add --no-cache \ + git \ + curl \ + jq \ + bash \ + supervisor + +COPY --from=builder $freeze_tmp_dir $freeze_tmp_dir +COPY --from=builder "/build/supabase/docker/" "$APP_ROOT" # Setup healtcheck COPY ./src/healthcheck.sh /bin/healthcheck RUN chmod +x /bin/healthcheck HEALTHCHECK --interval=5s --timeout=5s --start-period=45s --retries=90 CMD /bin/healthcheck -# Expose ledger ports -EXPOSE 3000 +# Supabase EXPOSE 8000 +# Postgres EXPOSE 5432 # Setup supervisor entrypoint COPY ./src/run-supabase.sh /usr/bin/run-supabase.sh COPY ./src/supervisord.conf /etc/supervisord.conf + +VOLUME /home/supabase/docker/volumes/db/data +VOLUME /home/supabase/docker/volumes/storage + ENTRYPOINT ["/usr/bin/supervisord"] CMD ["--configuration", "/etc/supervisord.conf", "--nodaemon"] diff --git a/tools/docker/supabase-all-in-one/README.md b/tools/docker/supabase-all-in-one/README.md index 946788cea2..32f6799fa2 100644 --- a/tools/docker/supabase-all-in-one/README.md +++ b/tools/docker/supabase-all-in-one/README.md @@ -1,35 +1,46 @@ # supabase-all-in-one An all in one supabase image that can be used as Cactus GUI backend. + - This docker image is for `testing` and `development` only. - **Do NOT use in production!** ## Usage + +### Dashboard credentials: + +- http://127.0.0.1:8000/ +- Username: supabase +- Password: this_password_is_insecure_and_should_be_updated + +### Postgress ccredentials: + - Password: `your-super-secret-and-long-postgres-password` ### Docker Compose -``` bash + +```bash ./script-start-docker.sh ``` or manually: -``` bash +```bash docker-compose build && docker-compose up -d ``` ### Docker + > Excute from the cactus root or adjust the paths accordingly. -``` bash +```bash # Build -DOCKER_BUILDKIT=1 docker build ./tools/docker/supabase-all-in-one -t cactus-supabase-all-in-one +docker build ./tools/docker/supabase-all-in-one -t cactus-supabase-all-in-one # Run docker run --name supabase_all_in_one_gui \ --detach \ --privileged \ - -p 3000:3000 \ -p 8000:8000 \ -p 5432:5432 \ cactus-supabase-all-in-one diff --git a/tools/docker/supabase-all-in-one/src/freeze-images.sh b/tools/docker/supabase-all-in-one/src/freeze-images.sh index 144607ecde..7d963b4753 100755 --- a/tools/docker/supabase-all-in-one/src/freeze-images.sh +++ b/tools/docker/supabase-all-in-one/src/freeze-images.sh @@ -1,21 +1,18 @@ -#!/bin/bash +#!/bin/sh set -e -FREEZE_SCRIPT_NAME="download-frozen-image-v2.sh" -FREEZE_SCRIPT_PATH="/usr/bin/${FREEZE_SCRIPT_NAME}" - -echo "Download freeze script..." -curl -sSL https://raw.githubusercontent.com/moby/moby/dedf8528a51c6db40686ed6676e9486d1ed5f9c0/contrib/download-frozen-image-v2.sh > "${FREEZE_SCRIPT_PATH}" -chmod +x "${FREEZE_SCRIPT_PATH}" - # Get list of images from docker-compose for img in `grep 'image:' docker-compose.yml | tr -d ' ' | cut -d':' -f2,3` do - img_path="${FREEZE_TMP_DIR}/${img/\//-}" - echo "Freeze image '${img}' in '${img_path}" + img_dir=$(echo "$img" | sed 's/[:\/]/-/g') # replace '\' and ':' with '-' + img_path="${FREEZE_TMP_DIR}/${img_dir}" + echo "Freeze image '${img}' in '${img_path}'" mkdir -p "${img_path}" - bash "${FREEZE_SCRIPT_PATH}" "${img_path}" "${img}" + + skopeo copy "docker://${img}" "docker-archive:${img_path}/archive.tar:${img}" + tar -zcf "${img_path}/archive.tar.gz" "${img_path}/archive.tar" + rm -fr "${img_path}/archive.tar" done -echo "Image freeze done." \ No newline at end of file +echo "Image freeze done." diff --git a/tools/docker/supabase-all-in-one/src/run-supabase.sh b/tools/docker/supabase-all-in-one/src/run-supabase.sh index 6f94a5c7bf..3dfee8864b 100755 --- a/tools/docker/supabase-all-in-one/src/run-supabase.sh +++ b/tools/docker/supabase-all-in-one/src/run-supabase.sh @@ -1,18 +1,21 @@ #!/bin/bash +# Wait for docker while ! docker ps &> /dev/null do echo "Wait for dockerd to start..." sleep 3 done -# Get list of images from docker-compose -for img in `ls ${FREEZE_TMP_DIR}` +# Load frozen images + +for img in `find "${FREEZE_TMP_DIR}" -name "*.tar.gz"` do echo "Load frozen image '${img}'" - tar -cC "${FREEZE_TMP_DIR}/${img}" . | docker load + tar -zxf "${img}" -O | docker load done echo "Frozen images loaded" -docker compose -f /home/supabase/docker/docker-compose.yml up \ No newline at end of file +# Run +docker compose -f "${APP_ROOT}/docker-compose.yml" up