Skip to content

Commit

Permalink
feat: add s3 config script
Browse files Browse the repository at this point in the history
  • Loading branch information
sweatybridge committed Dec 4, 2023

Verified

This commit was signed with the committer’s verified signature.
r-n-o Arnaud
1 parent a406c57 commit 6c8eabe
Showing 2 changed files with 41 additions and 7 deletions.
17 changes: 10 additions & 7 deletions docker/orioledb/Dockerfile
Original file line number Diff line number Diff line change
@@ -77,10 +77,10 @@ ARG CACHE_EPOCH
FROM builder as rust-toolchain
ENV PATH=/root/.cargo/bin:$PATH
RUN apt-get update && apt-get install -y --no-install-recommends curl pkg-config && \
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path --profile minimal --default-toolchain stable && \
rustup --version && \
rustc --version && \
cargo --version
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path --profile minimal --default-toolchain stable && \
rustup --version && \
rustc --version && \
cargo --version

RUN cargo install cargo-pgrx --version 0.10.2 --locked
RUN cargo pgrx init --pg${postgresql_major} $(which pg_config)
@@ -562,7 +562,7 @@ FROM rust-toolchain as pg_graphql-source
ARG pg_graphql_release
ARG pg_graphql_release_checksum
ADD --checksum=${pg_graphql_release_checksum} \
"https://github.com/supabase/pg_graphql/archive/refs/tags/v${pg_graphql_release}.tar.gz" \
"https://github.com/supabase/pg_graphql/archive/refs/tags/v${pg_graphql_release}.tar.gz" \
/tmp/pg_graphql.tar.gz
RUN tar -xvf /tmp/pg_graphql.tar.gz -C /tmp && \
rm -rf /tmp/pg_graphql.tar.gz
@@ -642,7 +642,7 @@ FROM rust-toolchain as pg_jsonschema-source
ARG pg_jsonschema_release
ARG pg_jsonschema_release_checksum
ADD --checksum=${pg_jsonschema_release_checksum} \
"https://github.com/supabase/pg_jsonschema/archive/refs/tags/v${pg_jsonschema_release}.tar.gz" \
"https://github.com/supabase/pg_jsonschema/archive/refs/tags/v${pg_jsonschema_release}.tar.gz" \
/tmp/pg_jsonschema.tar.gz
RUN tar -xvf /tmp/pg_jsonschema.tar.gz -C /tmp && \
rm -rf /tmp/pg_jsonschema.tar.gz
@@ -768,7 +768,7 @@ FROM rust-toolchain as wrappers-source
ARG wrappers_release
ARG wrappers_release_checksum
ADD --checksum=${wrappers_release_checksum} \
"https://github.com/supabase/wrappers/archive/refs/tags/v${wrappers_release}.tar.gz" \
"https://github.com/supabase/wrappers/archive/refs/tags/v${wrappers_release}.tar.gz" \
/tmp/wrappers.tar.gz
RUN tar -xvf /tmp/wrappers.tar.gz -C /tmp && \
rm -rf /tmp/wrappers.tar.gz
@@ -1044,6 +1044,9 @@ RUN sed -i \
-e "s|PGHOST= PGHOSTADDR=|PGHOST=\$POSTGRES_HOST|g" \
/usr/local/bin/docker-entrypoint.sh

COPY docker/orioledb/entrypoint.sh /
ENTRYPOINT ["/entrypoint.sh"]

HEALTHCHECK --interval=2s --timeout=2s --retries=10 CMD pg_isready -U postgres -h localhost
STOPSIGNAL SIGINT
EXPOSE 5432
31 changes: 31 additions & 0 deletions docker/orioledb/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash
set -eou pipefail

PG_CONF=/etc/postgresql/postgresql.conf

function configure_orioledb {
sed -i \
-e "s|shared_preload_libraries = '\(.*\)'|shared_preload_libraries = '\1, orioledb'|" \
-e "s|#max_worker_processes = .*|max_worker_processes = 50 # should fit orioledb.s3_num_workers as long as other workers|" \
-e "s|#log_min_messages = .*|log_min_messages = debug1 # will log all S3 requests|" \
-e "s|#archive_mode = off \(.*\)|archive_mode = on \1|" \
"$PG_CONF"

echo "
archive_library = 'orioledb'
orioledb.main_buffers = 1GB
orioledb.undo_buffers = 256MB
orioledb.s3_num_workers = 20 # should be enough for comfortable work
orioledb.s3_mode = true
orioledb.s3_host = '$S3_HOST' # replace with your bucket URL, accelerated buckets are recommended
orioledb.s3_region = '$S3_REGION' # replace with your S3 region
orioledb.s3_accesskey = '$S3_ACCESS_KEY' # replace with your S3 key
orioledb.s3_secretkey = '$S3_SECRET_KEY' # replace with your S3 secret key
" >> "$PG_CONF"
}

if ! grep -q orioledb "$PG_CONF"; then
configure_orioledb
fi

docker-entrypoint.sh "$@"

0 comments on commit 6c8eabe

Please sign in to comment.