Adjust docker build to use current user ID (#977)

This commit is contained in:
Nate McMaster 2018-03-20 16:17:59 -07:00 committed by GitHub
parent fde11611f8
commit 5aa5f92345
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 4 deletions

View File

@ -1,5 +1,11 @@
FROM microsoft/dotnet:2.1-runtime-deps-alpine
ARG USER
ARG USER_ID
ARG GROUP_ID
WORKDIR /code/build
RUN mkdir -p "/home/$USER" && chown "${USER_ID}:${GROUP_ID}" "/home/$USER"
ENV HOME "/home/$USER"
RUN apk add --no-cache \
bash \
@ -10,6 +16,8 @@ RUN apk add --no-cache \
icu-libs \
openssl
USER $USER_ID:$GROUP_ID
# Disable the invariant mode (set in base image)
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT false
ENV LC_ALL en_US.UTF-8
@ -26,6 +34,5 @@ COPY global.json /tmp/global.json
RUN DOTNET_SDK_VERSION="$(jq -r '.sdk.version' /tmp/global.json)" \
&& echo "Installing SDK ${DOTNET_SDK_VERSION}" \
&& wget -q --tries 10 -O /tmp/dotnet.tar.gz https://dotnetcli.blob.core.windows.net/dotnet/Sdk/$DOTNET_SDK_VERSION/dotnet-sdk-$DOTNET_SDK_VERSION-alpine.3.6-x64.tar.gz \
&& mkdir -p /usr/share/dotnet \
&& tar xzf /tmp/dotnet.tar.gz -C /usr/share/dotnet \
&& ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet
&& mkdir -p "$HOME/.dotnet" \
&& tar xzf /tmp/dotnet.tar.gz -C "$HOME/.dotnet"

View File

@ -97,7 +97,12 @@ tagname="universe-build-$image"
cp "$DIR/global.json" "$(dirname "$dockerfile")"
#endworkaround
docker build "$(dirname "$dockerfile")" -f "$dockerfile" --tag $tagname
docker build "$(dirname "$dockerfile")" \
--build-arg "USER=$(whoami)" \
--build-arg "USER_ID=$(id -u)" \
--build-arg "GROUP_ID=$(id -g)" \
--tag $tagname \
-f "$dockerfile"
docker run \
--rm \