Skip to content

Commit

Permalink
[RORDEV-1095] docker images improvements (#982)
Browse files Browse the repository at this point in the history
  • Loading branch information
coutoPL authored Feb 3, 2024
1 parent 1c0d57c commit 25f8dd8
Show file tree
Hide file tree
Showing 62 changed files with 368 additions and 88 deletions.
1 change: 0 additions & 1 deletion docker-image/init-readonlyrest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ readonlyrest:

- name: "ADMIN"
type: allow
verbosity: error
auth_key: admin:${env:ADMIN_USER_PASS}
22 changes: 22 additions & 0 deletions docker-image/ror-entrypoint-es6x.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash -e

INVOKE_ROR_TOOLS="$JAVA_HOME/bin/java -jar /usr/share/elasticsearch/plugins/readonlyrest/ror-tools.jar"

if $INVOKE_ROR_TOOLS verify | grep -q "Elasticsearch is NOT patched"; then

if [ -n "$I_UNDERSTAND_IMPLICATION_OF_ES_PATCHING" ] && [[ "${I_UNDERSTAND_IMPLICATION_OF_ES_PATCHING,,}" == *"yes"* ]]; then
$INVOKE_ROR_TOOLS patch
else
echo "Elasticsearch needs to be patched to work with ReadonlyREST. You can read about patching in our documentation:" \
"https://docs.readonlyrest.com/elasticsearch#id-3.-patch-elasticsearch. In this Docker image, the patching step" \
"is done automatically, but you must agree to have it done for you. You can do this by setting" \
"I_UNDERSTAND_IMPLICATION_OF_ES_PATCHING=yes environment variable when running the container."
exit 1
fi

else
echo "Elasticsearch is already patched. We can continue ..."
fi


gosu elasticsearch /usr/local/bin/docker-entrypoint.sh "$@"
21 changes: 21 additions & 0 deletions docker-image/ror-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash -e

INVOKE_ROR_TOOLS="/usr/share/elasticsearch/jdk/bin/java -jar /usr/share/elasticsearch/plugins/readonlyrest/ror-tools.jar"

if $INVOKE_ROR_TOOLS verify | grep -q "Elasticsearch is NOT patched"; then

if [ -n "$I_UNDERSTAND_IMPLICATION_OF_ES_PATCHING" ] && [[ "${I_UNDERSTAND_IMPLICATION_OF_ES_PATCHING,,}" == *"yes"* ]]; then
$INVOKE_ROR_TOOLS patch
else
echo "Elasticsearch needs to be patched to work with ReadonlyREST. You can read about patching in our documentation:" \
"https://docs.readonlyrest.com/elasticsearch#id-3.-patch-elasticsearch. In this Docker image, the patching step" \
"is done automatically, but you must agree to have it done for you. You can do this by setting" \
"I_UNDERSTAND_IMPLICATION_OF_ES_PATCHING=yes environment variable when running the container."
exit 1
fi

else
echo "Elasticsearch is already patched. We can continue ..."
fi

gosu elasticsearch /usr/local/bin/docker-entrypoint.sh "$@"
2 changes: 1 addition & 1 deletion es60x/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ tasks.register('prepareDockerImageFiles', Copy) {

from layout.projectDirectory.file("Dockerfile")
from layout.buildDirectory.file("distributions/" + pluginFullName + ".zip")
from rootProject.file("docker-image/init-readonlyrest.yml")
from rootProject.files("docker-image")

into layout.buildDirectory.dir("docker-image")
}
Expand Down
2 changes: 1 addition & 1 deletion es61x/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ tasks.register('prepareDockerImageFiles', Copy) {

from layout.projectDirectory.file("Dockerfile")
from layout.buildDirectory.file("distributions/" + pluginFullName + ".zip")
from rootProject.file("docker-image/init-readonlyrest.yml")
from rootProject.files("docker-image")

into layout.buildDirectory.dir("docker-image")
}
Expand Down
2 changes: 1 addition & 1 deletion es62x/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ tasks.register('prepareDockerImageFiles', Copy) {

from layout.projectDirectory.file("Dockerfile")
from layout.buildDirectory.file("distributions/" + pluginFullName + ".zip")
from rootProject.file("docker-image/init-readonlyrest.yml")
from rootProject.files("docker-image")

into layout.buildDirectory.dir("docker-image")
}
Expand Down
12 changes: 10 additions & 2 deletions es63x/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,20 @@ ARG ROR_VERSION
ENV KIBANA_USER_PASS=kibana
ENV ADMIN_USER_PASS=admin

USER root

RUN curl -o /usr/local/bin/gosu -SL "https://github.com/tianon/gosu/releases/download/1.17/gosu-amd64" && \
chmod +x /usr/local/bin/gosu && \
gosu nobody true

USER elasticsearch

COPY readonlyrest-${ROR_VERSION}_es${ES_VERSION}.zip /tmp/readonlyrest.zip
COPY init-readonlyrest.yml /usr/share/elasticsearch/config/readonlyrest.yml
COPY ror-entrypoint-es6x.sh /usr/local/bin/ror-entrypoint.sh

RUN /usr/share/elasticsearch/bin/elasticsearch-plugin install --batch file:///tmp/readonlyrest.zip

USER root
RUN $JAVA_HOME/bin/java -jar /usr/share/elasticsearch/plugins/readonlyrest/ror-tools.jar patch

USER 1000:0
ENTRYPOINT ["/usr/local/bin/ror-entrypoint.sh"]
2 changes: 1 addition & 1 deletion es63x/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ tasks.register('prepareDockerImageFiles', Copy) {

from layout.projectDirectory.file("Dockerfile")
from layout.buildDirectory.file("distributions/" + pluginFullName + ".zip")
from rootProject.file("docker-image/init-readonlyrest.yml")
from rootProject.files("docker-image")

into layout.buildDirectory.dir("docker-image")
}
Expand Down
12 changes: 10 additions & 2 deletions es65x/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,20 @@ ARG ROR_VERSION
ENV KIBANA_USER_PASS=kibana
ENV ADMIN_USER_PASS=admin

USER root

RUN curl -o /usr/local/bin/gosu -SL "https://github.com/tianon/gosu/releases/download/1.17/gosu-amd64" && \
chmod +x /usr/local/bin/gosu && \
gosu nobody true

USER elasticsearch

COPY readonlyrest-${ROR_VERSION}_es${ES_VERSION}.zip /tmp/readonlyrest.zip
COPY init-readonlyrest.yml /usr/share/elasticsearch/config/readonlyrest.yml
COPY ror-entrypoint-es6x.sh /usr/local/bin/ror-entrypoint.sh

RUN /usr/share/elasticsearch/bin/elasticsearch-plugin install --batch file:///tmp/readonlyrest.zip

USER root
RUN $JAVA_HOME/bin/java -jar /usr/share/elasticsearch/plugins/readonlyrest/ror-tools.jar patch

USER 1000:0
ENTRYPOINT ["/usr/local/bin/ror-entrypoint.sh"]
2 changes: 1 addition & 1 deletion es65x/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ tasks.register('prepareDockerImageFiles', Copy) {

from layout.projectDirectory.file("Dockerfile")
from layout.buildDirectory.file("distributions/" + pluginFullName + ".zip")
from rootProject.file("docker-image/init-readonlyrest.yml")
from rootProject.files("docker-image")

into layout.buildDirectory.dir("docker-image")
}
Expand Down
12 changes: 10 additions & 2 deletions es66x/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,20 @@ ARG ROR_VERSION
ENV KIBANA_USER_PASS=kibana
ENV ADMIN_USER_PASS=admin

USER root

RUN curl -o /usr/local/bin/gosu -SL "https://github.com/tianon/gosu/releases/download/1.17/gosu-amd64" && \
chmod +x /usr/local/bin/gosu && \
gosu nobody true

USER elasticsearch

COPY readonlyrest-${ROR_VERSION}_es${ES_VERSION}.zip /tmp/readonlyrest.zip
COPY init-readonlyrest.yml /usr/share/elasticsearch/config/readonlyrest.yml
COPY ror-entrypoint-es6x.sh /usr/local/bin/ror-entrypoint.sh

RUN /usr/share/elasticsearch/bin/elasticsearch-plugin install --batch file:///tmp/readonlyrest.zip

USER root
RUN $JAVA_HOME/bin/java -jar /usr/share/elasticsearch/plugins/readonlyrest/ror-tools.jar patch

USER 1000:0
ENTRYPOINT ["/usr/local/bin/ror-entrypoint.sh"]
2 changes: 1 addition & 1 deletion es66x/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ tasks.register('prepareDockerImageFiles', Copy) {

from layout.projectDirectory.file("Dockerfile")
from layout.buildDirectory.file("distributions/" + pluginFullName + ".zip")
from rootProject.file("docker-image/init-readonlyrest.yml")
from rootProject.files("docker-image")

into layout.buildDirectory.dir("docker-image")
}
Expand Down
12 changes: 10 additions & 2 deletions es67x/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,20 @@ ARG ROR_VERSION
ENV KIBANA_USER_PASS=kibana
ENV ADMIN_USER_PASS=admin

USER root

RUN curl -o /usr/local/bin/gosu -SL "https://github.com/tianon/gosu/releases/download/1.17/gosu-amd64" && \
chmod +x /usr/local/bin/gosu && \
gosu nobody true

USER elasticsearch

COPY readonlyrest-${ROR_VERSION}_es${ES_VERSION}.zip /tmp/readonlyrest.zip
COPY init-readonlyrest.yml /usr/share/elasticsearch/config/readonlyrest.yml
COPY ror-entrypoint-es6x.sh /usr/local/bin/ror-entrypoint.sh

RUN /usr/share/elasticsearch/bin/elasticsearch-plugin install --batch file:///tmp/readonlyrest.zip

USER root
RUN $JAVA_HOME/bin/java -jar /usr/share/elasticsearch/plugins/readonlyrest/ror-tools.jar patch

USER 1000:0
ENTRYPOINT ["/usr/local/bin/ror-entrypoint.sh"]
2 changes: 1 addition & 1 deletion es67x/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ tasks.register('prepareDockerImageFiles', Copy) {

from layout.projectDirectory.file("Dockerfile")
from layout.buildDirectory.file("distributions/" + pluginFullName + ".zip")
from rootProject.file("docker-image/init-readonlyrest.yml")
from rootProject.files("docker-image")

into layout.buildDirectory.dir("docker-image")
}
Expand Down
12 changes: 10 additions & 2 deletions es70x/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,20 @@ ARG ROR_VERSION
ENV KIBANA_USER_PASS=kibana
ENV ADMIN_USER_PASS=admin

USER root

RUN curl -o /usr/local/bin/gosu -SL "https://github.com/tianon/gosu/releases/download/1.17/gosu-amd64" && \
chmod +x /usr/local/bin/gosu && \
gosu nobody true

USER elasticsearch

COPY readonlyrest-${ROR_VERSION}_es${ES_VERSION}.zip /tmp/readonlyrest.zip
COPY init-readonlyrest.yml /usr/share/elasticsearch/config/readonlyrest.yml
COPY ror-entrypoint.sh /usr/local/bin/ror-entrypoint.sh

RUN /usr/share/elasticsearch/bin/elasticsearch-plugin install --batch file:///tmp/readonlyrest.zip

USER root
RUN /usr/share/elasticsearch/jdk/bin/java -jar /usr/share/elasticsearch/plugins/readonlyrest/ror-tools.jar patch

USER 1000:0
ENTRYPOINT ["/usr/local/bin/ror-entrypoint.sh"]
2 changes: 1 addition & 1 deletion es70x/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ tasks.register('prepareDockerImageFiles', Copy) {

from layout.projectDirectory.file("Dockerfile")
from layout.buildDirectory.file("distributions/" + pluginFullName + ".zip")
from rootProject.file("docker-image/init-readonlyrest.yml")
from rootProject.files("docker-image")

into layout.buildDirectory.dir("docker-image")
}
Expand Down
12 changes: 10 additions & 2 deletions es710x/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,20 @@ ARG ROR_VERSION
ENV KIBANA_USER_PASS=kibana
ENV ADMIN_USER_PASS=admin

USER root

RUN curl -o /usr/local/bin/gosu -SL "https://github.com/tianon/gosu/releases/download/1.17/gosu-amd64" && \
chmod +x /usr/local/bin/gosu && \
gosu nobody true

USER elasticsearch

COPY readonlyrest-${ROR_VERSION}_es${ES_VERSION}.zip /tmp/readonlyrest.zip
COPY init-readonlyrest.yml /usr/share/elasticsearch/config/readonlyrest.yml
COPY ror-entrypoint.sh /usr/local/bin/ror-entrypoint.sh

RUN /usr/share/elasticsearch/bin/elasticsearch-plugin install --batch file:///tmp/readonlyrest.zip

USER root
RUN /usr/share/elasticsearch/jdk/bin/java -jar /usr/share/elasticsearch/plugins/readonlyrest/ror-tools.jar patch

USER 1000:0
ENTRYPOINT ["/tini", "--", "/usr/local/bin/ror-entrypoint.sh"]
2 changes: 1 addition & 1 deletion es710x/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ tasks.register('prepareDockerImageFiles', Copy) {

from layout.projectDirectory.file("Dockerfile")
from layout.buildDirectory.file("distributions/" + pluginFullName + ".zip")
from rootProject.file("docker-image/init-readonlyrest.yml")
from rootProject.files("docker-image")

into layout.buildDirectory.dir("docker-image")
}
Expand Down
12 changes: 10 additions & 2 deletions es711x/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,20 @@ ARG ROR_VERSION
ENV KIBANA_USER_PASS=kibana
ENV ADMIN_USER_PASS=admin

USER root

RUN curl -o /usr/local/bin/gosu -SL "https://github.com/tianon/gosu/releases/download/1.17/gosu-amd64" && \
chmod +x /usr/local/bin/gosu && \
gosu nobody true

USER elasticsearch

COPY readonlyrest-${ROR_VERSION}_es${ES_VERSION}.zip /tmp/readonlyrest.zip
COPY init-readonlyrest.yml /usr/share/elasticsearch/config/readonlyrest.yml
COPY ror-entrypoint.sh /usr/local/bin/ror-entrypoint.sh

RUN /usr/share/elasticsearch/bin/elasticsearch-plugin install --batch file:///tmp/readonlyrest.zip

USER root
RUN /usr/share/elasticsearch/jdk/bin/java -jar /usr/share/elasticsearch/plugins/readonlyrest/ror-tools.jar patch

USER 1000:0
ENTRYPOINT ["/bin/tini", "--", "/usr/local/bin/ror-entrypoint.sh"]
2 changes: 1 addition & 1 deletion es711x/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ tasks.register('prepareDockerImageFiles', Copy) {

from layout.projectDirectory.file("Dockerfile")
from layout.buildDirectory.file("distributions/" + pluginFullName + ".zip")
from rootProject.file("docker-image/init-readonlyrest.yml")
from rootProject.files("docker-image")

into layout.buildDirectory.dir("docker-image")
}
Expand Down
12 changes: 10 additions & 2 deletions es714x/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,20 @@ ARG ROR_VERSION
ENV KIBANA_USER_PASS=kibana
ENV ADMIN_USER_PASS=admin

USER root

RUN curl -o /usr/local/bin/gosu -SL "https://github.com/tianon/gosu/releases/download/1.17/gosu-amd64" && \
chmod +x /usr/local/bin/gosu && \
gosu nobody true

USER elasticsearch

COPY readonlyrest-${ROR_VERSION}_es${ES_VERSION}.zip /tmp/readonlyrest.zip
COPY init-readonlyrest.yml /usr/share/elasticsearch/config/readonlyrest.yml
COPY ror-entrypoint.sh /usr/local/bin/ror-entrypoint.sh

RUN /usr/share/elasticsearch/bin/elasticsearch-plugin install --batch file:///tmp/readonlyrest.zip

USER root
RUN /usr/share/elasticsearch/jdk/bin/java -jar /usr/share/elasticsearch/plugins/readonlyrest/ror-tools.jar patch

USER 1000:0
ENTRYPOINT ["/bin/tini", "--", "/usr/local/bin/ror-entrypoint.sh"]
2 changes: 1 addition & 1 deletion es714x/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ tasks.register('prepareDockerImageFiles', Copy) {

from layout.projectDirectory.file("Dockerfile")
from layout.buildDirectory.file("distributions/" + pluginFullName + ".zip")
from rootProject.file("docker-image/init-readonlyrest.yml")
from rootProject.files("docker-image")

into layout.buildDirectory.dir("docker-image")
}
Expand Down
13 changes: 11 additions & 2 deletions es716x/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,21 @@ ARG ROR_VERSION
ENV KIBANA_USER_PASS=kibana
ENV ADMIN_USER_PASS=admin

USER root

RUN apt-get update && \
apt-get install -y --no-install-recommends gosu && \
rm -rf /var/lib/apt/lists/* && \
gosu nobody true

USER elasticsearch

COPY readonlyrest-${ROR_VERSION}_es${ES_VERSION}.zip /tmp/readonlyrest.zip
COPY init-readonlyrest.yml /usr/share/elasticsearch/config/readonlyrest.yml
COPY ror-entrypoint.sh /usr/local/bin/ror-entrypoint.sh

RUN /usr/share/elasticsearch/bin/elasticsearch-plugin install --batch file:///tmp/readonlyrest.zip

USER root
RUN /usr/share/elasticsearch/jdk/bin/java -jar /usr/share/elasticsearch/plugins/readonlyrest/ror-tools.jar patch

USER 1000:0
ENTRYPOINT ["/bin/tini", "--", "/usr/local/bin/ror-entrypoint.sh"]
2 changes: 1 addition & 1 deletion es716x/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ tasks.register('prepareDockerImageFiles', Copy) {

from layout.projectDirectory.file("Dockerfile")
from layout.buildDirectory.file("distributions/" + pluginFullName + ".zip")
from rootProject.file("docker-image/init-readonlyrest.yml")
from rootProject.files("docker-image")

into layout.buildDirectory.dir("docker-image")
}
Expand Down
Loading

0 comments on commit 25f8dd8

Please sign in to comment.