Skip to content

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

Publish images via a comprehensive CI + CD workflow (#437)

Dhruv Bhanushali8f1f5b941699
diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/ci_cd.yml
similarity index 72%
rename from .github/workflows/integration_tests.yml
rename to .github/workflows/ci_cd.yml
index 23331ddd5..11c3223ea 100644
--- a/.github/workflows/integration_tests.yml
+++ b/.github/workflows/ci_cd.yml
@@ -1,4 +1,4 @@
-name: Automated tests
+name: CI + CD
on:
pull_request:
branches:
@@ -6,6 +6,9 @@ on:
push:
branches:
- main
+ release:
+ types:
+ - published
workflow_dispatch:
jobs:
@@ -131,3 +134,44 @@ jobs:
run: just api-test -T
- name: Run analytics tests
run: just nl-test -T
+
+ push:
+ name: Publish Docker images
+ runs-on: ubuntu-latest
+ if: github.event == 'release' && github.event.action == 'published'
+ needs:
+ - test-ing
+ - test-api
+ permissions:
+ packages: write
+ contents: read
+ strategy:
+ matrix:
+ image:
+ - openverse_api
+ - ingestion_server
+ - analytics
+ steps:
+ - name: Log in to GitHub Docker Registry
+ uses: docker/login-action@v1
+ with:
+ registry: https://ghcr.io
+ username: ${{ github.actor }}
+ password: ${{ secrets.GITHUB_TOKEN }}
+
+ - name: Download image `${{ matrix.image }}`
+ uses: actions/download-artifact@v2
+ with:
+ name: ${{ matrix.image }}
+ path: /tmp
+
+ - name: Load and tag image `${{ matrix.image }}`
+ run: |
+ docker load --input /tmp/${{ matrix.image }}.tar
+ docker tag ${{ matrix.image }} \
+ ghcr.io/wordpress/openverse-${{ matrix.image }}:latest
+ docker tag ${{ matrix.image }} \
+ ghcr.io/wordpress/openverse-${{ matrix.image }}:${{ github.sha }}
+ docker tag ${{ matrix.image }} \
+ ghcr.io/wordpress/openverse-${{ matrix.image }}:${{ github.ref_name }}
+ docker push --all-tags ghcr.io/wordpress/openverse-${{ matrix.image }}
diff --git a/ingestion_server/README.md b/ingestion_server/README.md
index 6e2750de8..9cb56d940 100644
--- a/ingestion_server/README.md
+++ b/ingestion_server/README.md
@@ -121,12 +121,13 @@ database_table_to_elasticsearch_model = {
}
```
-## Deployment (last deployed version: 1.4.0)
+## Deployment
-This codebase is deployed as Docker image to Docker hub. The deployed image is then pulled in the production environment. See the [`./publish_release.sh`](publish_release.sh) script for deploying to Docker hub. The machine running the script must be logged into Docker as the Openverse account.
+This codebase is deployed as a Docker image to the GitHub Container Registry [ghcr.io](https://ghcr.io). The deployed image is then pulled in the production environment. See the [`ci_cd.yml`](../.github/workflows/ci_cd.yml) workflow for deploying to GHCR.
-The current Docker hub image is at [openverse/ingestion_server](https://hub.docker.com/r/openverse/ingestion_server) but the image previously lived at [creativecommons/ingestion_server](https://hub.docker.com/r/creativecommons/ingestion_server).
+The published image can be deployed using the minimal [`docker-compose.yml`](docker-compose.yml) file defined in this folder (do not forget to update the `.env` file for production). The repository `justfile` can be used, but the environment variable `IS_PROD` must be set to `true` in order for it to reference the production `docker-compose.yml` file here.
-The version numbering for the Docker image appears to be a standalone semver value, separate from the repository version.
+### Old Docker Hub images
-The published image can be deployed using the minimal [`docker-compose.yml`](docker-compose.yml) file defined in this folder (do not forget to update the `.env` file for production). The repository `justfile` can be used, but the environment variable `IS_PROD` must be set to `true` in order for it to reference the production `docker-compose.yml` file here.
+- [openverse/ingestion_server](https://hub.docker.com/r/openverse/ingestion_server)
+- [creativecommons/ingestion_server](https://hub.docker.com/r/creativecommons/ingestion_server)
diff --git a/ingestion_server/docker-compose.yml b/ingestion_server/docker-compose.yml
index de535ff8c..759869bc8 100644
--- a/ingestion_server/docker-compose.yml
+++ b/ingestion_server/docker-compose.yml
@@ -1,7 +1,7 @@
version: "2.4"
services:
ingestion_server:
- image: openverse/ingestion_server:1.4.0
+ image: ghcr.io/wordpress/openverse-ingestion-server:latest
ports:
- "8001:8001"
env_file: