Skip to content

Commit b335883

Browse files
committed
Preserve bash history across container rebuilds
Switch remote user to ubuntu (with sudo password ubuntu) since it already exists in the base Ubuntu docker image.
1 parent 9b226f7 commit b335883

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

.devcontainer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@
3333
]
3434
}
3535
},
36-
"remoteUser": "infinitime"
36+
"remoteUser": "ubuntu"
3737
}

docker/Dockerfile

+10-2
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,16 @@ RUN bash -c "source /opt/build.sh; GetNrfSdk;"
6565
# McuBoot
6666
RUN bash -c "source /opt/build.sh; GetMcuBoot;"
6767

68-
# Add the infinitime user with sudo password "it" for developing in devcontainer
69-
RUN adduser infinitime && echo "infinitime:it" | chpasswd && usermod -aG sudo infinitime
68+
ARG USERNAME=ubuntu
69+
70+
# Setup the ubuntu user with sudo password "ubuntu" for developing in devcontainer
71+
RUN echo "$USERNAME:ubuntu" | chpasswd && usermod -aG sudo $USERNAME
72+
73+
RUN SNIPPET="export PROMPT_COMMAND='history -a' && export HISTFILE=/commandhistory/.bash_history" \
74+
&& mkdir /commandhistory \
75+
&& touch /commandhistory/.bash_history \
76+
&& chown -R $USERNAME /commandhistory \
77+
&& echo "$SNIPPET" >> "/home/$USERNAME/.bashrc"
7078

7179
# Configure Git to accept the /sources directory as safe
7280
RUN git config --global --add safe.directory /sources

0 commit comments

Comments
 (0)