|
| 1 | +FROM openjdk:17.0.1-bullseye |
| 2 | +# To check for newer JDK versions, see https://openjdk.java.net/, then |
| 3 | +# https://hub.docker.com/_/openjdk. Last check on 16 jan 2022 [Manfred, 16jan2022] |
| 4 | + |
| 5 | +RUN apt-get update && \ |
| 6 | + apt-get upgrade -y && \ |
| 7 | + apt-get install -y \ |
| 8 | + procps \ |
| 9 | + iputils-ping \ |
| 10 | + net-tools \ |
| 11 | + lsb-release |
| 12 | +# procps: to support command 'ps' |
| 13 | +# iputils-ping: to support command 'ping' (https://linuxconfig.org/ping-command-not-found-on-ubuntu-20-04-focal-fossa-linux) [Manfred, 19sep2021] |
| 14 | +# net-tools: to support command such as 'arp', 'ifconfig', 'netstat', etc. (https://helpmanual.io/packages/apt/net-tools/) [Manfred, 26sep2021] |
| 15 | +# lsb-release: to support commmand 'lsb_release -a' [Manfred, 15jan2022] |
| 16 | +# You can safely remove the packages you don't want. [Manfred, 08oct2021] |
| 17 | + |
| 18 | +# Create non-root user (zero trust principle, least privileged principle) |
| 19 | +RUN groupadd -g 1000 -r dev && \ |
| 20 | + useradd -u 1000 -r -g dev -m -s $(which bash) dev |
| 21 | +# Option '-m' to create home directory (see https://askubuntu.com/a/393470) |
| 22 | +# Option '-s' to set shell for this user (see comment in https://askubuntu.com/a/393470) |
| 23 | +# 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/) |
| 24 | + |
| 25 | +# How to add sudo support for the non-root user is described at https://code.visualstudio.com/remote/advancedcontainers/add-nonroot-user#_creating-a-nonroot-user |
| 26 | +# However, standard practice is not to add sudo support for security reasons. VS Code will connect |
| 27 | +# to the running dev container as the user specified in file ".devcontainer/devcontainer.json" in |
| 28 | +# property "remoteUser". If you need to run commands as root to set up the dev container, use the |
| 29 | +# "RUN" directive in Dockerfile or add suitable code to the script ".devcontainer/entrypoint.sh". |
| 30 | +# [Manfred, 16jan2022] |
| 31 | + |
| 32 | +# Create working directory. Ownership will be changed in entrypoint.sh which |
| 33 | +# executes *after* the volume has been mounted. |
| 34 | +RUN mkdir /src |
| 35 | + |
| 36 | +# Copy entrypoint script into container, make it executable, then make it the entrypoint for the |
| 37 | +# container: |
| 38 | +COPY entrypoint.sh /entrypoint.sh |
| 39 | +RUN chmod +x /entrypoint.sh |
| 40 | +# Option '+x' adds executable flag to the file |
| 41 | +ENTRYPOINT ["/entrypoint.sh"] |
0 commit comments