This commit is contained in:
Stefan Hardegger
2025-09-22 10:13:49 +02:00
parent 87f37567fb
commit f61be90d5c
2 changed files with 39 additions and 18 deletions

View File

@@ -68,7 +68,9 @@ services:
solr:
image: solr:9.9.0
build:
context: .
dockerfile: solr.Dockerfile
ports:
- "8983:8983" # Expose Solr Admin UI for development
environment:
@@ -76,23 +78,6 @@ services:
- SOLR_JAVA_MEM=-Xms256m -Xmx512m
volumes:
- solr_data:/var/solr
- ./solr/stories:/opt/solr-9.9.0/server/solr/configsets/storycove_stories
- ./solr/authors:/opt/solr-9.9.0/server/solr/configsets/storycove_authors
command: >
sh -c "
echo 'Starting Solr...' &&
solr start -f &
SOLR_PID=$$! &&
echo 'Waiting for Solr to be ready...' &&
sleep 15 &&
echo 'Creating cores...' &&
(solr create_core -c storycove_stories -d storycove_stories || echo 'Stories core already exists') &&
echo 'Stories core ready' &&
(solr create_core -c storycove_authors -d storycove_authors || echo 'Authors core already exists') &&
echo 'Authors core ready' &&
echo 'Both cores are available' &&
wait $$SOLR_PID
"
deploy:
resources:
limits:

36
solr.Dockerfile Normal file
View File

@@ -0,0 +1,36 @@
FROM solr:9.9.0
# Switch to root to set up configuration
USER root
# Copy Solr configurations into the image
COPY ./solr/stories /opt/solr-9.9.0/server/solr/configsets/storycove_stories
COPY ./solr/authors /opt/solr-9.9.0/server/solr/configsets/storycove_authors
# Create initialization script
COPY <<EOF /opt/solr-init.sh
#!/bin/bash
echo "Starting Solr..."
solr start -f &
SOLR_PID=\$!
echo "Waiting for Solr to be ready..."
sleep 15
echo "Creating cores..."
(solr create_core -c storycove_stories -d storycove_stories || echo "Stories core already exists")
echo "Stories core ready"
(solr create_core -c storycove_authors -d storycove_authors || echo "Authors core already exists")
echo "Authors core ready"
echo "Both cores are available"
wait \$SOLR_PID
EOF
# Ensure proper permissions
RUN chown -R solr:solr /opt/solr-9.9.0/server/solr/configsets/ && \
chmod +x /opt/solr-init.sh && \
chown solr:solr /opt/solr-init.sh
# Switch back to solr user
USER solr
# Set the entrypoint to our initialization script
ENTRYPOINT ["/opt/solr-init.sh"]