@@ -8,30 +8,49 @@ ARG TARGETPLATFORM
88ENV TARGETPLATFORM=${TARGETPLATFORM}
99
1010# To fix "unsupported locale"
11- RUN apt-get update && \
12- apt-get install -y locales && \
13- echo 'en_GB.UTF-8 UTF-8' > /etc/locale.gen && \
14- echo 'en_US.UTF-8 UTF-8' >> /etc/locale.gen && \
15- locale-gen && \
16- dpkg-reconfigure --frontend=noninteractive locales
11+ RUN apt-get update \
12+ && apt-get install -y locales \
13+ && echo 'en_GB.UTF-8 UTF-8' > /etc/locale.gen \
14+ && echo 'en_US.UTF-8 UTF-8' >> /etc/locale.gen \
15+ && locale-gen \
16+ && dpkg-reconfigure --frontend=noninteractive locales
1717
1818ENV LANGUAGE=en_GB.UTF-8
1919ENV LANG=en_GB.UTF-8
2020ENV LC_ALL=en_GB.UTF-8
2121
22- # Install our python requirements, kubectl
22+ # Add a non-root user ("vscode") with sudo support
23+ # https://code.visualstudio.com/remote/advancedcontainers/add-nonroot-user
24+ # And attempt to persist command history
25+ # https://code.visualstudio.com/remote/advancedcontainers/persist-bash-history
26+ ARG USERNAME=vscode
27+ ARG USER_UID=1000
28+ ARG USER_GID=$USER_UID
29+ RUN groupadd --gid $USER_GID $USERNAME \
30+ && useradd --uid $USER_UID --gid $USER_GID --create-home $USERNAME --shell /bin/bash \
31+ && apt-get update \
32+ && apt-get install -y sudo \
33+ && echo $USERNAME ALL=\( root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
34+ && chmod 0440 /etc/sudoers.d/$USERNAME \
35+ && SNIPPET="export PROMPT_COMMAND='history -a' && export HISTFILE=/commandhistory/.bash_history" \
36+ && mkdir /commandhistory \
37+ && touch /commandhistory/.bash_history \
38+ && chown -R $USERNAME /commandhistory \
39+ && echo "$SNIPPET" >> "/home/$USERNAME/.bashrc"
40+
41+ # Install our python requirements, and kubectl
2342ARG KUBECTL_VERSION=1.31.11
2443COPY requirements.txt /tmp
25- RUN apt-get update && \
26- apt-get install -y --no-install-recommends \
44+ RUN apt-get update \
45+ && apt-get install -y --no-install-recommends \
2746 curl \
2847 git \
29- wget && \
30- pip install -r /tmp/requirements.txt && \
31- curl -LO https://dl.k8s.io/release/v${KUBECTL_VERSION}/bin/${TARGETPLATFORM}/kubectl && \
32- install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl && \
33- rm kubectl
34- # Popeye
48+ wget \
49+ && pip install -r /tmp/requirements.txt \
50+ && curl -LO https://dl.k8s.io/release/v${KUBECTL_VERSION}/bin/${TARGETPLATFORM}/kubectl \
51+ && install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl \
52+ && rm kubectl
53+ # Popeye (ARM or AMD)
3554ARG POPEYE_VERSION=0.22.1
3655RUN if [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
3756 wget https://github.com/derailed/popeye/releases/download/v${POPEYE_VERSION}/popeye_linux_arm64.tar.gz && \
@@ -41,6 +60,8 @@ RUN if [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
4160 tar -xf popeye_linux_amd64.tar.gz; \
4261 else \
4362 exit 112; \
44- fi && \
45- mv popeye /usr/local/bin && \
46- rm LICENSE README.md
63+ fi \
64+ && mv popeye /usr/local/bin \
65+ && rm LICENSE README.md
66+
67+ USER $USERNAME
0 commit comments