Skip to content

Commit

Permalink
Make db port configurable via POSTGRES_PORT (#2751)
Browse files Browse the repository at this point in the history
* Make db port configurable via new env var.

Signed-off-by: merobi-hub <merobi@gmail.com>

* Add DB_PORT env var to .env.example.

Signed-off-by: merobi-hub <merobi@gmail.com>

* Fix entrypoint.

Signed-off-by: merobi-hub <merobi@gmail.com>

* Add db port to ci env.

Signed-off-by: merobi-hub <merobi@gmail.com>

* Add pg port param to up script.

Signed-off-by: merobi-hub <merobi@gmail.com>

---------

Signed-off-by: merobi-hub <merobi@gmail.com>
Co-authored-by: Willy Lulciuc <willy@datakin.com>
  • Loading branch information
merobi-hub and wslulciuc authored May 22, 2024
1 parent 2c50ca0 commit 465ecaa
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .circleci/api-load-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ readonly MARQUEZ_HOST="localhost"
readonly MARQUEZ_ADMIN_PORT=8081
readonly MARQUEZ_URL="http://${MARQUEZ_HOST}:${MARQUEZ_ADMIN_PORT}"
readonly MARQUEZ_DB="marquez-db"
readonly POSTGRES_PORT=5432
readonly API_PORT=5000
readonly API_ADMIN_PORT=5001

readonly METADATA_FILE="api/load-testing/metadata.json"
readonly METADATA_STATS_QUERY=$(cat <<-END
Expand Down
6 changes: 6 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ jobs:
path: marquez
- store_artifacts:
path: k6
environment:
- POSTGRES_PORT=5432

migrate-db:
working_directory: ~/marquez
Expand All @@ -171,6 +173,10 @@ jobs:
- checkout
- run: ./.circleci/get-docker-compose.sh
- run: ./.circleci/db-migration.sh
environment:
- POSTGRES_PORT=5432
- API_PORT=5000
- API_ADMIN_PORT=5001

publish-snapshot:
working_directory: ~/marquez
Expand Down
1 change: 1 addition & 0 deletions .circleci/db-migration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ readonly POSTGRES_VERSION="14"
readonly MARQUEZ_VERSION=0.47.0
# Build version of Marquez
readonly MARQUEZ_BUILD_VERSION="$(git log --pretty=format:'%h' -n 1)" # SHA1
readonly POSTGRES_PORT=5432

readonly DB_MIGRATION_VOLUME="marquez_db-backup"
readonly DB_MIGRATION_BACKUP="db-migration-backup"
Expand Down
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
API_PORT=5000
API_ADMIN_PORT=5001
WEB_PORT=3000
POSTGRES_PORT=5432
TAG=0.47.0
2 changes: 1 addition & 1 deletion docker-compose.db.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ services:
image: postgres:14
container_name: marquez-db
ports:
- "5432:5432"
- "${POSTGRES_PORT}:${POSTGRES_PORT}"
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=password
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ services:
ports:
- "8080:8080"
environment:
DATABASE_URL: postgres://postgres:password@db:5432
DATABASE_URL: postgres://postgres:password@db:${POSTGRES_PORT}
8 changes: 6 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,17 @@ services:
- "db:postgres"
depends_on:
- db
entrypoint: ["/opt/marquez/wait-for-it.sh", "db:5432", "--", "./entrypoint.sh"]
entrypoint:
- /opt/marquez/wait-for-it.sh
- db:${POSTGRES_PORT}
- --
- ./entrypoint.sh

db:
image: postgres:14
container_name: marquez-db
ports:
- "5432:5432"
- "${POSTGRES_PORT}:${POSTGRES_PORT}"
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=password
Expand Down
7 changes: 6 additions & 1 deletion docker/up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ compose_files="-f docker-compose.yml"
API_PORT=5000
API_ADMIN_PORT=5001
WEB_PORT=3000
POSTGRES_PORT=5432
NO_WEB="false"
NO_VOLUMES="false"
TAG="${VERSION}"
Expand All @@ -84,6 +85,10 @@ while [ $# -gt 0 ]; do
shift
WEB_PORT="${1}"
;;
-p|'--pg-port')
shift
POSTGRES_PORT="${1}"
;;
-t|'--tag')
shift
TAG="${1}"
Expand Down Expand Up @@ -142,5 +147,5 @@ if [[ "${NO_VOLUMES}" = "false" ]]; then
fi

# Run docker compose cmd with overrides
DOCKER_SCAN_SUGGEST="false" API_PORT=${API_PORT} API_ADMIN_PORT=${API_ADMIN_PORT} WEB_PORT=${WEB_PORT} TAG=${TAG} \
DOCKER_SCAN_SUGGEST="false" API_PORT=${API_PORT} API_ADMIN_PORT=${API_ADMIN_PORT} WEB_PORT=${WEB_PORT} POSTGRES_PORT=${POSTGRES_PORT} TAG=${TAG} \
docker --log-level ERROR compose $compose_files up $compose_args
2 changes: 1 addition & 1 deletion docs/v2/docs/quickstart/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,4 @@ In this simple example, we showed you how to write sample lineage metadata to a

## Feedback {#feedback}

What did you think of this guide? You can reach out to us on [slack](https://join.slack.com/t/marquezproject/shared_invite/zt-29w4n8y45-Re3B1KTlZU5wO6X6JRzGmA) and leave us feedback, or [open a pull request](https://github.com/MarquezProject/marquez/blob/main/CONTRIBUTING.md#submitting-a-pull-request) with your suggestions!
What did you think of this guide? You can reach out to us on [slack](https://bit.ly/Marquez_Slack_invite) and leave us feedback, or [open a pull request](https://github.com/MarquezProject/marquez/blob/main/CONTRIBUTING.md#submitting-a-pull-request) with your suggestions!
2 changes: 1 addition & 1 deletion marquez.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ server:

db:
driverClass: org.postgresql.Driver
url: jdbc:postgresql://postgres:5432/marquez
url: jdbc:postgresql://postgres:${POSTGRES_PORT:-5432}/marquez
user: marquez
password: marquez

Expand Down

0 comments on commit 465ecaa

Please sign in to comment.