From b3e3e011439648ca5a8c3be9e8251743466aefb6 Mon Sep 17 00:00:00 2001 From: Zach Hoffman Date: Fri, 27 Sep 2024 01:11:06 -0600 Subject: [PATCH] Get POSTGRES_VERSION from .env in Dockerfiles and docker-compose files --- cache-config/testing/docker/.env | 1 + cache-config/testing/docker/docker-compose.yml | 3 ++- cache-config/testing/docker/traffic_ops/Dockerfile | 2 +- docker-compose.yml | 2 +- infrastructure/cdn-in-a-box/docker-compose.yml | 2 ++ infrastructure/cdn-in-a-box/traffic_ops/Dockerfile-db | 3 ++- tc-health-client/testing/docker/.env | 1 + tc-health-client/testing/docker/docker-compose.yml | 2 +- tc-health-client/testing/docker/traffic_ops/Dockerfile | 2 +- traffic_ops/INSTALL.md | 2 +- traffic_ops/app/db/trafficvault/test/.env | 1 + traffic_ops/app/db/trafficvault/test/Dockerfile-db-admin | 2 +- traffic_ops/app/db/trafficvault/test/Dockerfile-tvdb | 4 ++-- traffic_ops/app/db/trafficvault/test/docker-compose.yml | 4 ++-- traffic_ops/traffic_ops_golang/README.md | 2 +- traffic_ops_db/docker/.env | 1 + traffic_ops_db/docker/Dockerfile | 3 ++- traffic_ops_db/docker/docker-compose.yml | 2 ++ traffic_ops_db/test/docker/.env | 1 + traffic_ops_db/test/docker/Dockerfile-db | 4 ++-- traffic_ops_db/test/docker/Dockerfile-db-admin | 2 +- traffic_ops_db/test/docker/docker-compose.yml | 4 ++-- 22 files changed, 31 insertions(+), 19 deletions(-) create mode 120000 cache-config/testing/docker/.env create mode 120000 tc-health-client/testing/docker/.env create mode 120000 traffic_ops/app/db/trafficvault/test/.env create mode 120000 traffic_ops_db/docker/.env create mode 120000 traffic_ops_db/test/docker/.env diff --git a/cache-config/testing/docker/.env b/cache-config/testing/docker/.env new file mode 120000 index 0000000000..e72b3932f4 --- /dev/null +++ b/cache-config/testing/docker/.env @@ -0,0 +1 @@ +../../../.env \ No newline at end of file diff --git a/cache-config/testing/docker/docker-compose.yml b/cache-config/testing/docker/docker-compose.yml index f5e9156567..08712fb8a0 100644 --- a/cache-config/testing/docker/docker-compose.yml +++ b/cache-config/testing/docker/docker-compose.yml @@ -35,7 +35,7 @@ volumes: services: db: - image: postgres:13.2 + image: postgres:${POSTGRES_VERSION} env_file: - variables.env ports: @@ -50,6 +50,7 @@ services: args: - OS_DISTRO=${OS_DISTRO:-rockylinux} - OS_VERSION=${OS_VERSION:-8} + - POSTGRES_VERSION=${POSTGRES_VERSION} context: ../../.. dockerfile: cache-config/testing/docker/traffic_ops/Dockerfile volumes: diff --git a/cache-config/testing/docker/traffic_ops/Dockerfile b/cache-config/testing/docker/traffic_ops/Dockerfile index c5f9d8c89c..83d1c38b22 100644 --- a/cache-config/testing/docker/traffic_ops/Dockerfile +++ b/cache-config/testing/docker/traffic_ops/Dockerfile @@ -39,7 +39,7 @@ RUN set -o nounset -o errexit && \ if [[ "${OS_VERSION%%.*}" -eq 7 ]]; then \ use_repo=''; \ enable_repo=''; \ - # needed for llvm-toolset-7-clang, which is needed for postgresql13-devel-13.2-1PGDG, required by TO rpm + # needed for llvm-toolset-7-clang, which is needed for postgresql13-devel-13.X-1PGDG, required by TO rpm dnf -y install gcc centos-release-scl-rh; \ else \ use_repo='--repo=pgdg13'; \ diff --git a/docker-compose.yml b/docker-compose.yml index ca8cc4f24b..87a1a6e017 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -38,7 +38,7 @@ services: - .:/go/src/github.com/apache/trafficcontrol db: - image: postgres:13.2-alpine + image: postgres:${POSTGRES_VERSION}-alpine ports: - 5432:5432 environment: diff --git a/infrastructure/cdn-in-a-box/docker-compose.yml b/infrastructure/cdn-in-a-box/docker-compose.yml index 22872ad847..60894e3f0f 100644 --- a/infrastructure/cdn-in-a-box/docker-compose.yml +++ b/infrastructure/cdn-in-a-box/docker-compose.yml @@ -37,6 +37,8 @@ services: # All other components access the database thru the Traffic Ops API db: build: + args: + POSTGRES_VERSION: ${POSTGRES_VERSION} context: . dockerfile: traffic_ops/Dockerfile-db hostname: db diff --git a/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile-db b/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile-db index 593db61c2c..f824a0b86f 100644 --- a/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile-db +++ b/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile-db @@ -19,7 +19,8 @@ # Dockerfile for trafficops db ############################################################ -FROM postgres:13.2-alpine +ARG POSTGRES_VERSION +FROM postgres:${POSTGRES_VERSION}-alpine ENV POSTGRES_PASSWORD=$POSTGRES_PASSWORD RUN apk add bind-tools \ diff --git a/tc-health-client/testing/docker/.env b/tc-health-client/testing/docker/.env new file mode 120000 index 0000000000..e72b3932f4 --- /dev/null +++ b/tc-health-client/testing/docker/.env @@ -0,0 +1 @@ +../../../.env \ No newline at end of file diff --git a/tc-health-client/testing/docker/docker-compose.yml b/tc-health-client/testing/docker/docker-compose.yml index 8d142aab4e..c01d759012 100644 --- a/tc-health-client/testing/docker/docker-compose.yml +++ b/tc-health-client/testing/docker/docker-compose.yml @@ -35,7 +35,7 @@ volumes: services: db: - image: postgres:13.2 + image: postgres:${POSTGRES_VERSION} env_file: - variables.env ports: diff --git a/tc-health-client/testing/docker/traffic_ops/Dockerfile b/tc-health-client/testing/docker/traffic_ops/Dockerfile index 1e999e80f7..f4a33f97c5 100644 --- a/tc-health-client/testing/docker/traffic_ops/Dockerfile +++ b/tc-health-client/testing/docker/traffic_ops/Dockerfile @@ -37,7 +37,7 @@ RUN set -o nounset -o errexit && \ if [[ "${OS_VERSION%%.*}" -eq 7 ]]; then \ use_repo=''; \ enable_repo=''; \ - # needed for llvm-toolset-7-clang, which is needed for postgresql13-devel-13.2-1PGDG, required by TO rpm + # needed for llvm-toolset-7-clang, which is needed for postgresql13-devel-13.x-1PGDG, required by TO rpm dnf -y install gcc centos-release-scl-rh; \ else \ use_repo='--repo=pgdg13'; \ diff --git a/traffic_ops/INSTALL.md b/traffic_ops/INSTALL.md index 7a3fbcc76b..5edd18575c 100644 --- a/traffic_ops/INSTALL.md +++ b/traffic_ops/INSTALL.md @@ -30,7 +30,7 @@ Instructions are here: https://yum.postgresql.org/ `$ sudo yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm` -## Install Postgres 13.2 server (in a container or on the host) +## Install Postgres 13.16 server (in a container or on the host) ### on the host: diff --git a/traffic_ops/app/db/trafficvault/test/.env b/traffic_ops/app/db/trafficvault/test/.env new file mode 120000 index 0000000000..7e66cb76ec --- /dev/null +++ b/traffic_ops/app/db/trafficvault/test/.env @@ -0,0 +1 @@ +../../../../../.env \ No newline at end of file diff --git a/traffic_ops/app/db/trafficvault/test/Dockerfile-db-admin b/traffic_ops/app/db/trafficvault/test/Dockerfile-db-admin index e039037cf0..680a4a8a32 100644 --- a/traffic_ops/app/db/trafficvault/test/Dockerfile-db-admin +++ b/traffic_ops/app/db/trafficvault/test/Dockerfile-db-admin @@ -20,7 +20,7 @@ ############################################################ FROM rockylinux:8 -ARG POSTGRES_VERSION=13.2 +ARG POSTGRES_VERSION ENV POSTGRES_VERSION=$POSTGRES_VERSION # NOTE: temporary workaround for removal of golang packages from CentOS 7 base repo diff --git a/traffic_ops/app/db/trafficvault/test/Dockerfile-tvdb b/traffic_ops/app/db/trafficvault/test/Dockerfile-tvdb index 5fdeeb5a08..9c054d1bfe 100644 --- a/traffic_ops/app/db/trafficvault/test/Dockerfile-tvdb +++ b/traffic_ops/app/db/trafficvault/test/Dockerfile-tvdb @@ -19,9 +19,9 @@ # Dockerfile for traffic vault db ############################################################ -ARG POSTGRES_VERSION=13.2 +ARG POSTGRES_VERSION FROM postgres:${POSTGRES_VERSION} -ARG POSTGRES_VERSION=13.2 +ARG POSTGRES_VERSION ENV POSTGRES_VERSION=$POSTGRES_VERSION ENV POSTGRES_PASSWORD=twelve diff --git a/traffic_ops/app/db/trafficvault/test/docker-compose.yml b/traffic_ops/app/db/trafficvault/test/docker-compose.yml index a833db84cf..b0a4b66d44 100644 --- a/traffic_ops/app/db/trafficvault/test/docker-compose.yml +++ b/traffic_ops/app/db/trafficvault/test/docker-compose.yml @@ -32,7 +32,7 @@ services: context: . dockerfile: Dockerfile-tvdb args: - POSTGRES_VERSION: ${POSTGRES_VERSION:-13.2} + POSTGRES_VERSION: ${POSTGRES_VERSION} ports: - 5432 @@ -41,7 +41,7 @@ services: context: . dockerfile: Dockerfile-db-admin args: - POSTGRES_VERSION: ${POSTGRES_VERSION:-13.2} + POSTGRES_VERSION: ${POSTGRES_VERSION} TRAFFIC_OPS_RPM: traffic_ops.rpm depends_on: - tvdb diff --git a/traffic_ops/traffic_ops_golang/README.md b/traffic_ops/traffic_ops_golang/README.md index a28db5e81a..a80c05e29a 100644 --- a/traffic_ops/traffic_ops_golang/README.md +++ b/traffic_ops/traffic_ops_golang/README.md @@ -24,7 +24,7 @@ To run `traffic_ops_golang` proxy locally the following prerequisites are needed: * Golang version greater or equal to the Go version found in the `GO_VERSION` file at the base of this repository. See: [https://golang.org/doc/install](https://golang.org/doc/install) -* Postgres 13.2 or greater +* Postgres 13 or greater ## Vendoring and Building diff --git a/traffic_ops_db/docker/.env b/traffic_ops_db/docker/.env new file mode 120000 index 0000000000..c7360fb82d --- /dev/null +++ b/traffic_ops_db/docker/.env @@ -0,0 +1 @@ +../../.env \ No newline at end of file diff --git a/traffic_ops_db/docker/Dockerfile b/traffic_ops_db/docker/Dockerfile index ce3f53ab2a..fbb343a397 100644 --- a/traffic_ops_db/docker/Dockerfile +++ b/traffic_ops_db/docker/Dockerfile @@ -11,7 +11,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # -FROM postgres:13.2 +ARG POSTGRES_VERSION +FROM postgres:${POSTGRES_VERSION} MAINTAINER dev@trafficcontrol.apache.org diff --git a/traffic_ops_db/docker/docker-compose.yml b/traffic_ops_db/docker/docker-compose.yml index 4d88ac10ea..68729f927d 100644 --- a/traffic_ops_db/docker/docker-compose.yml +++ b/traffic_ops_db/docker/docker-compose.yml @@ -17,6 +17,8 @@ services: build: context: .. dockerfile: /opt/traffic_ops_db/docker/Dockerfile + args: + POSTGRES_VERSION: ${POSTGRES_VERSION} env_file: - /opt/traffic_ops_db/docker/docker-compose.env ports: diff --git a/traffic_ops_db/test/docker/.env b/traffic_ops_db/test/docker/.env new file mode 120000 index 0000000000..e72b3932f4 --- /dev/null +++ b/traffic_ops_db/test/docker/.env @@ -0,0 +1 @@ +../../../.env \ No newline at end of file diff --git a/traffic_ops_db/test/docker/Dockerfile-db b/traffic_ops_db/test/docker/Dockerfile-db index e2dc6c32b3..aaccabb4ef 100644 --- a/traffic_ops_db/test/docker/Dockerfile-db +++ b/traffic_ops_db/test/docker/Dockerfile-db @@ -19,9 +19,9 @@ # Dockerfile for trafficops db ############################################################ -ARG POSTGRES_VERSION=13.2 +ARG POSTGRES_VERSION FROM postgres:${POSTGRES_VERSION} -ARG POSTGRES_VERSION=13.2 +ARG POSTGRES_VERSION ENV POSTGRES_VERSION=$POSTGRES_VERSION ENV POSTGRES_PASSWORD=twelve diff --git a/traffic_ops_db/test/docker/Dockerfile-db-admin b/traffic_ops_db/test/docker/Dockerfile-db-admin index b2add5929a..fa24860d67 100644 --- a/traffic_ops_db/test/docker/Dockerfile-db-admin +++ b/traffic_ops_db/test/docker/Dockerfile-db-admin @@ -20,7 +20,7 @@ ############################################################ FROM rockylinux:8 -ARG POSTGRES_VERSION=13.2 +ARG POSTGRES_VERSION ENV POSTGRES_VERSION=$POSTGRES_VERSION RUN dnf install -y \ diff --git a/traffic_ops_db/test/docker/docker-compose.yml b/traffic_ops_db/test/docker/docker-compose.yml index 8764e775d1..2bb2e65e33 100644 --- a/traffic_ops_db/test/docker/docker-compose.yml +++ b/traffic_ops_db/test/docker/docker-compose.yml @@ -32,7 +32,7 @@ services: context: . dockerfile: Dockerfile-db args: - POSTGRES_VERSION: ${POSTGRES_VERSION:-13.2} + POSTGRES_VERSION: ${POSTGRES_VERSION} ports: - 5432 @@ -41,7 +41,7 @@ services: context: . dockerfile: Dockerfile-db-admin args: - POSTGRES_VERSION: ${POSTGRES_VERSION:-13.2} + POSTGRES_VERSION: ${POSTGRES_VERSION} TRAFFIC_OPS_RPM: traffic_ops.rpm depends_on: - db