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 7, 2023
1 parent 8f2dad6 commit edd655f
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 7 deletions.
18 changes: 11 additions & 7 deletions docker/orioledb/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1023,6 +1023,7 @@ COPY ansible/files/walg_helper_scripts/wal_change_ownership.sh /root/wal_change_
RUN sed -i \
-e "s|#unix_socket_directories = '/tmp'|unix_socket_directories = '/var/run/postgresql'|g" \
-e "s|#session_preload_libraries = ''|session_preload_libraries = 'supautils'|g" \
-e "s|shared_preload_libraries = '\(.*\)'|shared_preload_libraries = '\1, orioledb'|" \
-e "s|#include = '/etc/postgresql-custom/supautils.conf'|include = '/etc/postgresql-custom/supautils.conf'|g" \
-e "s|#include = '/etc/postgresql-custom/wal-g.conf'|include = '/etc/postgresql-custom/wal-g.conf'|g" /etc/postgresql/postgresql.conf && \
echo "cron.database_name = 'postgres'" >> /etc/postgresql/postgresql.conf && \
Expand All @@ -1044,6 +1045,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
Expand Down
32 changes: 32 additions & 0 deletions docker/orioledb/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash
set -eou pipefail

PG_CONF=/etc/postgresql/postgresql.conf

function configure_orioledb {
echo "Configuring OrioleDB..."

sed -i \
-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 edd655f

Please sign in to comment.