From cfdbb2c6091e300017aeee4224d9c5f21cd55421 Mon Sep 17 00:00:00 2001 From: Disassembler Date: Wed, 13 Dec 2017 15:58:29 +0100 Subject: [PATCH] Move Solr to /opt and create separate UID/GID --- solr.sh | 1 + solr/Dockerfile | 18 ++++++++++-------- solr/lib/systemd/system/solr.service | 2 +- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/solr.sh b/solr.sh index 760ef2d..6b13061 100755 --- a/solr.sh +++ b/solr.sh @@ -8,6 +8,7 @@ docker build -t solr ${SOURCE_DIR} # Configure Solr mkdir -p /srv/solr/data cp ${SOURCE_DIR}/srv/solr/data/solr.xml /srv/solr/data/solr.xml +chown -R 8983:8983 /srv/solr/data # Configure Solr service cp ${SOURCE_DIR}/lib/systemd/system/solr.service /lib/systemd/system/solr.service diff --git a/solr/Dockerfile b/solr/Dockerfile index 0de7a68..47382d7 100644 --- a/solr/Dockerfile +++ b/solr/Dockerfile @@ -5,16 +5,18 @@ RUN apk --no-cache add openjdk8-jre-base RUN apk --no-cache add bash lsof \ && wget http://archive.apache.org/dist/lucene/solr/6.5.1/solr-6.5.1.tgz -O /tmp/solr-6.5.1.tgz \ - && tar xzf /tmp/solr-6.5.1.tgz -C /srv/ \ - && mv /srv/solr-6.5.1 /srv/solr \ + && mkdir /opt \ + && tar xzf /tmp/solr-6.5.1.tgz -C /opt/ \ + && mv /opt/solr-6.5.1 /opt/solr \ && rm -f /tmp/solr-6.5.1.tgz \ - && addgroup -S solr \ - && adduser -S -h /srv/solr -H -s /bin/sh -g solr -G solr solr \ - && chown -R solr:solr /srv/solr/ \ - && ln -s /srv/solr/bin/solr /usr/local/bin/solr + && addgroup -S -g 8983 solr \ + && adduser -S -u 8983 -h /var/lib/solr -s /bin/sh -g solr -G solr solr \ + && chown -R solr:solr /opt/solr/ \ + && cp -p /opt/solr/server/solr/solr.xml /var/lib/solr/solr.xml \ + && ln -s /opt/solr/bin/solr /usr/local/bin/solr -VOLUME ["/srv/solr/server/solr"] +VOLUME ["/var/lib/solr"] EXPOSE 8983 USER solr -CMD ["solr", "start", "-f"] +CMD ["solr", "start", "-f", "-s", "/var/lib/solr"] diff --git a/solr/lib/systemd/system/solr.service b/solr/lib/systemd/system/solr.service index fca917b..b51df55 100644 --- a/solr/lib/systemd/system/solr.service +++ b/solr/lib/systemd/system/solr.service @@ -4,7 +4,7 @@ After=network.target [Service] Type=simple -ExecStart=/usr/bin/docker run --rm --tmpfs /tmp --name solr -v /srv/solr/data:/srv/solr/server/solr solr +ExecStart=/usr/bin/docker run --rm --tmpfs /tmp --name solr -v /srv/solr/data:/var/lib/solr solr ExecStop=/usr/bin/docker stop solr [Install]