FROM alpine:3.7
MAINTAINER Disassembler <disassembler@dasm.cz>


RUN \
 # Install Java 1.8 JRE 
 apk --no-cache add openjdk8-jre-base paxctl \
 # Fix grsec attributes to loosen memory protection restrictions
 && paxctl -cm /usr/lib/jvm/java-1.8-openjdk/jre/bin/java \
 && paxctl -cm /usr/lib/jvm/java-1.8-openjdk/bin/java \
 # Cleanup
 && apk del paxctl

RUN \
 # Install runtime dependencies
 apk --no-cache add bash lsof \
 # Download and install Solr
 && wget http://archive.apache.org/dist/lucene/solr/6.5.1/solr-6.5.1.tgz -O /tmp/solr-6.5.1.tgz \
 && 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 \
 # Create OS user
 && addgroup -S -g 8983 solr \
 && adduser -S -u 8983 -h /var/lib/solr -s /bin/false -g solr -G solr solr \
 && chown -R solr:solr /opt/solr/ \
 # Copy basic configuration file to data location
 && cp -p /opt/solr/server/solr/solr.xml /var/lib/solr/solr.xml \
 # Make start/stop script visible globally
 && ln -s /opt/solr/bin/solr /usr/local/bin/solr

VOLUME ["/var/lib/solr"]
EXPOSE 8983

USER solr
CMD ["solr", "start", "-f"]
