diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml new file mode 100644 index 00000000..7a7ca209 --- /dev/null +++ b/.github/workflows/docker.yaml @@ -0,0 +1,65 @@ +name: Build & Push to GHCR + +on: + workflow_dispatch: + push: + # tags: + # - 'v*' + # - '!v*-alpha*' + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout source + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to GHCR + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract version & image name + id: vars + run: | + if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then + raw_tag="${GITHUB_REF#refs/tags/}" + version="${raw_tag#v}" + else + # ----- Branch / PR fallback ----- + branch="${GITHUB_REF#refs/heads/}" + # Replace / and uppercase chars with safe lowercase dashes + safe_branch=$(echo "$branch" | tr '[:upper:]/' '[:lower:]-') + sha=${GITHUB_SHA::8} + raw_tag="${safe_branch}-${sha}" + version="$raw_tag" + fi + image_repo="ghcr.io/${GITHUB_REPOSITORY,,}" + echo "raw_tag=$raw_tag" >> "$GITHUB_OUTPUT" + echo "version=$version" >> "$GITHUB_OUTPUT" + echo "image_repo=$image_repo" >> "$GITHUB_OUTPUT" + + - name: Build & push image + uses: docker/build-push-action@v5 + with: + context: . + push: true + platforms: linux/amd64,linux/arm64 + tags: | + ${{ steps.vars.outputs.image_repo }}:${{ steps.vars.outputs.version }} + ${{ steps.vars.outputs.image_repo }}:${{ steps.vars.outputs.raw_tag }} + ${{ steps.vars.outputs.image_repo }}:latest + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..315fd8d8 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +# syntax=docker/dockerfile:1 +FROM solr:8.11.2 + +USER root +ENV IBEXA_TEMPLATE_DIR=/opt/solr/server/ibexa/template + +RUN mkdir -p ${IBEXA_TEMPLATE_DIR} +COPY src/lib/Resources/config/solr/ ${IBEXA_TEMPLATE_DIR}/ + +RUN set -eux; \ + mkdir -p /opt/solr/server/ibexa; \ + for f in solrconfig.xml stopwords.txt synonyms.txt; do \ + cp /opt/solr/server/solr/configsets/_default/conf/$f ${IBEXA_TEMPLATE_DIR}/; \ + done; \ + cp /opt/solr/server/solr/solr.xml /opt/solr/server/ibexa/ + +RUN sed -i.bak '//d' \ + ${IBEXA_TEMPLATE_DIR}/solrconfig.xml \ + && sed -i '//,/<\/autoSoftCommit>/c\\n ${solr.autoSoftCommit.maxTime:20}\n' \ + ${IBEXA_TEMPLATE_DIR}/solrconfig.xml + + +USER solr +ENV SOLR_CORE=collection1 +CMD ["bash", "-c", "solr-precreate \"$SOLR_CORE\" \"$IBEXA_TEMPLATE_DIR\""]