-
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): add docker image for test supabase instance
- Add a new docker image `supabase-all-in-one` that will setup supabase instance for tests. - Supabase is used as a backend for Cactus GUI. Closes: #2253 Signed-off-by: Michal Bajer <michal.bajer@fujitsu.com>
- Loading branch information
Showing
8 changed files
with
167 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
FROM docker:20.10.21-dind | ||
|
||
ARG SUPABSE_TAG="v0.22.10" | ||
|
||
ENV FREEZE_TMP_DIR="/opt/docker-freeze" | ||
|
||
# Install package dependencies | ||
RUN apk update \ | ||
&& apk add --no-cache \ | ||
git \ | ||
curl \ | ||
jq \ | ||
bash \ | ||
supervisor | ||
|
||
WORKDIR /home | ||
RUN git clone --depth 1 --branch "${SUPABSE_TAG}" "https://github.com/supabase/supabase" | ||
|
||
WORKDIR /home/supabase/docker | ||
RUN cp .env.example .env | ||
|
||
# Freeze docker images | ||
COPY ./src/freeze-images.sh /usr/bin/freeze-images.sh | ||
RUN bash /usr/bin/freeze-images.sh | ||
|
||
# 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 | ||
EXPOSE 8000 | ||
EXPOSE 5432 | ||
|
||
# Setup supervisor entrypoint | ||
COPY ./src/run-supabase.sh /usr/bin/run-supabase.sh | ||
COPY ./src/supervisord.conf /etc/supervisord.conf | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# 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 | ||
- Password: `your-super-secret-and-long-postgres-password` | ||
|
||
### Docker Compose | ||
``` bash | ||
./script-start-docker.sh | ||
``` | ||
|
||
or manually: | ||
|
||
``` bash | ||
docker-compose build && docker-compose up -d | ||
``` | ||
|
||
### Docker | ||
> Excute from the cactus root or adjust the paths accordingly. | ||
``` bash | ||
# Build | ||
DOCKER_BUILDKIT=1 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 | ||
``` |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
version: "3.5" | ||
|
||
services: | ||
supabase-all-in-one-db: | ||
container_name: cactus-supabase-all-in-one-db | ||
image: cactus-supabase-all-in-one | ||
privileged: true | ||
build: | ||
context: ./ | ||
dockerfile: Dockerfile | ||
ports: | ||
- "3000:3000" # Supabase Studio | ||
- "8000:8000" # Supabase API | ||
- "5432:5432" # Postgres | ||
network_mode: host |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
echo "[process] Start docker environment for Supabase DB" | ||
docker-compose build && docker-compose up -d |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/bash | ||
|
||
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}" | ||
mkdir -p "${img_path}" | ||
bash "${FREEZE_SCRIPT_PATH}" "${img_path}" "${img}" | ||
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
# Check if supabase schemas has been added | ||
schema_count=$(docker exec supabase-db psql -U postgres -c '\du' | grep supabase | wc -l) | ||
if [ $schema_count -lt 3 ]; then exit 2; fi | ||
|
||
# TODO - can be improved by checking endpoints (if current one causes troubles) | ||
|
||
exit 0 |
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
|
||
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}` | ||
do | ||
echo "Load frozen image '${img}'" | ||
tar -cC "${FREEZE_TMP_DIR}/${img}" . | docker load | ||
done | ||
|
||
echo "Frozen images loaded" | ||
|
||
docker compose -f /home/supabase/docker/docker-compose.yml up |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
[supervisord] | ||
logfile = /var/log/supervisord.log | ||
logfile_maxbytes = 50MB | ||
logfile_backups=10 | ||
loglevel = info | ||
|
||
[program:dockerd] | ||
command=dockerd-entrypoint.sh | ||
autostart=true | ||
autorestart=true | ||
stderr_logfile=/dev/stderr | ||
stderr_logfile_maxbytes=0 | ||
stdout_logfile=/dev/stdout | ||
stdout_logfile_maxbytes=0 | ||
priority=1 | ||
|
||
[program:supabase] | ||
command=/usr/bin/run-supabase.sh | ||
autostart=true | ||
autorestart=unexpected | ||
stderr_logfile=/dev/stderr | ||
stderr_logfile_maxbytes=0 | ||
stdout_logfile=/dev/stdout | ||
stdout_logfile_maxbytes=0 |