Skip to content

Openverse is a search engine for openly-licensed media. This monorepo includes all application code.

Extract entrypoints to separate shell scripts (#1926)

Arun Chib52e136c47ea4
diff --git a/docker-compose.yml b/docker-compose.yml
index f9d80b8e0..3304ac042 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -72,18 +72,12 @@ services:
env_file:
- .env
- docker/minio/.env
- # Create empty buckets on every container startup
- # Note: $0 is included in the exec because "/bin/bash -c" swallows the first
- # argument, so it must be re-added at the beginning of the exec call
- entrypoint: >-
- /bin/bash -c
- "for b in $${BUCKETS_TO_CREATE//,/ }; do
- echo \"Making bucket $$b\" && mkdir -p /data/$$b;
- done &&
- exec $$0 \"$$@\""
+
command: minio server /data --address :5000 --console-address :5001
volumes:
- minio:/data
+ - ./docker/minio/s3_entrypoint.sh:/opt/minio/s3_entrypoint.sh:ro
+ entrypoint: /opt/minio/s3_entrypoint.sh
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:5010/minio/health/live"]
interval: 30s
@@ -104,25 +98,8 @@ services:
# Buckets for testing provider data imported from s3 are subdirectories under
# /tests/s3-data/
- ./catalog/tests/s3-data:/data:rw
- # Loop through subdirectories mounted to the volume and load them to s3/minio.
- # This takes care of filesystem delays on some local dev environments that may make
- # minio miss files included directly in the minio volume.
- # More info here: https://stackoverflow.com/questions/72867045
- # This does *not* allow for testing permissions issues that may come up in real AWS.
- # And, if you remove files from /tests/s3-data, you will need to use `just down -v`
- # and `just up` or `just recreate` to see the minio bucket without those files.
- entrypoint: >
- /bin/sh -c "
- /usr/bin/mc config host add s3 http://s3:5000 $${AWS_ACCESS_KEY} $${AWS_SECRET_KEY};
- cd /data;
- for b in */ ; do
- echo \"Loading bucket $$b\"
- /usr/bin/mc mb --ignore-existing s3/$$b
- /usr/bin/mc cp --r $$b s3/$$b
- /usr/bin/mc ls s3/$$b;
- done ;
- exit 0;
- "
+ - ./docker/minio/load_to_s3_entrypoint.sh:/opt/minio/load_to_s3_entrypoint.sh:ro
+ entrypoint: /opt/minio/load_to_s3_entrypoint.sh
# Dev changes for the scheduler
scheduler:
diff --git a/docker/minio/load_to_s3_entrypoint.sh b/docker/minio/load_to_s3_entrypoint.sh
new file mode 100755
index 000000000..67e53e39c
--- /dev/null
+++ b/docker/minio/load_to_s3_entrypoint.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+# This does *not* allow for testing permissions issues that may come up in real AWS.
+# And, if you remove files from /tests/s3-data, you will need to use `just down -v`
+# and `just up` or `just recreate` to see the minio bucket without those files.
+# Loop through subdirectories mounted to the volume and load them to s3/minio.
+# This takes care of filesystem delays on some local dev environments that may make
+# minio miss files included directly in the minio volume.
+# More info here: https://stackoverflow.com/questions/72867045
+set -euxo pipefail
+
+/usr/bin/mc config host add s3 http://s3:5000 "${AWS_ACCESS_KEY}" "${AWS_SECRET_KEY}"
+cd /data
+for b in */; do
+ echo "Loading bucket $b"
+ /usr/bin/mc mb --ignore-existing s3/"$b"
+ /usr/bin/mc cp --r "$b" s3/"$b"
+ /usr/bin/mc ls s3/"$b"
+done
+exit 0
diff --git a/docker/minio/s3_entrypoint.sh b/docker/minio/s3_entrypoint.sh
new file mode 100755
index 000000000..d47ecf561
--- /dev/null
+++ b/docker/minio/s3_entrypoint.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+# Create empty buckets on every container startup
+set -euxo pipefail
+for b in ${BUCKETS_TO_CREATE//,/ }; do
+ echo "Making bucket $b" && mkdir -p /data/"$b"
+done
+exec "$@"