Created
March 4, 2024 17:49
-
-
Save bskinner/331a30b01449c8ccd2873799a6b9d1e0 to your computer and use it in GitHub Desktop.
VSCode dev env containerfile
This file contains 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 node:20-bullseye | |
ARG GITHUB_ID | |
EXPOSE 22 | |
WORKDIR /workspace | |
# Add Microsoft's VSCode repository to apt's sources | |
RUN apt-get update && apt-get install -y \ | |
wget \ | |
gpg \ | |
apt-transport-https | |
RUN wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor -o packages.microsoft.gpg && \ | |
install -D -o root -g root -m 644 packages.microsoft.gpg /etc/apt/keyrings/packages.microsoft.gpg && \ | |
sh -c 'echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" > /etc/apt/sources.list.d/vscode.list' && \ | |
rm -f packages.microsoft.gpg | |
# Install the VSCode repository | |
RUN apt-get update && apt-get install -y \ | |
git \ | |
openssh-server \ | |
ssh-import-id \ | |
code | |
# SSH Setup | |
# Make sure the .ssh dir exists, has the correct permissions, | |
# and preload the current github ssh public keys | |
RUN mkdir -p -m 0600 ~/.ssh && \ | |
ssh-keyscan github.com >> ~/.ssh/known_hosts | |
RUN mkdir /var/run/sshd | |
# Enable root login, but | |
RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin prohibit-password/' /etc/ssh/sshd_config | |
RUN sed -i 's/UsePam yes/#UsePam no/' /etc/ssh/sshd_config | |
RUN ssh-import-id "gh:${GITHUB_ID}" | |
RUN corepack enable | |
RUN code --no-sandbox --user-data-dir ~/.vscode --install-extension eamodio.gitlens | |
CMD service ssh start && \ | |
code tunnel |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment