Skip to content

Openverse is a search engine for openly-licensed media. This monorepo includes all application code.

Tag API images with PDM content hash (#4278)

Dhruv Bhanushali54d34c19d3de
diff --git a/api/compose.yml b/api/compose.yml
index bdd0e6667..18ca2a052 100644
--- a/api/compose.yml
+++ b/api/compose.yml
@@ -17,7 +17,7 @@ services:
- SEMANTIC_VERSION=${SEMANTIC_VERSION:-v1.0.0}
- API_PY_VERSION
- PDM_INSTALL_ARGS=--dev
- image: openverse-api
+ image: openverse-api:${API_PDM_HASH:-latest}
volumes:
- .:/api:z
- ../packages/python:/packages/python:z
diff --git a/api/justfile b/api/justfile
index 65f4ae22c..ee725d8f9 100644
--- a/api/justfile
+++ b/api/justfile
@@ -16,9 +16,14 @@ NO_COLOR := "\\033[0m"
# These commands use standard GNU tools instead of `pdm` because we do not
# require PDM on the host machine for API development.
+export API_PDM_HASH := `grep 'content_hash' pdm.lock | awk -F'[:"]' '{print $3}'`
export API_PY_VERSION := `grep 'requires-python' pyproject.toml | awk -F'"' '{print $2}' | sed 's/^==//g; s/\.\*$//g'`
export PGCLI_VERSION := `grep -A 1 'name = "pgcli"' pdm.lock | grep 'version' | awk -F'"' '{print $2}'`
+# Print the PDM content hash as a unique identifier for the current set of packages
+@pdm-hash:
+ echo $API_PDM_HASH
+
# Print the Python version specified in `pyproject.toml`
@py-version:
echo $API_PY_VERSION
diff --git a/justfile b/justfile
index 6a7a89e6c..fd61faf7e 100644
--- a/justfile
+++ b/justfile
@@ -136,6 +136,7 @@ EXEC_DEFAULTS := if IS_CI == "" { "" } else { "-T" }
export CATALOG_PY_VERSION := `just catalog/py-version`
export CATALOG_AIRFLOW_VERSION := `just catalog/airflow-version`
export API_PY_VERSION := `just api/py-version`
+export API_PDM_HASH := `just api/pdm-hash`
export INGESTION_PY_VERSION := `just ingestion_server/py-version`
export FRONTEND_NODE_VERSION := `just frontend/node-version`
export FRONTEND_PNPM_VERSION := `just frontend/pnpm-version`