From 521e111b3d24588231c942030f78b0c155ab7afd Mon Sep 17 00:00:00 2001 From: Stephen Ficklin Date: Mon, 7 Mar 2022 10:43:26 -0800 Subject: [PATCH 1/7] updating docker with flyway --- Dockerfile | 33 --------------------------------- docker/Dockerfile | 44 ++++++++++++++++++++++++++++++++++++++++++++ docker/flyway.conf | 6 ++++++ docker/makefile | 8 ++++++++ 4 files changed, 58 insertions(+), 33 deletions(-) delete mode 100644 Dockerfile create mode 100644 docker/Dockerfile create mode 100644 docker/flyway.conf create mode 100644 docker/makefile diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index d1d158893..000000000 --- a/Dockerfile +++ /dev/null @@ -1,33 +0,0 @@ -FROM ubuntu:18.10 -MAINTAINER Scott Cain - -RUN apt-get update - -#for some reason, this has to be installed by itself -RUN apt-get install -y tzdata - -RUN apt-get install -y apt-utils - -RUN apt-get install -y wget \ - unzip \ - git \ - make \ - gcc \ - vim \ - uuid-dev - -RUN apt-get install -y postgresql-all - - - -RUN cd / ; \ - git clone https://github.com/GMOD/Chado.git ; \ - cd Chado; \ - git checkout 1.4; \ - /etc/init.d/postgresql start; \ - su -c "createdb chado" - postgres; \ - su -c "psql chado < /Chado/chado/schemas/1.4/default_schema.sql" - postgres; \ - /etc/init.d/postgresql stop; - -#ENTRYPOINT["sh","/entrypoint.sh"] -CMD ["/etc/init.d/postgresql", "start"] diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 000000000..f5f7b8de4 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,44 @@ +FROM ubuntu:20.04 +MAINTAINER Scott Cain + +RUN apt-get update + +#for some reason, this has to be installed by itself +RUN apt-get install -y tzdata + +RUN apt-get install -y apt-utils + +RUN apt-get install -y wget \ + unzip \ + git \ + make \ + gcc \ + vim \ + uuid-dev + +RUN apt-get install -y postgresql-all + +RUN cd /usr/local \ + && wget -qO- https://repo1.maven.org/maven2/org/flywaydb/flyway-commandline/8.5.2/flyway-commandline-8.5.2-linux-x64.tar.gz | tar xvz \ + && ln -s `pwd`/flyway-8.5.2/flyway /usr/local/bin + +ARG CHADO_BRANCH=${CHADO_BRANCH} +ARG CHADO_VERSION=${CHADO_VERSION} + +RUN cd / \ + && git clone https://github.com/GMOD/Chado.git \ + && cd Chado \ + && git checkout ${CHADO_BRANCH} + +RUN /etc/init.d/postgresql start \ + && su -c "createdb chado" - postgres \ + && su -c "psql chado < /Chado/chado/schemas/${CHADO_VERSION}/default_schema.sql" - postgres \ + && su - postgres \ + && psql -c "ALTER USER postgres PASSWORD 'chad0$test';" \ + && exit \ + && /etc/init.d/postgresql stop; + +ADD flyway.conf flyway.conf + +#ENTRYPOINT["sh","/entrypoint.sh"] +CMD ["/etc/init.d/postgresql", "start"] diff --git a/docker/flyway.conf b/docker/flyway.conf new file mode 100644 index 000000000..d8bd37c4c --- /dev/null +++ b/docker/flyway.conf @@ -0,0 +1,6 @@ +flyway.url=jdbc:postgresql://localhost:5432/chado +flyway.user=postgres +flyway.password=chad0$test +flyway.schemas=public +flyway.locations=filesystem:/Chado +flyway.validateOnMigrate=false diff --git a/docker/makefile b/docker/makefile new file mode 100644 index 000000000..9231f3e26 --- /dev/null +++ b/docker/makefile @@ -0,0 +1,8 @@ +all: v1.4 + +v1.4: + docker build \ + -t gmod/chado:1.4 \ + --build-arg CHADO_BRANCH=1.4 \ + --build-arg CHADO_VERSION=1.4 \ + . From c5ceed23a837e4d3b9f48adeca08ceaeedfdd344 Mon Sep 17 00:00:00 2001 From: Stephen Ficklin Date: Mon, 7 Mar 2022 11:38:44 -0800 Subject: [PATCH 2/7] Working docker image with flyway and motd --- README.md | 22 ++++++++++++++++++---- docker/Dockerfile | 15 ++++++++------- docker/entrypoint.sh | 2 ++ docker/flyway.conf | 2 +- docker/motd | 10 ++++++++++ 5 files changed, 39 insertions(+), 12 deletions(-) create mode 100644 docker/entrypoint.sh create mode 100644 docker/motd diff --git a/README.md b/README.md index 07949933e..df834edb8 100644 --- a/README.md +++ b/README.md @@ -83,14 +83,28 @@ are currently using PostgreSQL. Please read the included [chado/INSTALL.Chado.md](./chado/INSTALL.Chado.md) document for instructions on how to install the Chado schema. -### Running the Docker Image - +### Using the Chado Docker Image +#### Locally building the Docker Image +To build the docker image run the following: ```bash -docker build -t chado . -docker run -it -d chado +cd docker +make v +``` +Replace `` with a specific version of Chado that you want to use (e.g. `1.4`). This will create a Docker image with the tag: `gmod/chado:` where is the same version used above (e.g. `gmod/chado:1.4`). + +#### Using the Chado Docker +You can start and work within the Chado container by using the following command. +```bash +docker run -it gmod/chado: ``` +Replace `` with the specific version of Chado that you want to use (e.g. `1.4`). This will start the PostgreSQL server and give you access to a bash terminal. +As a test, you can run the `flyway info` command after starting the container: + +```bash +flyway info +``` ## Chado Support diff --git a/docker/Dockerfile b/docker/Dockerfile index f5f7b8de4..1760f2921 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -29,16 +29,17 @@ RUN cd / \ && git clone https://github.com/GMOD/Chado.git \ && cd Chado \ && git checkout ${CHADO_BRANCH} - + RUN /etc/init.d/postgresql start \ && su -c "createdb chado" - postgres \ - && su -c "psql chado < /Chado/chado/schemas/${CHADO_VERSION}/default_schema.sql" - postgres \ - && su - postgres \ - && psql -c "ALTER USER postgres PASSWORD 'chad0$test';" \ - && exit \ + && su -c "psql chado < /Chado/schemas/${CHADO_VERSION}/default_schema.sql" - postgres \ + && su -c "psql -c \"ALTER USER postgres PASSWORD 'chadotest';\"" - postgres \ && /etc/init.d/postgresql stop; ADD flyway.conf flyway.conf +ADD entrypoint.sh entrypoint.sh +ADD motd /etc/motd + +RUN echo '[ ! -z "$TERM" -a -r /etc/motd ] && cat /etc/issue && cat /etc/motd' >> /etc/bash.bashrc -#ENTRYPOINT["sh","/entrypoint.sh"] -CMD ["/etc/init.d/postgresql", "start"] +ENTRYPOINT ["sh", "entrypoint.sh"] diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh new file mode 100644 index 000000000..f97dd5454 --- /dev/null +++ b/docker/entrypoint.sh @@ -0,0 +1,2 @@ +/etc/init.d/postgresql start +/bin/bash diff --git a/docker/flyway.conf b/docker/flyway.conf index d8bd37c4c..47496f0fe 100644 --- a/docker/flyway.conf +++ b/docker/flyway.conf @@ -1,6 +1,6 @@ flyway.url=jdbc:postgresql://localhost:5432/chado flyway.user=postgres -flyway.password=chad0$test +flyway.password=chadotest flyway.schemas=public flyway.locations=filesystem:/Chado flyway.validateOnMigrate=false diff --git a/docker/motd b/docker/motd new file mode 100644 index 000000000..daa1b12a4 --- /dev/null +++ b/docker/motd @@ -0,0 +1,10 @@ + ________ _____ ____ ____ + / ____/ / / / | / __ \/ __ \ + / / / /_/ / /| | / / / / / / / +/ /___/ __ / ___ |/ /_/ / /_/ / +\____/_/ /_/_/ |_/_____/\____/ + +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 From 94b71cbe2b3853dc69340a7661aa9a134f721203 Mon Sep 17 00:00:00 2001 From: Stephen Ficklin Date: Mon, 7 Mar 2022 13:23:19 -0800 Subject: [PATCH 3/7] Fix for dockerfile so flyway is executable anywhere --- docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 1760f2921..ebce907ae 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -36,7 +36,7 @@ RUN /etc/init.d/postgresql start \ && su -c "psql -c \"ALTER USER postgres PASSWORD 'chadotest';\"" - postgres \ && /etc/init.d/postgresql stop; -ADD flyway.conf flyway.conf +ADD flyway.conf /root/flyway.conf ADD entrypoint.sh entrypoint.sh ADD motd /etc/motd From e3ba97ee16a662c5fa643b8ab2a63cd0bf47958a Mon Sep 17 00:00:00 2001 From: Stephen Ficklin Date: Mon, 7 Mar 2022 14:12:58 -0800 Subject: [PATCH 4/7] updates to the readme --- README.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index df834edb8..a9b12c9a0 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ Please read the included [chado/INSTALL.Chado.md](./chado/INSTALL.Chado.md) docu install the Chado schema. ### Using the Chado Docker Image -#### Locally building the Docker Image +#### Locally Build the Docker Image To build the docker image run the following: ```bash @@ -106,6 +106,23 @@ As a test, you can run the `flyway info` command after starting the container: flyway info ``` +You can explore the Chado tables using the `psql` command in the following way: + +```bash +psql -U postgres -h localhost -d chado +``` +You will be prompted for a password. The default password is `chadotest` + +##### Testing Chado +You can test any Git branch of Chado by navigating to the Chado directory in the image and changing the branch: +```bash +cd Chado/chado +git checkout +``` +If the branch has any FlyWay migrations you can test those by running the apporopriate flyway commands. + + + ## Chado Support Please see our website for more information on Chado and the GMOD project: From ec827336eaf1454c8bc9e4263b370164f4b696dd Mon Sep 17 00:00:00 2001 From: Stephen Ficklin Date: Mon, 7 Mar 2022 14:26:58 -0800 Subject: [PATCH 5/7] Changed version number in makefile --- docker/Dockerfile | 2 +- docker/makefile | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index ebce907ae..6a0c9780c 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -32,7 +32,7 @@ RUN cd / \ RUN /etc/init.d/postgresql start \ && su -c "createdb chado" - postgres \ - && su -c "psql chado < /Chado/schemas/${CHADO_VERSION}/default_schema.sql" - postgres \ + && su -c "psql chado < /Chado/chado/schemas/${CHADO_VERSION}/default_schema.sql" - postgres \ && su -c "psql -c \"ALTER USER postgres PASSWORD 'chadotest';\"" - postgres \ && /etc/init.d/postgresql stop; diff --git a/docker/makefile b/docker/makefile index 9231f3e26..dd819e3c8 100644 --- a/docker/makefile +++ b/docker/makefile @@ -1,8 +1,8 @@ -all: v1.4 +all: v1.31 -v1.4: +v1.31: docker build \ - -t gmod/chado:1.4 \ - --build-arg CHADO_BRANCH=1.4 \ - --build-arg CHADO_VERSION=1.4 \ + -t gmod/chado:1.31 \ + --build-arg CHADO_BRANCH=1.31-release \ + --build-arg CHADO_VERSION=1.31 \ . From 4842863fc8e22a3aa6ccdac3842db77ef192048f Mon Sep 17 00:00:00 2001 From: Stephen Ficklin Date: Mon, 7 Mar 2022 14:40:34 -0800 Subject: [PATCH 6/7] More updates to the readme --- README.md | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a9b12c9a0..fb03d326e 100644 --- a/README.md +++ b/README.md @@ -113,13 +113,34 @@ psql -U postgres -h localhost -d chado ``` You will be prompted for a password. The default password is `chadotest` -##### Testing Chado -You can test any Git branch of Chado by navigating to the Chado directory in the image and changing the branch: +##### Testing a Pull Request +You can test any pull request or other Git branch of Chado by navigating to the Chado directory in the image and changing the branch: ```bash cd Chado/chado git checkout ``` -If the branch has any FlyWay migrations you can test those by running the apporopriate flyway commands. +If the branch has any FlyWay migrations you can test those by running these flyway commans: + +Use this command to see what needs to be applied +```bash +flyway info +``` + +For testing of a PR you can set the baseline to the current installation of Chado provided by the image: +```bash +flyway baseline +``` + +To update Chado you can apply the Flyway migrations: +```bash +flyway migrate +``` + +As long as no errors occured you will see success for all updates: + +```bash +flyway info +``` From c13927a3b2e628bd0d0ee537ba727e6bc939771e Mon Sep 17 00:00:00 2001 From: Stephen Ficklin Date: Mon, 14 Mar 2022 10:04:54 -0700 Subject: [PATCH 7/7] fix to readme docker versions --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fb03d326e..540337f2f 100644 --- a/README.md +++ b/README.md @@ -91,14 +91,14 @@ To build the docker image run the following: cd docker make v ``` -Replace `` with a specific version of Chado that you want to use (e.g. `1.4`). This will create a Docker image with the tag: `gmod/chado:` where is the same version used above (e.g. `gmod/chado:1.4`). +Replace `` with a specific version of Chado that you want to use (e.g. `1.31`). This will create a Docker image with the tag: `gmod/chado:` where is the same version used above (e.g. `gmod/chado:1.31`). #### Using the Chado Docker You can start and work within the Chado container by using the following command. ```bash docker run -it gmod/chado: ``` -Replace `` with the specific version of Chado that you want to use (e.g. `1.4`). This will start the PostgreSQL server and give you access to a bash terminal. +Replace `` with the specific version of Chado that you want to use (e.g. `1.31`). This will start the PostgreSQL server and give you access to a bash terminal. As a test, you can run the `flyway info` command after starting the container: