Skip to content

Commit

Permalink
Add solr support (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
reebalazs committed Nov 17, 2023
1 parent d07eaae commit fd72d6c
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 0 deletions.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ recursive-exclude frontend *
exclude instance.yaml
global-exclude *.pyc
global-exclude .DS_Store
recursive-include scripts *.py
44 changes: 44 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ SHELL:=bash
MAKEFLAGS+=--warn-undefined-variables
MAKEFLAGS+=--no-builtin-rules

CURRENT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))

COMPOSE_PROJECT_NAME?="kitconcept_intranet"
SOLR_ONLY_COMPOSE?=${CURRENT_DIR}/docker-compose.yml

# We like colors
# From: https://coderwall.com/p/izxssa/colored-makefile-for-golang-projects
RED=`tput setaf 1`
Expand Down Expand Up @@ -127,3 +132,42 @@ build-image: ## Build Docker Image
.PHONY: run-image
run-image: build-image ## Build Docker Image
docker run --rm -it -p 8080:8080 $(IMAGE_NAME):$(IMAGE_TAG)

## Solr only
.PHONY: solr-prepare
solr-prepare: ## Prepare solr
@echo "$(RED)==> Preparing solr $(RESET)"
mkdir -p ${SOLR_DATA_FOLDER}/solr

.PHONY: start-solr
start-solr: solr-start

.PHONY: stop-solr
stop-solr: solr-stop

.PHONY: start-solr-fg
start-solr-fg: solr-start-fg

.PHONY: solr-start
solr-start: ## Start solr
@echo "Start solr"
@COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME} docker compose -f ${SOLR_ONLY_COMPOSE} up -d

.PHONY: solr-start-fg
solr-start-fg: ## Start solr in foreground
@echo "Start solr in foreground"
@COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME} docker compose -f ${SOLR_ONLY_COMPOSE} up

.PHONY: solr-stop
solr-stop: ## Stop solr
@echo "Stop solr"
@COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME} docker compose -f ${SOLR_ONLY_COMPOSE} down

.PHONY: solr-logs
solr-logs: ## Show solr logs
@echo "Show solr logs"
@COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME} docker compose -f ${SOLR_ONLY_COMPOSE} logs -f

.PHONY: solr-activate-and-reindex
solr-activate-and-reindex: instance/etc/zope.ini ## Activate and reindex solr
PYTHONWARNINGS=ignore ./bin/zconsole run instance/etc/zope.conf scripts/solr_activate_and_reindex.py --clear
15 changes: 15 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: "3"
services:
solr:
image: ghcr.io/kitconcept/solr:latest
ports:
- 8983:8983
volumes:
- solr-data:/var/solr/data
command:
- solr-precreate
- plone
- /plone-config

volumes:
solr-data: {}
Empty file added news/1.feature
Empty file.
20 changes: 20 additions & 0 deletions scripts/solr_activate_and_reindex.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from kitconcept.solr.reindex_helpers import activate_and_reindex
from Testing.makerequest import makerequest
from zope.site.hooks import setSite

import sys
import transaction


if __name__ == "__main__":
app = makerequest(app) # noQA

# Set site to Plone
site_id = "Plone"
portal = app.unrestrictedTraverse(site_id)
setSite(portal)

activate_and_reindex(portal, clear="--clear" in sys.argv)

transaction.commit()
app._p_jar.sync()

0 comments on commit fd72d6c

Please sign in to comment.