Skip to content

Commit

Permalink
[TASK] Make it possible to change solr unix GID:UID on docker image b…
Browse files Browse the repository at this point in the history
…uild

This change makes it possible to change solr unix GID:UID on docker image build time.
It is required for dev. environments and custom setups of EXT:solr docker containers.
  • Loading branch information
dkd-kaehm committed Jun 9, 2023
1 parent 18c49ab commit a71fe94
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Docker/SolrServer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,16 @@ FROM solr:9.2
MAINTAINER dkd Internet Service GmbH <solr-eb-support@dkd.de>
ENV TERM linux

ARG SOLR_UNIX_UID="8983"
ARG SOLR_UNIX_GID="8983"

USER root
RUN rm -fR /opt/solr/server/solr/*
RUN rm -fR /opt/solr/server/solr/* \
&& usermod --non-unique --uid "${SOLR_UNIX_UID}" solr \
&& groupmod --non-unique --gid "${SOLR_UNIX_GID}" solr \
&& chown -R solr:solr /var/solr /opt/solr \
&& apt update && apt upgrade -y && apt install sudo -y \
&& echo "solr ALL=NOPASSWD: /docker-entrypoint-initdb.d/as-sudo/*" > /etc/sudoers.d/solr
COPY Docker/SolrServer/docker-entrypoint-initdb.d/ /docker-entrypoint-initdb.d
USER solr

Expand Down
12 changes: 12 additions & 0 deletions Docker/SolrServer/docker-entrypoint-initdb.d/as-sudo-tweaks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

set -e

# execute files in /docker-entrypoint-initdb.d/as-sudo/*.sh before starting solr
while read -r f; do
case "$f" in
*.sh) echo "$0: running 'sudo $f'"; sudo "$f" ;;
*) echo "$0: ignoring $f" ;;
esac
echo
done < <(find /docker-entrypoint-initdb.d/as-sudo/ -mindepth 1 -type f | sort -n)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

chown -R solr:solr /var/solr /opt/solr

0 comments on commit a71fe94

Please sign in to comment.