Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
232 changes: 224 additions & 8 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,24 @@ on:
description: 'invenio-override repo branch'
required: false
default: 'main'
variant:
type: choice
description: Choose the instance variant
options:
- mug
- oer
- basic
- vanilla
required: false
default: mug
recreate:
type: choice
description: Recreate instance (passed to gitlab pipeline)
options:
- true
- false
required: false
default: false

jobs:

Expand All @@ -39,6 +57,7 @@ jobs:
pip install uv

- name: Install invenio-override
if: ${{ !startsWith( github.ref, 'refs/tags') }}
run: |
mkdir .venv
uv venv .venv
Expand All @@ -53,10 +72,13 @@ jobs:
install_cmd='uv pip install git+https://github.com/sharedRDM/invenio-override@${INVENIO_OVERRIDE_BRANCH}'
eval "$install_cmd"

- name: Change pyproject.toml
if: "${{ github.event.inputs.invenio-override-branch != '' }}"
- name: Change pyproject.toml override branch
if: "${{ github.event.inputs.invenio-override-branch != '' && !startsWith( github.ref, 'refs/tags') }}"
run: sed -i 's/invenio-override", branch = "main"/invenio-override", branch = "${{ github.event.inputs.invenio-override-branch }}"/g' pyproject.toml

- name: Change pyproject.toml override MUG
run: sed -i 's/-override ~/-override[marc21] ~/g' pyproject.toml

- name: Relock uv
run: |
source .venv/bin/activate
Expand Down Expand Up @@ -101,7 +123,176 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}


build-and-push-theme:
build-and-push-oer:
runs-on: ubuntu-22.04
permissions:
contents: read
packages: write

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.12'

- name: Install uv package
run: |
pip install uv

- name: Install invenio-override
if: ${{ !startsWith( github.ref, 'refs/tags') }}
run: |
mkdir .venv
uv venv .venv
source .venv/bin/activate

if [[ '${{ github.event.inputs.invenio-override-branch }}' == '' ]]; then
INVENIO_OVERRIDE_BRANCH="main"
else
INVENIO_OVERRIDE_BRANCH="${{ github.event.inputs.invenio-override-branch }}"
fi

install_cmd='uv pip install git+https://github.com/sharedRDM/invenio-override@${INVENIO_OVERRIDE_BRANCH}'
eval "$install_cmd"

- name: Change pyproject.toml override branch
if: "${{ github.event.inputs.invenio-override-branch != '' && !startsWith( github.ref, 'refs/tags') }}"
run: sed -i 's/invenio-override", branch = "main"/invenio-override", branch = "${{ github.event.inputs.invenio-override-branch }}"/g' pyproject.toml

- name: Change pyproject.toml override OER
run: sed -i 's/-override ~/-override[lom] ~/g' pyproject.toml

- name: Relock uv
run: |
source .venv/bin/activate
uv lock --upgrade
deactivate
rm -rf .venv

- name: Convert repository name to lowercase
run: echo "IMAGE_NAME=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV

- name: Determine Docker tag (from tag or branch)
id: get_tag
run: |
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
TAG_NAME="${GITHUB_REF#refs/tags/}"
else
TAG_NAME="${GITHUB_REF#refs/heads/}"
fi
echo "DOCKER_TAG=$TAG_NAME" >> $GITHUB_ENV

- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push OER Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
file: Dockerfile.oer
push: true
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.DOCKER_TAG }}-oer
labels: ${{ steps.meta.outputs.labels }}


build-and-push-basic:
runs-on: ubuntu-22.04
permissions:
contents: read
packages: write

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.12'

- name: Install uv package
run: |
pip install uv

- name: Install invenio-override
if: ${{ !startsWith( github.ref, 'refs/tags') }}
run: |
mkdir .venv
uv venv .venv
source .venv/bin/activate

if [[ '${{ github.event.inputs.invenio-override-branch }}' == '' ]]; then
INVENIO_OVERRIDE_BRANCH="main"
else
INVENIO_OVERRIDE_BRANCH="${{ github.event.inputs.invenio-override-branch }}"
fi

install_cmd='uv pip install git+https://github.com/sharedRDM/invenio-override@${INVENIO_OVERRIDE_BRANCH}'
eval "$install_cmd"

- name: Change pyproject.toml override branch
if: "${{ github.event.inputs.invenio-override-branch != '' && !startsWith( github.ref, 'refs/tags') }}"
run: sed -i 's/invenio-override", branch = "main"/invenio-override", branch = "${{ github.event.inputs.invenio-override-branch }}"/g' pyproject.toml

- name: Relock uv
run: |
source .venv/bin/activate
uv lock --upgrade
deactivate
rm -rf .venv

- name: Convert repository name to lowercase
run: echo "IMAGE_NAME=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV

- name: Determine Docker tag (from tag or branch)
id: get_tag
run: |
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
TAG_NAME="${GITHUB_REF#refs/tags/}"
else
TAG_NAME="${GITHUB_REF#refs/heads/}"
fi
echo "DOCKER_TAG=$TAG_NAME" >> $GITHUB_ENV

- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Basic Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
file: Dockerfile.basic
push: true
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.DOCKER_TAG }}-basic
labels: ${{ steps.meta.outputs.labels }}


build-and-push-vanilla:
runs-on: ubuntu-22.04
permissions:
contents: read
Expand All @@ -111,6 +302,28 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.12'

- name: Install uv package
run: |
pip install uv

- name: Change pyproject.toml no override
run: sed -i 's/"invenio-override ~=0.0.6",//g' pyproject.toml

- name: Relock uv
run: |
mkdir .venv
uv venv .venv
source .venv/bin/activate
uv pip uninstall invenio-override
uv lock --upgrade
deactivate
rm -rf .venv

- name: Convert repository name to lowercase
run: echo "IMAGE_NAME=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV

Expand All @@ -137,22 +350,25 @@ jobs:
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Theme Docker image
- name: Build and push Vanilla Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
file: Dockerfile.theme
file: Dockerfile.basic
push: true
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.DOCKER_TAG }}-theme
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.DOCKER_TAG }}-vanilla
labels: ${{ steps.meta.outputs.labels }}


trigger-gitlab-pipeline:
name: Trigger GitLab Pipeline
runs-on: ubuntu-latest
needs:
- build-and-push-mug
- build-and-push-theme
- build-and-push-oer
- build-and-push-basic
- build-and-push-vanilla

steps:
- name: Set Docker tag environment
Expand All @@ -172,5 +388,5 @@ jobs:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
PROJECT_ID: 45464
REF_NAME: 'main'
PIPELINE_VARIABLES: '{"DOCKER_IMAGE_TAG":"${{ env.DOCKER_TAG }}", "DOCKER_IMAGE_TAG_INSTANCE":"mug"}'
PIPELINE_VARIABLES: '{"DOCKER_IMAGE_TAG":"${{ env.DOCKER_TAG }}", "DOCKER_IMAGE_TAG_INSTANCE":"${{ github.event.inputs.variant }}", "RECREATE_INSTANCE":"${{ github.event.inputs.recreate }}"}'

2 changes: 1 addition & 1 deletion Dockerfile.theme → Dockerfile.basic
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ COPY --from=builder ${INVENIO_INSTANCE_PATH}/templates ${INVENIO_INSTANCE_PATH}/
WORKDIR ${WORKING_DIR}/src

COPY ./docker/uwsgi/ ${INVENIO_INSTANCE_PATH}
COPY ./invenio.cfg ${INVENIO_INSTANCE_PATH}
COPY ./themes/override-basic/invenio.cfg ${INVENIO_INSTANCE_PATH}
RUN chown invenio:invenio .

USER invenio
Expand Down
43 changes: 43 additions & 0 deletions Dockerfile.oer
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# STAGE 1
FROM ghcr.io/tu-graz-library/docker-invenio-base:main-builder AS builder

COPY pyproject.toml uv.lock ./

RUN uv sync --frozen

# to use rspack
ENV INVENIO_WEBPACKEXT_PROJECT="invenio_assets.webpack:rspack_project"

COPY ./app_data/ ${INVENIO_INSTANCE_PATH}/app_data/
COPY ./assets/ ${INVENIO_INSTANCE_PATH}/assets/
COPY ./static/ ${INVENIO_INSTANCE_PATH}/static/
COPY ./translations ${INVENIO_INSTANCE_PATH}/translations/
COPY ./templates ${INVENIO_INSTANCE_PATH}/templates/

# Replace variables.less
COPY themes/MUG/variables.less /opt/env/lib/python3.12/site-packages/invenio_override/assets/semantic-ui/less/invenio_override/variables.less

RUN invenio collect --verbose && invenio webpack create

WORKDIR ${INVENIO_INSTANCE_PATH}/assets
RUN pnpm install
RUN pnpm run build

# STAGE 2
FROM ghcr.io/tu-graz-library/docker-invenio-base:main-frontend AS frontend

COPY --from=builder ${VIRTUAL_ENV}/lib ${VIRTUAL_ENV}/lib
COPY --from=builder ${VIRTUAL_ENV}/bin ${VIRTUAL_ENV}/bin
COPY --from=builder ${INVENIO_INSTANCE_PATH}/app_data ${INVENIO_INSTANCE_PATH}/app_data
COPY --from=builder ${INVENIO_INSTANCE_PATH}/static ${INVENIO_INSTANCE_PATH}/static
COPY --from=builder ${INVENIO_INSTANCE_PATH}/translations ${INVENIO_INSTANCE_PATH}/translations
COPY --from=builder ${INVENIO_INSTANCE_PATH}/templates ${INVENIO_INSTANCE_PATH}/templates

WORKDIR ${WORKING_DIR}/src
COPY ./docker/uwsgi/ ${INVENIO_INSTANCE_PATH}
COPY ./themes/override-oer/invenio.cfg ${INVENIO_INSTANCE_PATH}
RUN chown invenio:invenio .

USER invenio

ENTRYPOINT [ "bash", "-c"]
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,14 @@ For detailed steps on working with UV, check the [Working with UV](./UV-GUIDE.md

## Docker Images

Each image has a correspondent instance _variant_ that a user can choose to deploy.

| Name | Description |
|---|---|
| ``Dockerfile`` | Dockerfile used to build base image, without theme. |
| ``Dockerfile.mug`` | Dockerfile used to build MUG image. |
| ``Dockerfile.theme`` | Dockerfile used to build default override theme image. |
| ``Dockerfile`` | Dockerfile used to build base image, without theme. - no variant, used for local testing. |
| ``Dockerfile.mug`` | Dockerfile used to build MUG image. (with Publications) - variant **mug** |
| ``Dockerfile.oer`` | Dockerfile used to build Educational Resources image (OER). - variant **oer** |
| ``Dockerfile.basic`` | Dockerfile used to base invenio-override image (no OER or Publications) and also base invenio theme (without invenio-override) - variants **basic** and **vanilla** |


## CI/CD
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ authors = [

dependencies = [
"invenio-app-rdm[opensearch2] ~=13.0.0b3.dev2",
"invenio-rdm-records>=18.11.0,<19.0.0",
"invenio-logging[sentry_sdk]>=4.0.0,<5.0.0",
"uwsgi >=2.0",
"uwsgitop >=0.11",
"uwsgi-tools >=1.1.1",
"invenio-override[marc21] ~=0.0.6",
"invenio-override ~=0.0.6",
]

[tool.setuptools]
Expand Down
1 change: 1 addition & 0 deletions themes/override-base/additional.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Example config for instance installation with invenio-override withour OER and Publications (basic) or completely without invenio-override (vanilla invenioRDM).
Loading