-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(supabase-all-in-one): update versions, use skopeo
- Use latest supabase and container base versions. - Use skopeo to freeze images, fetch the containers in separate build phase. - Add anonymous volume definitions in dockerfile to speedup default runtime. Closes #3099 Signed-off-by: Michal Bajer <michal.bajer@fujitsu.com>
- Loading branch information
Showing
4 changed files
with
80 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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." | ||
echo "Image freeze done." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
# Run | ||
docker compose -f "${APP_ROOT}/docker-compose.yml" up |