Skip to content
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

Docker updates #129

Merged
merged 7 commits into from
Dec 5, 2022
Merged

Docker updates #129

merged 7 commits into from
Dec 5, 2022

Conversation

spficklin
Copy link
Contributor

@spficklin spficklin commented Mar 7, 2022

Issue: #128

This PR updates the docker image provided by this repository to:

  • Include Flyway.
  • Adds a default password be set for the postgres user, which is hardcoded in the Dockerfile and flyway.conf files. This is necessary because flyway cannot connect via the UNIX socket.
  • I added a message of the day motd that warns the user not to use this for production (See below)
  • I added an entryfile script that runs the postgresql server and drops the user to a bash shell.
  • Updates to the README
  • A makefile to automatically build the images

To Test

Build the docker image using the new makefile

cd docker
make v1.31

Startup the image:

docker run -it gmod/chado:1.31

To test Flyway changes, change Chado to use the 1.4 branch

cd /Chado/
git checkout 1.4

Run Flyway from the root directory:

flyway info
flyway baseline
flyway migrate

Examples

The warning message when the image first starts:

* Starting PostgreSQL 12 database server                                                                                                                                                                            [ OK ] 
Ubuntu 20.04.4 LTS \n \l

   ________  _____    ____  ____
  / ____/ / / /   |  / __ \/ __ \
 / /   / /_/ / /| | / / / / / / /
/ /___/ __  / ___ |/ /_/ / /_/ /
\____/_/ /_/_/  |_/_____/\____/

This Chado docker image uses default security settings for
PostgreSQL and has a hard-coded password for the postgres
user.  Do not use this image for a production service without
first correcting

Example usage of the flyway info command:

root@da57899c2665:/# flyway info
Flyway is up to date
38 SQL migrations were detected but not run because they did not follow the filename convention.
If this is in error, enable debug logging or 'validateMigrationNaming' to fail fast and see a list of the invalid file names.
Flyway Community Edition 8.5.2 by Redgate
See what's new here: https://flywaydb.org/documentation/learnmore/releaseNotes#8.5.2

Database: jdbc:postgresql://localhost:5432/chado (PostgreSQL 12.9)
Schema version: << Empty Schema >>

+-----------+-----------+-----------------------------------+------+--------------+---------+
| Category  | Version   | Description                       | Type | Installed On | State   |
+-----------+-----------+-----------------------------------+------+--------------+---------+
| Versioned | 1.3.3.001 | add stock biomat table            | SQL  |              | Pending |
| Versioned | 1.3.3.002 | add db relationship table         | SQL  |              | Pending |
| Versioned | 1.3.3.003 | alter analysis unique constraint  | SQL  |              | Pending |
| Versioned | 1.3.3.004 | add synoynm indices cvtermsynonym | SQL  |              | Pending |
| Versioned | 1.3.3.005 | add type id 2 project table       | SQL  |              | Pending |
| Versioned | 1.3.3.006 | modify mage                       | SQL  |              | Pending |
| Versioned | 1.3.3.007 | fix search path                   | SQL  |              | Pending |
| Versioned | 1.3.3.008 | add is obsolete cell line table   | SQL  |              | Pending |
| Versioned | 1.3.3.009 | update analysis desc              | SQL  |              | Pending |
+-----------+-----------+-----------------------------------+------+--------------+---------+

@laceysanderson laceysanderson linked an issue Mar 7, 2022 that may be closed by this pull request
Copy link
Contributor

@laceysanderson laceysanderson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Using the makefile to build the image
✅ Running the image
✅ Using flyway inside the container on start

So next I tried to use the image to test a PR :-)
Based on the dockerfile I saw Chado was cloned at the root so I cd'd in and switched the branch to an existing PR. Then I tried using flyway info and ran found out it couldn't be used anywhere but the root directory.

Notes:

  • We could use some docs related to how to use the docker to test a PR and inspect the schema.
  • flyway only works if you're in the root directory. This is a pain if you need to change branches first.
  • docs on using psql to actually check the schema would also be nice :-D especially if there were an alias so you can just use psql without args for those who don't read the docs ;-)

@spficklin
Copy link
Contributor Author

Okay, I've made the changes you requested @laceysanderson . You can now run Flyway from anywhere in the image (no need to be in the root folder) and the README has been updated to tell you how to find where the Chado repository is installed and how to run psql

I also make one additional change. I changed the version of this Docker image to 1.31 instead of 1.4 because I'm really confused about the versioning (see issue #130) and it doesn't make sense to have a 1.4 docker image of Chado if you then have to apply the 1.3.3_XXX Flyway fixes to it.....

Copy link
Member

@scottcain scottcain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very useful--thanks @spficklin !

Copy link
Contributor

@laceysanderson laceysanderson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks! This looks good to me and works as expected now :-) 👍

@laceysanderson
Copy link
Contributor

Two reviews approving this change so this is ready to merge @scottcain 🎉 Thanks @spficklin this is going to make reviewing migration PRS so much easier!

@scottcain scottcain merged commit 9ae6f92 into 1.4 Dec 5, 2022
@laceysanderson laceysanderson deleted the docker-updates branch December 5, 2022 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update Docker Image for Flyway
3 participants