[docker] postgresql with timescaledb
作者:互联网
Dockerfile
FROM timescale/timescaledb:latest-pg14 RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo "Asia/Shanghai" > /etc/timezone
docker build
docker build -t timescaledb-pg14:1.0 .
docker run
docker run -itd -p 5432:5432 --name psql-test --restart=always -e POSTGRES_USER=user -e POSTGRES_PASSWORD=password -v /home/psql/data:/var/lib/postgresql/data timescaledb-pg14:1.0
参考:
https://raw.githubusercontent.com/timescale/timescaledb-docker/main/Dockerfile
Dockerfile记录
ARG PG_VERSION ARG PREV_IMAGE ARG TS_VERSION ############################ # Build tools binaries in separate image ############################ ARG GO_VERSION=1.14.0 FROM golang:${GO_VERSION}-alpine AS tools ENV TOOLS_VERSION 0.8.1 RUN apk update && apk add --no-cache git \ && go get github.com/timescale/timescaledb-tune/cmd/timescaledb-tune \ && go get github.com/timescale/timescaledb-parallel-copy/cmd/timescaledb-parallel-copy \ && go get github.com/timescale/timescaledb-backup/cmd/ts-dump \ && go get github.com/timescale/timescaledb-backup/cmd/ts-restore \ && go build -o /go/bin/timescaledb-tune -v github.com/timescale/timescaledb-tune/cmd/timescaledb-tune \ && go build -o /go/bin/timescaledb-parallel-copy -v github.com/timescale/timescaledb-parallel-copy/cmd/timescaledb-parallel-copy \ && go build -o /go/bin/ts-dump -v github.com/timescale/timescaledb-backup/cmd/ts-dump \ && go build -o /go/bin/ts-restore -v github.com/timescale/timescaledb-backup/cmd/ts-restore ############################ # Grab old versions from previous version ############################ ARG PG_VERSION ARG PREV_IMAGE FROM ${PREV_IMAGE} AS oldversions # Remove update files, mock files, and all but the last 5 .so/.sql files RUN rm -f $(pg_config --sharedir)/extension/timescaledb*mock*.sql \ && if [ -f $(pg_config --pkglibdir)/timescaledb-tsl-1*.so ]; then rm -f $(ls -1 $(pg_config --pkglibdir)/timescaledb-tsl-1*.so | head -n -5); fi \ && if [ -f $(pg_config --pkglibdir)/timescaledb-1*.so ]; then rm -f $(ls -1 $(pg_config --pkglibdir)/timescaledb-*.so | head -n -5); fi \ && if [ -f $(pg_config --sharedir)/extension/timescaledb--1*.sql ]; then rm -f $(ls -1 $(pg_config --sharedir)/extension/timescaledb--1*.sql | head -n -5); fi ############################ # Now build image and copy in tools ############################ ARG PG_VERSION FROM postgres:${PG_VERSION}-alpine ARG OSS_ONLY LABEL maintainer="Timescale https://www.timescale.com" COPY docker-entrypoint-initdb.d/* /docker-entrypoint-initdb.d/ COPY --from=tools /go/bin/* /usr/local/bin/ COPY --from=oldversions /usr/local/lib/postgresql/timescaledb-*.so /usr/local/lib/postgresql/ COPY --from=oldversions /usr/local/share/postgresql/extension/timescaledb--*.sql /usr/local/share/postgresql/extension/ ARG TS_VERSION RUN set -ex \ && apk add --no-cache --virtual .fetch-deps \ ca-certificates \ git \ openssl \ openssl-dev \ tar \ && mkdir -p /build/ \ && git clone https://github.com/timescale/timescaledb /build/timescaledb \ \ && apk add --no-cache --virtual .build-deps \ coreutils \ dpkg-dev dpkg \ gcc \ krb5-dev \ libc-dev \ make \ cmake \ util-linux-dev \ \ # Build current version \ && cd /build/timescaledb && rm -fr build \ && git checkout ${TS_VERSION} \ && ./bootstrap -DCMAKE_BUILD_TYPE=RelWithDebInfo -DREGRESS_CHECKS=OFF -DTAP_CHECKS=OFF -DGENERATE_DOWNGRADE_SCRIPT=ON -DWARNINGS_AS_ERRORS=OFF -DPROJECT_INSTALL_METHOD="docker"${OSS_ONLY} \ && cd build && make install \ && cd ~ \ \ && if [ "${OSS_ONLY}" != "" ]; then rm -f $(pg_config --pkglibdir)/timescaledb-tsl-*.so; fi \ && apk del .fetch-deps .build-deps \ && rm -rf /build \ && sed -r -i "s/[#]*\s*(shared_preload_libraries)\s*=\s*'(.*)'/\1 = 'timescaledb,\2'/;s/,'/'/" /usr/local/share/postgresql/postgresql.conf.sample
标签:postgresql,timescale,--,timescaledb,build,&&,go,docker 来源: https://www.cnblogs.com/Primzahl/p/16381591.html