Giter VIP home page Giter VIP logo

Comments (3)

Romathonat avatar Romathonat commented on May 19, 2024

Hello,
I had the same problem and struggled with this way too long.
The probleme is that you add an init file to /docker-entrypoint-initdb.d : if you look at the Dockerfile of postgres, you will see that this docker-entrypoint launch your init files before using timescaledb as a dependency !

In order to fix that, I created another container, expecially for the init of the db, it looks like this :

FROM debian:jessie
RUN apt-get update && apt-get install -y netcat

# in order to have psql
RUN apt-get install -y postgresql-client

ADD ./init_schema.sql /
ADD ./start.sh /start.sh

CMD ["/start.sh"]

and the start.sh looks like this :

#!/bin/sh

while ! nc -z postgres 5432;do sleep 3;done

# now that the database is up, we can log into it and launch the init
PGPASSWORD=my password psql -h name_in_docker_compose -U user database< init_schema.sql

echo 'init done'

The part with the while is here to be sure the database is up before filling it with data.

version: '3'
services:
  postgres:
    build:
      context: ./postgres
    container_name: postgres

  postgres_init:
    build:
      context: ./postgres/postgres_init
    container_name: postgres_init
    depends_on:
      - postgres

I also put the command "postgres -c shared_preload_libraries=timescaledb" in the dockerfile as CMD [...] instead of the docker-compose.

This workaround works but it is not really clean, I admit, but it works until we find something better.

from timescaledb.

RobAtticus avatar RobAtticus commented on May 19, 2024

Hi, we just released a new version (0.0.12-beta) that also included a new build process for Docker images (using the timescale/timescaledb-docker repo). This should have streamlined the build image, so maybe give it a try and see if it works better with Docker Compose? If not we can do some more investigating.

from timescaledb.

Romathonat avatar Romathonat commented on May 19, 2024

I tested it today, it works perfectly, good job. Now you can add you init scripts to /docker-entrypoint-initdb.d in the timescaledb docker, postgres will use it correctly (without saying that it can't use plugin timescaledb or whatever)

from timescaledb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.