├── .gitignore ├── Makefile ├── .github └── workflows │ ├── push-to-ghcr.yml │ └── dockerimage.yml ├── tests ├── docs.xml └── sphinx.conf ├── LICENSE ├── Dockerfile └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | tests/data 3 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | PWD = $(shell pwd) 2 | 3 | index: 4 | cat ./tests/docs.xml | docker run -i \ 5 | -v $(PWD)/tests/sphinx.conf:/opt/sphinx/conf/sphinx.conf \ 6 | -v $(PWD)/tests/data:/opt/sphinx/indexes \ 7 | --platform linux/amd64 macbre/docker-sphinxsearch \ 8 | indexer --config /opt/sphinx/conf/sphinx.conf test_index 9 | 10 | start: 11 | docker run --detach --rm \ 12 | -v $(PWD)/tests/sphinx.conf:/opt/sphinx/conf/sphinx.conf \ 13 | -v $(PWD)/tests/data:/opt/sphinx/indexes \ 14 | -p 36307:36307 \ 15 | --name sphinx_test \ 16 | --platform linux/amd64 macbre/docker-sphinxsearch 17 | 18 | query: 19 | mysql -h0 -P36307 -e 'show tables' 20 | mysql -h0 -P36307 -e "select * from test_index where match('tags')" 21 | -------------------------------------------------------------------------------- /.github/workflows/push-to-ghcr.yml: -------------------------------------------------------------------------------- 1 | name: Build and publish a Docker image to ghcr.io and Docker Hub 2 | on: 3 | 4 | # publish on releases (tagged as "x.y.z" - "v" prefix is removed) 5 | release: 6 | types: [ published ] 7 | 8 | # publish on pushes to the main branch (tagged as "master") 9 | push: 10 | branches: 11 | - master 12 | 13 | jobs: 14 | docker_publish: 15 | runs-on: ubuntu-latest 16 | 17 | steps: 18 | - uses: actions/checkout@v2 19 | 20 | # https://github.com/marketplace/actions/push-to-ghcr 21 | - name: Build and publish a Docker image for macbre/sphinxsearch 22 | uses: macbre/push-to-ghcr@master 23 | with: 24 | image_name: macbre/sphinxsearch 25 | github_token: ${{ secrets.GITHUB_TOKEN }} 26 | docker_io_token: ${{ secrets.DOCKER_IO_ACCESS_TOKEN }} 27 | -------------------------------------------------------------------------------- /tests/docs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | this is the main content entry 12 | must be handled properly by xml parser lib]]> 13 | 1012325463 14 | note how field/attr tags can be 15 | in randomized order 16 | some undeclared element 17 | 18 | 19 | another subject 20 | here comes another document, and i am given to understand, 21 | that in-document field order must not matter, sir 22 | 1012325467 23 | 24 | 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Maciej Brencz 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /tests/sphinx.conf: -------------------------------------------------------------------------------- 1 | source xml 2 | { 3 | type = xmlpipe2 4 | xmlpipe_fixup_utf8 = 1 5 | xmlpipe_command = cat /dev/stdin 6 | } 7 | 8 | index test_index 9 | { 10 | source = xml 11 | 12 | # @see http://sphinxsearch.com/docs/manual-2.3.2.html#conf-blend-chars 13 | blend_chars = - 14 | 15 | # CALL SUGGEST 16 | min_infix_len = 3 17 | 18 | # wsparcie dla polskich znaków 19 | # @see http://sphinxsearch.com/wiki/doku.php?id=charset_tables#polish 20 | charset_table = 0..9, A..Z->a..z, a..z, U+0143->U+0144, U+0104->U+0105, U+0106->U+0107, U+0118->U+0119, U+0141->U+0142, U+00D3->U+00F3, U+015A->U+015B, U+0179->U+017A, U+017B->U+017C, U+0105, U+0107, U+0119, U+0142, U+00F3, U+015B, U+017A, U+017C, U+0144 21 | } 22 | 23 | indexer 24 | { 25 | mem_limit = 256M 26 | } 27 | 28 | searchd 29 | { 30 | listen = 36307:mysql41 31 | # the defaults are as follows: 32 | # log = /opt/sphinx/logs/searchd.log 33 | # query_log = /opt/sphinx/logs/query.log 34 | # pid_file = /opt/sphinx/searchd.pid 35 | 36 | # binlogs 37 | binlog = 0 # disable logging 38 | } 39 | 40 | common 41 | { 42 | datadir = /opt/sphinx 43 | } 44 | -------------------------------------------------------------------------------- /.github/workflows/dockerimage.yml: -------------------------------------------------------------------------------- 1 | name: Check if a Docker image can be built 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | 8 | jobs: 9 | 10 | build: 11 | 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - uses: actions/checkout@v2 16 | 17 | - name: Build the Docker image 18 | run: | 19 | docker build . --tag ${{ github.repository }} 20 | docker images 21 | 22 | - name: Execute "indexer -v" 23 | run: | 24 | docker run ${{ github.repository }} indexer -v 25 | 26 | - name: Test handling of custom config files (via SPHINX_CONFIG_FILE env variable) 27 | run: | 28 | set -x 29 | 30 | docker run ${{ github.repository }} | grep "using config file '/opt/sphinx/conf/sphinx.conf'" 31 | docker run --env SPHINX_CONFIG_FILE=/etc/sphinx/custom.conf ${{ github.repository }} | grep "using config file '/etc/sphinx/custom.conf'" 32 | 33 | - name: Index the test data 34 | run: | 35 | make index 36 | 37 | - name: Check the index 38 | run: | 39 | set -x 40 | make start && sleep 2 && docker ps 41 | 42 | echo "Make the test queries" 43 | make query 44 | 45 | echo "Logs" 46 | docker logs sphinx_test 47 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # Dockerfile for Sphinx SE 2 | # https://hub.docker.com/r/bitnami/minideb 3 | FROM bitnami/minideb:bookworm 4 | 5 | # https://sphinxsearch.com/blog/ 6 | ENV SPHINX_VERSION=3.8.1-d25e0bb 7 | 8 | # install dependencies 9 | RUN apt-get update \ 10 | && apt-get install -y --no-install-recommends \ 11 | libgomp1 \ 12 | libmariadb3 libmariadb-dev \ 13 | libpq-dev \ 14 | wget 15 | 16 | # set up and expose directories 17 | RUN mkdir -pv /opt/sphinx/logs /opt/sphinx/indexes 18 | VOLUME /opt/sphinx/indexes 19 | 20 | # https://sphinxsearch.com/files/sphinx-3.8.1-d25e0bb-linux-amd64-musl.tar.gz - Alpine 21 | # https://sphinxsearch.com/files/sphinx-3.8.1-d25e0bb-linux-amd64.tar.gz - Debian 22 | RUN wget http://sphinxsearch.com/files/sphinx-${SPHINX_VERSION}-linux-amd64.tar.gz -O /tmp/sphinxsearch.tar.gz \ 23 | && cd /opt/sphinx && tar -xf /tmp/sphinxsearch.tar.gz \ 24 | && rm /tmp/sphinxsearch.tar.gz 25 | 26 | # point to sphinx binaries 27 | ENV PATH="${PATH}:/opt/sphinx/sphinx-3.8.1/bin" 28 | RUN indexer -v 29 | 30 | # redirect logs to stdout 31 | RUN ln -sv /dev/stdout /opt/sphinx/logs/query.log \ 32 | && ln -sv /dev/stdout /opt/sphinx/logs/searchd.log 33 | 34 | # expose TCP port 35 | EXPOSE 36307 36 | 37 | VOLUME /opt/sphinx/conf 38 | 39 | # allow custom config file to be passed 40 | ARG SPHINX_CONFIG_FILE=/opt/sphinx/conf/sphinx.conf 41 | ENV SPHINX_CONFIG_FILE=${SPHINX_CONFIG_FILE} 42 | 43 | # prepare a start script 44 | RUN echo "exec searchd --nodetach --config \${SPHINX_CONFIG_FILE}" > /opt/sphinx/start.sh 45 | 46 | CMD ["sh", "/opt/sphinx/start.sh"] 47 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Docker-sphinxsearch 2 | Docker image for [Sphinx search engine](http://sphinxsearch.com/docs/sphinx3.html) 3 | 4 | ``` 5 | docker pull macbre/sphinxsearch:latest 6 | ``` 7 | 8 | or from GitHub Containers Registry: 9 | 10 | ``` 11 | docker pull ghcr.io/macbre/sphinxsearch:latest 12 | ``` 13 | 14 | ## Usage example 15 | 16 | You can use this image in `docker-compose`-powered app: 17 | 18 | ```yaml 19 | services: 20 | sphinx: 21 | image: macbre/sphinxsearch:3.8.1 22 | ports: 23 | - "127.0.0.1:36307:36307" # bind to local interface only! 24 | volumes: 25 | - ./data:/opt/sphinx/indexes # directory where sphinx will store index data 26 | - ./sphinx.conf:/opt/sphinx/conf/sphinx.conf # SphinxSE configuration file 27 | mem_limit: 512m # match indexer.value from sphinx.conf 28 | ``` 29 | 30 | or you can provide your custom config file: 31 | 32 | ```yaml 33 | services: 34 | sphinx: 35 | image: macbre/sphinxsearch:3.8.1 36 | environment: 37 | - SPHINX_CONFIG_FILE=/opt/sphinx/conf/my_custom_file.conf 38 | ports: 39 | - "127.0.0.1:36307:36307" # bind to local interface only! 40 | volumes: 41 | - ./data:/opt/sphinx/indexes # directory where sphinx will store index data 42 | - ./my_custom_file.conf:/opt/sphinx/conf/my_custom_file.conf # SphinxSE configuration file 43 | mem_limit: 512m # match indexer.value from sphinx.conf 44 | ``` 45 | 46 | 1. First, execute `docker-compose run sphinx indexer --all` to prepare indices. Otherwise, you'd end up with `WARNING: index 'test_index': prealloc: failed to open /opt/sphinx/indexes/test_index/test_index.sph: No such file or directory; NOT SERVING` error. 47 | 2. Then, execute `docker-compose up -d` to run sphinsearch daemon in the background. 48 | 49 | Read more at https://lukaszherok.com/post/view/9/Running%20SphinxSearch%20in%20Podman%20container 50 | 51 | ## [Tags available](https://hub.docker.com/r/macbre/sphinxsearch/tags/) 52 | 53 | ### `3.8.1`, `latest` 54 | 55 | ``` 56 | Sphinx 3.8.1 (commit d25e0bb3) 57 | Copyright (c) 2001-2025, Andrew Aksyonoff 58 | Copyright (c) 2008-2016, Sphinx Technologies Inc (http://sphinxsearch.com) 59 | Built on: #1-Alpine SMP Thu, 18 May 2023 08:53:16 +0000 60 | Built with: GNU 10.3.1 61 | Build date: May 12 2025 62 | Build type: release 63 | Configure flags: cmake 64 | Compiled DB drivers: mysql-dynamic pgsql-dynamic odbc-dynamic 65 | Compiled features: libexpat libstemmer re2 faiss blis 66 | Versions: binlog_format v.22, index_format v.70, udf_api v.23 67 | Enabled dynamic drivers: mysql pgsql 68 | ``` 69 | 70 | ### `3.7.1` 71 | 72 | ``` 73 | Sphinx 3.7.1 (commit da9f8a4e7) 74 | Copyright (c) 2001-2024, Andrew Aksyonoff 75 | Copyright (c) 2008-2016, Sphinx Technologies Inc (http://sphinxsearch.com) 76 | Built on: #1-Alpine SMP Tue, 19 Jul 2022 15:30:18 +0000 77 | Built with: GNU 10.3.1 78 | Build date: Mar 28 2024 79 | Build type: release 80 | Configure flags: cmake 81 | Compiled DB drivers: mysql-dynamic pgsql-dynamic odbc-dynamic 82 | Compiled features: libexpat libstemmer re2 jemalloc 83 | Versions: binlog_format v.11, index_format v.63, udf_api v.23 84 | Enabled dynamic drivers: mysql pgsql 85 | ```` 86 | 87 | ### `3.6.1` 88 | 89 | ``` 90 | Sphinx 3.6.1 (commit c9dbedabf) 91 | Copyright (c) 2001-2023, Andrew Aksyonoff 92 | Copyright (c) 2008-2016, Sphinx Technologies Inc (http://sphinxsearch.com) 93 | 94 | Built on: #1-Alpine SMP Tue, 19 Jul 2022 15:30:18 +0000 95 | Built with: GNU 10.3.1 96 | Build date: Oct 4 2023 97 | Build type: release 98 | Configure flags: cmake 99 | Compiled DB drivers: mysql-dynamic pgsql-dynamic odbc-dynamic 100 | Compiled features: libexpat libstemmer re2 jemalloc 101 | Versions: binlog_format v.10, index_format v.63, udf_api v.23 102 | Enabled dynamic drivers: mysql pgsql 103 | ``` 104 | 105 | ### `3.5.1` 106 | 107 | ``` 108 | Sphinx 3.5.1 (commit 82c60cbfe) 109 | Copyright (c) 2001-2023, Andrew Aksyonoff 110 | Copyright (c) 2008-2016, Sphinx Technologies Inc (http://sphinxsearch.com) 111 | 112 | Built on: Linux alpine314 5.10.131-0-lts #1-Alpine SMP Tue, 19 Jul 2022 15:30:18 +0000 x86_64 Linux 113 | Built with: gcc 10.3.1 114 | Build date: Feb 2 2023 115 | Build type: release 116 | Configure flags: '--enable-dl' '--with-mysql' '--with-pgsql' '--with-unixodbc' 'CXXFLAGS=-DSPHINX_TAG= -DNDEBUG -O3 -g1 -D__MUSL__' 'LDFLAGS=-static-libstdc++ -static-libgcc' 117 | Compiled DB drivers: mysql-dynamic pgsql-dynamic odbc-dynamic 118 | Compiled features: libexpat libstemmer re2 jemalloc 119 | Versions: binlog_format v.10, index_format v.62, udf_api v.23 120 | ``` 121 | 122 | ### `3.4.1` 123 | 124 | ``` 125 | Sphinx 3.4.1 (commit efbcc658) 126 | Copyright (c) 2001-2021, Andrew Aksyonoff 127 | Copyright (c) 2008-2016, Sphinx Technologies Inc (http://sphinxsearch.com) 128 | 129 | Built on: Linux alpine312 5.4.43-1-lts #2-Alpine SMP Thu, 28 May 2020 20:13:48 UTC x86_64 Linux 130 | Built with: gcc 9.3.0 131 | Build date: Jul 9 2021 132 | Build type: release 133 | Configure flags: '--enable-dl' '--with-mysql' '--with-pgsql' '--with-unixodbc' 'CXXFLAGS=-DSPHINX_TAG= -DNDEBUG -O3 -g1 -D__MUSL__' 'LDFLAGS=-static-libstdc++ -static-libgcc' 134 | Compiled DB drivers: mysql-dynamic pgsql-dynamic odbc-dynamic 135 | Versions: binlog_format v.8, index_format v.55, udf_api v.17 136 | Enabled dynamic drivers: mysql pgsql 137 | ``` 138 | 139 | ### `3.3.1` 140 | 141 | ``` 142 | Sphinx 3.3.1 (commit b72d67bc) 143 | Copyright (c) 2001-2020, Andrew Aksyonoff 144 | Copyright (c) 2008-2016, Sphinx Technologies Inc (http://sphinxsearch.com) 145 | 146 | Built on: Linux alpine312 5.4.43-1-lts #2-Alpine SMP Thu, 28 May 2020 20:13:48 UTC x86_64 Linux 147 | Built with: gcc 9.3.0 148 | Build date: Jul 6 2020 149 | Build type: release 150 | Configure flags: '--enable-dl' '--with-mysql' '--with-pgsql' '--with-unixodbc' 'CXXFLAGS=-DSPHINX_TAG= -DNDEBUG -O3 -g1 -D__MUSL__' 'LDFLAGS=-static-libstdc++ -static-libgcc' 151 | Compiled DB drivers: mysql-dynamic pgsql-dynamic odbc-dynamic 152 | Enabled dynamic drivers: mysql pgsql 153 | ``` 154 | 155 | ### `3.2.1` 156 | 157 | ``` 158 | Sphinx 3.2.1 (commit f152e0b8) 159 | Copyright (c) 2001-2020, Andrew Aksyonoff 160 | Copyright (c) 2008-2016, Sphinx Technologies Inc (http://sphinxsearch.com) 161 | 162 | Built on: Linux alpine38 4.14.69-0-vanilla #1-Alpine SMP Mon Sep 10 19:33:23 UTC 2018 x86_64 Linux 163 | Built with: gcc 6.4.0 164 | Build date: Jan 31 2020 165 | Build type: release 166 | Configure flags: '--enable-dl' '--with-mysql' '--with-pgsql' '--with-unixodbc' 'CXXFLAGS=-DSPHINX_TAG= -DNDEBUG -O3 -g1 -D__MUSL__' 'LDFLAGS=-static-libstdc++ -static-libgcc' 167 | Compiled DB drivers: mysql-dynamic pgsql-dynamic odbc-dynamic 168 | Enabled dynamic drivers: mysql pgsql 169 | ``` 170 | 171 | ### `3.1.1` 172 | 173 | ``` 174 | Sphinx 3.1.1 (commit 612d99f4) 175 | Copyright (c) 2001-2018, Andrew Aksyonoff 176 | Copyright (c) 2008-2016, Sphinx Technologies Inc (http://sphinxsearch.com) 177 | 178 | Built on: Linux alpine38 4.14.69-0-vanilla #1-Alpine SMP Mon Sep 10 19:33:23 UTC 2018 x86_64 Linux 179 | Built with: gcc 6.4.0 180 | Build date: Oct 17 2018 181 | Build type: release 182 | Configure flags: '--enable-dl' '--with-mysql' '--with-pgsql' '--with-unixodbc' 'CXXFLAGS=-DSPHINX_TAG= -DNDEBUG -O3 -g1 -D__MUSL__' 'LDFLAGS=-static-libstdc++ -static-libgcc' 183 | Compiled DB drivers: mysql-dynamic pgsql-dynamic odbc-dynamic 184 | Enabled dynamic drivers: mysql pgsql 185 | ``` 186 | 187 | ### `3.0.3` 188 | 189 | ``` 190 | Sphinx 3.0.3 (commit facc3fb) 191 | Copyright (c) 2001-2018, Andrew Aksyonoff 192 | Copyright (c) 2008-2016, Sphinx Technologies Inc (http://sphinxsearch.com) 193 | 194 | Built on: Linux ubuntu16 4.4.0-116-generic #140-Ubuntu SMP Mon Feb 12 21:23:04 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux 195 | Built with: gcc 5.4.0 196 | Build date: Mar 30 2018 197 | Build type: release 198 | Configure flags: '--enable-dl' '--with-mysql' '--with-pgsql' '--with-unixodbc' 'CXXFLAGS=-DSPHINX_TAG= -DNDEBUG -O3 -g1' 'LDFLAGS=-static-libstdc++' 199 | Compiled DB drivers: mysql-dynamic pgsql-dynamic odbc-dynamic 200 | Enabled dynamic drivers: mysql pgsql 201 | ``` 202 | 203 | ### `3.0.1` 204 | 205 | ``` 206 | Sphinx 3.0.1 (commit 7fec4f6) 207 | Copyright (c) 2001-2017, Andrew Aksyonoff 208 | Copyright (c) 2008-2016, Sphinx Technologies Inc (http://sphinxsearch.com) 209 | 210 | Built on: Linux ubuntu16desktop 4.4.0-101-generic #124-Ubuntu SMP Fri Nov 10 18:29:59 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux 211 | Built with: gcc 5.4.0 212 | Build date: Dec 17 2017 213 | Build type: release 214 | Configure flags: '--enable-dl' '--with-mysql' '--with-pgsql' 'CXXFLAGS=-DSPHINX_TAG= -g1' 'LDFLAGS=-static-libstdc++' 215 | Compiled DB drivers: mysql-dynamic pgsql-dynamic 216 | Enabled dynamic drivers: mysql pgsql 217 | ``` 218 | 219 | ## Testing your changes locally 220 | 221 | ``` 222 | docker build . -t macbre/docker-sphinxsearch 223 | 224 | # or fetch from the repository and tag it accordingly 225 | docker pull ghcr.io/macbre/sphinxsearch:latest 226 | docker tag ghcr.io/macbre/sphinxsearch:latest macbre/docker-sphinxsearch 227 | 228 | make index 229 | make start && sleep 2 230 | make query 231 | ``` 232 | --------------------------------------------------------------------------------