sqitchers / docker-sqitch

Docker Image packaging for Sqitch
MIT License
35 stars 39 forks source link

Towards a generic sqitch snowflake image #34

Closed venkatra closed 3 years ago

venkatra commented 3 years ago

I was playing recently with Sqitch docker to connect to Snowflake. I followed all the exact steps as mentioned in snowflake/README.md.

The good news is that it worked, but I had also realized that we are not having a generic docker image, as you had required the snowflake to be defined in the '/etc/odbc.ini'

&& perl -i -pe "s/SF_ACCOUNT/$sf_account/g" odbc.ini \ && cat odbc.ini >> /etc/odbc.ini \ && cat odbcinst.ini >> /etc/odbcinst.ini \ I figured that you can overcome this issue by mounting a local copy of odbc.ini as part of the sqitch invocation in the docker-sqitch.sh.

First I ran the docker build like below: bash env DIR=snowflake ./build --build-arg sf_account=SFACCOUNT Then i edited the script docker-sqitch.sh like below : `bash

PATH TO ODBC

PATH_TO_ODBCINI=/Users/venkatra/Dev/learn/sqitcher/odbc.ini

 # Run the container with the current and home directories mounted.
docker run -it --rm --network host \
   --mount "type=bind,src=$(pwd),dst=/repo" \
   --mount "type=bind,src=$HOME,dst=$homedst" \
  --mount "type=bind,src=$PATH_TO_ODBCINI,dst=/etc/odbc.ini" \
  --mount "type=bind,src=$PATH_TO_SNOWSQL_CONFIG,dst=/var/.snowsql/config" \
  "${passopt[@]}" "$SQITCH_IMAGE" "$@"

` Notice :

By doing this, I believe you will be able to also incorporate Snowflake into the existing Sqitch docker image. I have attached a modified version of the "sqitch", "snowsql_config.txt" & "odbc.ini" file. (I had to add the 'txt' extension so I can have it attached).

odbc.ini.txt sqitch.txt snowsql_config.txt

If you approve to adopt this, the 'PATH_TO_ODBCINI' can be a command-line variable that gets passed to the 'sqitch' script along with the 'SQITCH_IMAGE' env variable.

theory commented 3 years ago

Hi, thanks for the comments, @venkatra. I don't see why any of this is necessary. All the connection info can be specified in the target URLs; the odbc.ini is there mostly to point to the Snowflake ODBC driver and to define a convenient SnowflakeDB configuration. OTOH, I know that many folks familiar with ODBC like to put all the connection info into the odbc.ini file, so your approach to mount a directory is a perfectly reasonable approach, though I don't see a need to add such variables to a script designed to be used with any supported database engine.