Created
September 26, 2021 02:05
-
-
Save ManfredLange/aa5ac571ae0a4dc1eece29fa1d8ff2d5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM mcr.microsoft.com/dotnet/sdk:5.0.401 | |
# For other base images, check https://hub.docker.com/_/microsoft-dotnet-sdk/ | |
RUN apt-get update && \ | |
apt-get upgrade -y && \ | |
apt-get install -y procps iputils-ping net-tools | |
# procps: to support command 'ps' | |
# iputils-ping: to support command 'ping' (https://linuxconfig.org/ping-command-not-found-on-ubuntu-20-04-focal-fossa-linux) [Manfred, 19sep2021] | |
# net-tools: to support command such as 'arp', 'ifconfig', 'netstat', etc. (https://helpmanual.io/packages/apt/net-tools/) [Manfred, 26sep2021] | |
# Create non-root user | |
RUN groupadd -g 1000 -r dev && \ | |
useradd -u 1000 -r -g dev -m -s $(which bash) dev | |
# Option '-m' to create home directory (see https://askubuntu.com/a/393470) | |
# Option '-s' to set shell for this user (see comment in https://askubuntu.com/a/393470) | |
# Option '-r' creates a system user which does not expire (see https://linuxize.com/post/how-to-create-users-in-linux-using-the-useradd-command/) | |
# Create working directory. Ownership will be changed in entrypoint.sh which | |
# executes *after* the volume has been mounted. | |
RUN mkdir /src | |
# Copy entrypoint script into container, make it executable, then execute it: | |
COPY entrypoint.sh /entrypoint.sh | |
RUN chmod +x /entrypoint.sh | |
# Option '+x' adds executable flag to the file | |
ENTRYPOINT ["/entrypoint.sh"] | |
# Install dotnet-outdated (see https://github.com/dotnet-outdated/dotnet-outdated) | |
RUN runuser -l dev -c "dotnet tool install --global dotnet-outdated-tool" | |
# runuser installs it as if the non-root user was installing it. This makes it available to that non-root user | |
ENV PATH "$PATH:/home/dev/.dotnet/tools" | |
# If the previous doesn't work, consider https://stackoverflow.com/a/59293118/411428 [Manfred, 13nov2020] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment