Skip to content

Refactor entrypoint to allow "sql.gz" files as well #131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 3, 2016

Conversation

tianon
Copy link
Member

@tianon tianon commented Mar 2, 2016

@yosifkit
Copy link
Member

yosifkit commented Mar 3, 2016

LGTM, though we should probably add this to our tests for postgres and myqsl. 😉

yosifkit added a commit that referenced this pull request Mar 3, 2016
Refactor entrypoint to allow "sql.gz" files as well
@yosifkit yosifkit merged commit 48d6cd0 into docker-library:master Mar 3, 2016
@yosifkit yosifkit deleted the sql-gz branch March 3, 2016 00:06
tianon added a commit to infosiftr/stackbrew that referenced this pull request Mar 8, 2016
- `cassandra`: 3.0.4
- `celery`: 3.1.22
- `django`: 1.9.4
- `drupal`: explicit `FROM php:7.0` instead of `php:7` (safer in the future event of PHP 7.1 incompat)
- `irssi`: fix GPG usage (docker-library/irssi#5)
- `mongo`: 3.2.4 and 3.0.10
- `owncloud`: 9.0 GA, 8.2.3, 8.1.6, 8.0.11, and 7.0.13
- `percona`: 5.6.29-76.2-1.jessie
- `php`: 7.0.4, 5.6.19, and 5.5.33 (docker-library/php#199)
- `postgres`: `sql.gz` enablement (docker-library/postgres#131)
- `pypy`: pip 8.1.0
- `python`: pip 8.1.0 (docker-library/python#94)
- `rails`: 4.2.6
- `rocket.chat`: 0.21.0
RichardScothern pushed a commit to RichardScothern/official-images that referenced this pull request Jun 14, 2016
- `cassandra`: 3.0.4
- `celery`: 3.1.22
- `django`: 1.9.4
- `drupal`: explicit `FROM php:7.0` instead of `php:7` (safer in the future event of PHP 7.1 incompat)
- `irssi`: fix GPG usage (docker-library/irssi#5)
- `mongo`: 3.2.4 and 3.0.10
- `owncloud`: 9.0 GA, 8.2.3, 8.1.6, 8.0.11, and 7.0.13
- `percona`: 5.6.29-76.2-1.jessie
- `php`: 7.0.4, 5.6.19, and 5.5.33 (docker-library/php#199)
- `postgres`: `sql.gz` enablement (docker-library/postgres#131)
- `pypy`: pip 8.1.0
- `python`: pip 8.1.0 (docker-library/python#94)
- `rails`: 4.2.6
- `rocket.chat`: 0.21.0
@sgala
Copy link

sgala commented Sep 13, 2016

Hi, this commit introduced a behaviour change that is biting me.

I used .sh files to change the database and thus create several ones with files like 001prod1.sh 001.prod1.sql 002.prod2.sh 002.prod2.sql, where 000.sh would set a MAIN_POSTGRES_USER=${POSTGRES_USER} etc, and 001.prod1.sh would be something like:

psql -v ON_ERROR_STOP=1 --username "$MAIN_POSTGRES_USER" <<-EOSQL
    CREATE USER ${PROD1_DB_USER} WITH PASSWORD '${PROD1_DB_PASSWORD}';
    CREATE DATABASE ${PROD1_DB};
    GRANT ALL PRIVILEGES ON DATABASE ${PROD1_DB} TO ${PROD1_DB_USER};
export POSTGRES_USER=${PROD1_DB_USER}
export POSTGRES_PASSWORD=${PROD1_DB_PASSWORD}
export POSTGRES_DB=${PROD1_DB}

Now you are evaluating the line

psql+=( --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" )

out of the loop, and thus all DBs use the original user. I found the former behaviour more flexible and helped me to minimise containers while having separate DBs. Do you think it would make sense a patch putting this line back inside the loop, where it would restore the previous behaviour?

@yosifkit
Copy link
Member

If you are already running psql commands in your shell scripts, why not rename your sql files (so that the entrypoint does not run them) and just import them yourself? psql --username ${PROD1_DB_USER} ... < 001-prod1-sql

That or just export on top of the psql variable that we use; though I am not sure if that may change like this has.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants