I'd like to have my basic database built using *.sql script placed in /docker-entrypoint-initdb.d/
My SQL files look like this:
create schema crm;
alter schema crm owner to ${CRM_SCHEMA_OWNER};
....
Of course, importing using psql does not resolve the variable. My question is now, how could I use environment variables like this?
I tried around having also a .sh file in the entrypoint directory, replacing the strings in the .sql file with environment data, but I always get:
db_1 | sed: couldn't open temporary file /docker-entrypoint-initdb.d/sedjKqYgZ: Permission denied
I even tried
COPY sql/*.sql /mydata/
RUN ln -sf /mydata/*.sql /docker-entrypoint-initdb.d/
in the Dockerfile and in my .sh script in /docker-entrypoint-initdb.d/
sed -i "s/__CRM_SCHEMA_OWNER__/$CRM_SCHEMA_OWNER/g" /mydata/01_create_crm.sql
but this also did not work.
Any suggestions on how to use env variables for setting up a DB?
Thanks Fritz