Skip to content

Update DockerFile so that ownership of new files does not default to root #5459

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions .ci/DockerFile
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
ARG DOTNET_VERSION=5.0.103
FROM mcr.microsoft.com/dotnet/sdk:${DOTNET_VERSION} AS elasticsearch-net-build

WORKDIR /sln
ARG USER_ID
ARG GROUP_ID

RUN echo addgroup --gid $GROUP_ID user
RUN addgroup --gid $GROUP_ID user
RUN adduser --disabled-password --gecos '' --uid $USER_ID --gid $GROUP_ID user

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

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

RUN chown -R $GROUP_ID:$USER_ID $(pwd)
RUN chown -R $GROUP_ID:$USER_ID $(pwd)
RUN chown -R $GROUP_ID:$USER_ID /tmp/NuGetScratch
USER user

# Install app dependencies
RUN dotnet restore

# copy relevant files (see .dockerignore)
COPY . .

# making sure enough git info is available inside the container
RUN git rev-parse HEAD .
RUN git rev-parse HEAD .



4 changes: 3 additions & 1 deletion .ci/make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ echo -e "\033[34;1mINFO:\033[0m DOTNET_VERSION ${DOTNET_VERSION}\033[0m"

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

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

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

Expand Down
4 changes: 3 additions & 1 deletion .ci/run-repository.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ echo -e "\033[34;1mINFO:\033[0m DOTNET_VERSION ${DOTNET_VERSION}\033[0m"

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

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

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

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/make-codegen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
name: "code-gen ${{ matrix.branch }}"
- name: "PR ${{ matrix.branch }}"
# fixate to known release.
uses: peter-evans/create-pull-request@5ea31358e901bfaf28ca19849903d802fd0a891b
uses: peter-evans/create-pull-request@052fc72b4198ba9fbc81b818c6e1859f747d49a8
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: "fix/${{ matrix.branch }}/code-gen"
Expand Down
3 changes: 2 additions & 1 deletion src/ApiGenerator/Configuration/GeneratorLocations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ public static class GeneratorLocations
{
// @formatter:off — disable formatter after this line
public static string EsNetFolder { get; } = $@"{Root}../../src/Elasticsearch.Net/";
public static string LastDownloadedRef { get; } = Path.Combine(Root, "last_downloaded_version.txt");

public static string LastDownloadedRef { get; } = Path.Combine(Path.GetTempPath(), "last_downloaded_version.txt");

public static string NestFolder { get; } = $@"{Root}../../src/Nest/";
public static string RestSpecificationFolder { get; } = $@"{Root}RestSpecification/";
Expand Down
1 change: 0 additions & 1 deletion src/ApiGenerator/last_downloaded_version.txt

This file was deleted.