-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: customized timescaledb docker image
- Loading branch information
0 parents
commit 0ae139e
Showing
2 changed files
with
65 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,38 @@ | ||
# TimescaleDB tools | ||
FROM docker.io/library/golang:alpine AS timescaledb-tools | ||
|
||
RUN apk update && apk add --no-cache git gcc musl-dev \ | ||
&& go install github.com/timescale/timescaledb-tune/cmd/timescaledb-tune@latest \ | ||
&& go install github.com/timescale/timescaledb-parallel-copy/cmd/timescaledb-parallel-copy@latest | ||
|
||
# TimescaleDB extension | ||
FROM docker.io/timescale/timescaledb:2.16.1-pg16-bitnami AS timescaledb | ||
|
||
# Copy the last 3 versions of the extension | ||
RUN cd /opt/bitnami/postgresql/lib \ | ||
&& cp timescaledb.so /tmp \ | ||
&& cp -r $(ls . | grep timescaledb- | sort | tail -n 3) /tmp \ | ||
&& cp -r $(ls . | grep timescaledb-tsl- | sort | tail -n 3) /tmp \ | ||
&& cd /opt/bitnami/postgresql/share/extension \ | ||
&& cp -r $(ls . | grep timescaledb | grep .sql) /tmp | ||
|
||
# PostgreSQL Server | ||
FROM docker.io/bitnami/postgresql:16.4.0 AS postgresql | ||
|
||
# TimescaleDB tools | ||
COPY --from=timescaledb-tools /go/bin/* /usr/local/bin/ | ||
|
||
# TimescaleDB extension (We will install last 3 versions) | ||
COPY --from=timescaledb /tmp/*.so /opt/bitnami/postgresql/lib/ | ||
|
||
# TimescaleDB upgrade and downgrade scripts | ||
COPY --from=timescaledb /tmp/*.sql /opt/bitnami/postgresql/share/extension/ | ||
|
||
# TimescaleDB initialization scripts | ||
COPY --from=timescaledb /docker-entrypoint-initdb.d/*.sh /docker-entrypoint-initdb.d/ | ||
|
||
# Entrypoint | ||
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh | ||
|
||
ENTRYPOINT [ "docker-entrypoint.sh" ] | ||
CMD [ "/opt/bitnami/scripts/postgresql/run.sh" ] |
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,27 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Load PostgeSQL environment variables and Bitnami Logging Libraty | ||
. /opt/bitnami/scripts/postgresql-env.sh | ||
. /opt/bitnami/scripts/liblog.sh | ||
|
||
# We have to use the bitnami configuration variable to add timescaledb to | ||
# shared preload list, or else it gets overwritten. | ||
if [ -z "$POSTGRESQL_SHARED_PRELOAD_LIBRARIES" ] | ||
then | ||
POSTGRESQL_SHARED_PRELOAD_LIBRARIES=timescaledb | ||
else | ||
POSTGRESQL_SHARED_PRELOAD_LIBRARIES="$POSTGRESQL_SHARED_PRELOAD_LIBRARIES,timescaledb" | ||
fi | ||
export POSTGRESQL_SHARED_PRELOAD_LIBRARIES | ||
|
||
# If it's already init, run timescaledb-tune again (to update the config if needed) | ||
if [ -f "$POSTGRESQL_VOLUME_DIR/.user_scripts_initialized" ]; then | ||
# Run timescaledb-tune script | ||
info "Running timescaledb-tune to update the configuration..." | ||
/docker-entrypoint-initdb.d/001_timescaledb_tune.sh | ||
info "timescaledb-tune finished" | ||
fi | ||
|
||
# Fall through to the original entrypoint. Note that we use exec here because | ||
# this wrapper script shouldn't change PID 1 of the container. | ||
exec "/opt/bitnami/scripts/postgresql/entrypoint.sh" "$@" |