Skip to content

Commit aa6b9cc

Browse files
committed
Update DockerFile so that ownership of new files does not default to root (#5459)
(cherry picked from commit 60f9460)
1 parent b0ac9f3 commit aa6b9cc

File tree

6 files changed

+26
-7
lines changed

6 files changed

+26
-7
lines changed

.ci/DockerFile

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
ARG DOTNET_VERSION=5.0.102
22
FROM mcr.microsoft.com/dotnet/sdk:${DOTNET_VERSION}-1 AS elasticsearch-net-build
33

4-
WORKDIR /sln
4+
ARG USER_ID
5+
ARG GROUP_ID
6+
7+
RUN echo addgroup --gid $GROUP_ID user
8+
RUN addgroup --gid $GROUP_ID user
9+
RUN adduser --disabled-password --gecos '' --uid $USER_ID --gid $GROUP_ID user
510

11+
WORKDIR /sln
12+
RUN chown $GROUP_ID:$USER_ID $(pwd)
613
COPY ./*.sln ./nuget.config ./*.Build.props ./*.Build.targets ./
714

815
COPY ./dotnet-tools.json ./
@@ -24,11 +31,19 @@ RUN for file in $(find . -name "*.?sproj"); do mkdir -p $(dirname $file)/$(basen
2431
COPY build/scripts/scripts.fsproj ./build/scripts/
2532
COPY .ci/Jenkins.csproj ./.ci/
2633

34+
RUN chown -R $GROUP_ID:$USER_ID $(pwd)
35+
RUN chown -R $GROUP_ID:$USER_ID $(pwd)
36+
RUN chown -R $GROUP_ID:$USER_ID /tmp/NuGetScratch
37+
USER user
38+
2739
# Install app dependencies
2840
RUN dotnet restore
2941

3042
# copy relevant files (see .dockerignore)
3143
COPY . .
3244

3345
# making sure enough git info is available inside the container
34-
RUN git rev-parse HEAD .
46+
RUN git rev-parse HEAD .
47+
48+
49+

.ci/make.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ echo -e "\033[34;1mINFO:\033[0m DOTNET_VERSION ${DOTNET_VERSION}\033[0m"
2727

2828
echo -e "\033[1m>>>>> Build [elastic/elasticsearch-net container] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>\033[0m"
2929

30-
docker build --file .ci/DockerFile --tag elastic/elasticsearch-net .
30+
docker build --file .ci/DockerFile --tag elastic/elasticsearch-net \
31+
--build-arg USER_ID="$(id -u)" \
32+
--build-arg GROUP_ID="$(id -g)" .
3133

3234
echo -e "\033[1m>>>>> Run [elastic/elasticsearch-net container] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>\033[0m"
3335

.ci/run-repository.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ echo -e "\033[34;1mINFO:\033[0m DOTNET_VERSION ${DOTNET_VERSION}\033[0m"
3636

3737
echo -e "\033[1m>>>>> Build [elastic/elasticsearch-net container] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>\033[0m"
3838

39-
docker build --file .ci/DockerFile --tag elastic/elasticsearch-net .
39+
docker build --file .ci/DockerFile --tag elastic/elasticsearch-net \
40+
--build-arg USER_ID=$(id -u) \
41+
--build-arg GROUP_ID=$(id -g) .
4042

4143
echo -e "\033[1m>>>>> Run [elastic/elasticsearch-net container] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>\033[0m"
4244

.github/workflows/make-codegen.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
name: "code-gen ${{ matrix.branch }}"
3434
- name: "PR ${{ matrix.branch }}"
3535
# fixate to known release.
36-
uses: peter-evans/create-pull-request@5ea31358e901bfaf28ca19849903d802fd0a891b
36+
uses: peter-evans/create-pull-request@052fc72b4198ba9fbc81b818c6e1859f747d49a8
3737
with:
3838
token: ${{ secrets.GITHUB_TOKEN }}
3939
branch: "fix/${{ matrix.branch }}/code-gen"

src/ApiGenerator/Configuration/GeneratorLocations.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ public static class GeneratorLocations
1111
{
1212
// @formatter:off — disable formatter after this line
1313
public static string EsNetFolder { get; } = $@"{Root}../../src/Elasticsearch.Net/";
14-
public static string LastDownloadedRef { get; } = Path.Combine(Root, "last_downloaded_version.txt");
14+
15+
public static string LastDownloadedRef { get; } = Path.Combine(Path.GetTempPath(), "last_downloaded_version.txt");
1516

1617
public static string NestFolder { get; } = $@"{Root}../../src/Nest/";
1718
public static string RestSpecificationFolder { get; } = $@"{Root}RestSpecification/";

src/ApiGenerator/last_downloaded_version.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)