File tree Expand file tree Collapse file tree 5 files changed +30
-10
lines changed Expand file tree Collapse file tree 5 files changed +30
-10
lines changed Original file line number Diff line number Diff line change 1
1
ARG RUBY_TEST_VERSION=2.7
2
2
FROM ruby:${RUBY_TEST_VERSION}
3
3
4
+ # Default UID/GID to 1000
5
+ # it can be overridden at build time
6
+ ARG BUILDER_UID=1000
7
+ ARG BUILDER_GID=1000
8
+ ENV BUILDER_USER elastic
9
+ ENV BUILDER_GROUP elastic
10
+
4
11
ENV GEM_HOME="/usr/local/bundle"
5
- ENV PATH $GEM_HOME/bin:$GEM_HOME/gems/bin:$PATH
12
+ ENV PATH= " $GEM_HOME/bin:$GEM_HOME/gems/bin:$PATH"
6
13
ENV QUIET=true
7
14
ENV CI=true
8
15
16
+ # Install required tools
17
+ RUN apt-get -q update \
18
+ && apt-get -y install zip \
19
+ && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
20
+
21
+ # Create user
22
+ RUN groupadd --system -g ${BUILDER_GID} ${BUILDER_GROUP} \
23
+ && useradd --system --shell /bin/bash -u ${BUILDER_UID} -g ${BUILDER_GROUP} -d /var/lib/elastic -m elastic 1>/dev/null 2>/dev/null \
24
+ && mkdir -p /usr/src/app && touch /Gemfile.lock \
25
+ && chown -R ${BUILDER_USER}:${BUILDER_GROUP} /usr/src/app /Gemfile.lock
26
+
27
+ COPY --chown=$BUILDER_USER:$BUILDER_GROUP . .
28
+
9
29
WORKDIR /usr/src/app
10
30
11
- COPY . .
31
+ USER ${BUILDER_USER}:${BUILDER_GROUP}
12
32
13
- RUN apt-get update
14
- RUN apt-get install zip
15
- RUN bundle install --quiet
16
- RUN bundle exec rake bundle:clean
17
- RUN rake bundle:install
33
+ RUN bundle install \
34
+ && bundle exec rake bundle:clean \
35
+ && rake bundle:install
Original file line number Diff line number Diff line change @@ -116,7 +116,7 @@ echo -e "\033[1m>>>>> Build [elastic/elasticsearch-ruby container] >>>>>>>>>>>>>
116
116
# ------------------------------------------------------- #
117
117
118
118
echo -e " \033[34;1mINFO: building $product container\033[0m"
119
- docker build --file .ci/Dockerfile --tag ${product} .
119
+ docker build --build-arg BUILDER_UID= " $( id -u ) " -- file .ci/Dockerfile --tag ${product} .
120
120
121
121
# ------------------------------------------------------- #
122
122
# Run the Container
@@ -131,6 +131,7 @@ args_string="${TASK_ARGS[*]}"
131
131
args_string=" ${args_string// / ,} "
132
132
133
133
docker run \
134
+ -u " $( id -u) " \
134
135
--env " RUBY_TEST_VERSION=${RUBY_TEST_VERSION} " \
135
136
--env " WORKFLOW=${WORKFLOW} " \
136
137
--name test-runner \
Original file line number Diff line number Diff line change 115
115
echo -e " \033[34;1mINFO:\033[0m Starting container $node_name \033[0m"
116
116
set -x
117
117
docker run \
118
+ -u " $( id -u) " \
118
119
--name " $node_name " \
119
120
--network " $network_name " \
120
121
--env " ES_JAVA_OPTS=-Xms1g -Xmx1g -da:org.elasticsearch.xpack.ccr.index.engine.FollowingEngineAssertions" \
Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ repo=`pwd`
43
43
# run the client tests
44
44
if [[ $TEST_SUITE != " platinum" ]]; then
45
45
docker run \
46
+ -u " $( id -u) " \
46
47
--network=" ${network_name} " \
47
48
--env " TEST_ES_SERVER=${elasticsearch_url} " \
48
49
--env " TEST_SUITE=${TEST_SUITE} " \
@@ -53,6 +54,7 @@ if [[ $TEST_SUITE != "platinum" ]]; then
53
54
bundle exec rake elasticsearch:download_artifacts test:rest_api
54
55
else
55
56
docker run \
57
+ -u " $( id -u) " \
56
58
--network=" ${network_name} " \
57
59
--env " TEST_ES_SERVER=${elasticsearch_url} " \
58
60
--env " ELASTIC_PASSWORD=${elastic_password} " \
Original file line number Diff line number Diff line change @@ -33,8 +33,6 @@ namespace :unified_release do
33
33
34
34
build_gems ( args [ :output_dir ] )
35
35
create_zip_file ( args [ :output_dir ] )
36
- sh "chmod 666 #{ CURRENT_PATH . join ( args [ :output_dir ] ) } /* && " \
37
- "chmod 666 #{ CURRENT_PATH . join ( args [ :output_dir ] ) } "
38
36
end
39
37
40
38
def build_gems ( output_dir )
You can’t perform that action at this time.
0 commit comments