I am currently working on a project with a PostgreSQL, Redis, Medusa and Solr implementation.
I want to run all my applications containerized so that I can easily deploy it to my Linux Server.
My issue is that when I try to run a containerized Solr instance from my docker-compose.yml
it ends up being unable to find the Request Handlers
I have created.
When I access the admin GUI running on localhost:8983 I am able to see my core and run the /select
Request Handler.
Inside the GUI when I open my Core (called product_core) under the files I see an entirely different directory.
It seems that I cannot get my Solr instance to find my own solrconfig.xml files even though they're copied to the image.
Which I can see when I docker exec -it solr /bin/bash
into my Solr instance.
Inside the Solr instance in the directory:/var/solr/data/product_core
I can see the files that the GUI shows, but I cannot seem to get it to work to copy the files.
Below is my docker-compose.yml file:
version: "3.8"
services:
backend:
build:
context: ./medusa_backend
dockerfile: Dockerfile
image: dahlfrederik/medusa_backend
container_name: medusa_backend
depends_on:
- postgres
- redis
environment:
DATABASE_URL: postgresql://postgres:alpha123@postgres:5432/postgres
REDIS_URL: redis://redis:6379/
NODE_ENV: development
JWT_SECRET: some_jwt_secret
COOKIE_SECRET: some_cookie_secret
PORT: 9000
ADMIN_CORS: http://localhost:7000,http://localhost:7001,http://192.168.98.141:7000,http://localhost:7000
STORE_CORS: http://localhost:3000,http://192.168.98.141:8000,http://localhost:8000
MEDUSA_DISABLE_TELEMETRY: "true"
volumes:
- ./medusa_backend/data:/var/lib/postgresql/data
ports:
- "9000:9000"
restart: always
postgres:
image: postgres:10.4
container_name: postgres
ports:
- "5432:5432"
volumes:
- ./postgres/data:/var/lib/postgresql/data
restart: always
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=alpha123
- POSTGRES_DB=postgres
redis:
image: redis
container_name: redis
expose:
- 6379
restart: always
admin:
build:
context: ./medusa_admin
dockerfile: Dockerfile
image: dahlfrederik/medusa_admin
container_name: medusa_admin
depends_on:
- backend
environment:
HOST: 0.0.0.0
PORT: 7000
ports:
- "7000:7000"
restart: always
storefront:
build:
context: ./nextjs_frontend
dockerfile: Dockerfile
image: dahlfrederik/medusa_storefront
container_name: storefront
depends_on:
- backend
environment:
PORT: 8000
ports:
- "8000:8000"
restart: always
solr:
image: solr
container_name: solr
depends_on:
- postgres
ports:
- "8983:8983"
volumes:
- data:/var/solr
- ./solr:/opt/solr/server/solr/product_core
entrypoint:
- docker-entrypoint.sh
- solr-precreate
- product_core
restart: always
volumes:
data:
My Solr config file are located in the directory Solr which is placed inside the folder containing my docker-compose file.
I have created a managed-schema.xml
as below
<?xml version="1.0" encoding="UTF-8" ?>
<schema name="default-config" version="1.6">
<field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="title" type="text_general" indexed="true" stored="true" />
<field name="description" type="text_general" indexed="true" stored="true" />
<field name="type" type="string" indexed="true" stored="true" />
<field name="size" type="string" indexed="true" stored="true" />
<field name="price" type="string" indexed="true" stored="true" />
<field name="image" type="string" indexed="false" stored="true" />
<field name="inStock" type="boolean" indexed="false" stored="true" />
<uniqueKey>id</uniqueKey>
<fieldType name="string" class="solr.StrField" />
<fieldType name="text_general" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" />
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.ASCIIFoldingFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" />
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.ASCIIFoldingFilterFactory"/>
</analyzer>
</fieldType>
<fieldType name="boolean" class="solr.BoolField" />
</schema>
And I have created a solrconfig.xml as below:
<?xml version="1.0" encoding="UTF-8" ?>
<config>
<requestHandler name="/search" class="solr.SearchHandler">
<lst name="defaults">
<str name="echoParams">explicit</str>
<int name="rows">100</int>
<str name="fl">id,title,description,type,size,price,image,inStock</str>
<str name="facet">true</str>
<str name="facet.mincount">1</str>
<str name="facet.field">size</str>
<str name="facet.field">price</str>
<str name="facet.field">color</str>
</lst>
<lst name="invariants">
<str name="defType">edismax</str>
<str name="qf">title^2 description</str>
</lst>
<arr name="last-components">
<str>facet</str>
</arr>
</requestHandler>
<requestHandler name="/autocomplete_search" class="solr.SearchHandler">
<lst name="defaults">
<str name="echoParams">all</str>
<str name="df">text</str>
<int name="rows">10</int>
<str name="fl">title,image</str>
</lst>
</requestHandler>
<searchComponent name="facet">
<lst name="facet">
<bool name="facet.sort">true</bool>
<lst name="facet.field">
<str name="field">size</str>
<bool name="facet.missing">true</bool>
<bool name="facet.sort">false</bool>
<int name="facet.limit">-1</int>
</lst>
<lst name="facet.range">
<str name="field">price</str>
<int name="mincount">1</int>
<str name="method">dv</str>
</lst>
<lst name="facet.field">
<str name="field">color</str>
</lst>
</lst>
</searchComponent>
<requestHandler name="/select" class="solr.SearchHandler">
<lst name="defaults">
<str name="echoParams">explicit</str>
<int name="rows">10</int>
<str name="fl">id,title,description,type,size,price</str>
<str name="facet">true</str>
<str name="facet.mincount">1</str>
<str name="facet.field">size</str>
<str name="facet.field">price</str>
<str name="facet.field">color</str>
</lst>
<arr name="last-components">
<str>facet</str>
</arr>
</requestHandler>
<updateRequestProcessorChain name="uuid">
<processor class="solr.UUIDUpdateProcessorFactory">
<str name="fieldName">id</str>
</processor>
<processor class="solr.LogUpdateProcessorFactory"/>
<processor class="solr.RunUpdateProcessorFactory"/>
</updateRequestProcessorChain>
</config>
So it appears that I somehow copy my files to the wrong destination - but when I try to copy it to the one that I can see inside the Solr GUI it does not find my core.
Thanks in advance for any suggestions.
I tried to change the directory in which the config files are stored. I've tried docker-compose up --build -d. Tried changing to use entrypoint instead of command in the docker-compose.yml file
It turned out that my issues was that the config files was saved at the wrong locations in my docker instance - I figured that out by adding a dummy text file HelloWorld.txt
and then using Linux search command to find that file and its location.
I solved my problem by adding a script to my Azure build/deployment pipeline that copies the content of my solr-conf folder to my docker instance and then running the reload core command.
So my solution was to run a script that executes following commands:
docker cp {path-to-my-solr-config-folder]\solr\conf\. solr:/var/solr/data/{core-name]/conf
Then I execute the following post command.
curl -X POST http://localhost:8983/solr/admin/cores?action=RELOAD&core={core-name}
It could probably have been done more intuitively and I am still thinking about adding the commands directly to my docker-compose.yml
file. But for now this was a way to solve my problem.