Skip to content

Commit 39ddad2

Browse files
committed
feat: install gh with apt
Installing the github CLI with apt is more maintainable than downloading the binary with the bonus that the gh man pages are installed.
1 parent cc7232f commit 39ddad2

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

Dockerfile

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,31 @@ FROM mcr.microsoft.com/devcontainers/python:${PYTHON_VERSION}
55
LABEL org.opencontainers.image.authors="Ryan Boehning <1250684+ryboe@users.noreply.github.com>"
66

77
RUN <<-EOT
8+
mkdir -p --mode=755 /etc/apt/keyrings
9+
wget --no-verbose --output-document=/etc/apt/keyrings/githubcli-archive-keyring.gpg https://cli.github.com/packages/githubcli-archive-keyring.gpg
10+
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" > /etc/apt/sources.list.d/github-cli.list
811
apt update
912
apt full-upgrade
13+
apt install gh --yes
1014
apt clean
1115
rm -rf /var/lib/apt/lists/*
1216
EOT
1317

14-
# Enable pipefail to catch errors.
15-
SHELL ["/bin/zsh", "-o", "pipefail", "-c"]
16-
1718
# Change the vscode user's default shell to zsh.
1819
RUN sed -i 's/\/home\/vscode:\/bin\/bash/\/home\/vscode:\/bin\/zsh/' /etc/passwd
1920
USER vscode
2021

2122
# Remove shell configs from the base image.
2223
RUN rm -rf ~/.bash_logout ~/.bashrc ~/.oh-my-zsh ~/.profile
2324

24-
# Create local bin directory for gh, poetry, and other command line tools.
25-
RUN mkdir -p /home/vscode/.local/bin
25+
# Enable pipefail to catch poetry install errors.
26+
SHELL ["/bin/zsh", "-o", "pipefail", "-c"]
2627

2728
# Install poetry and enable its completions.
2829
RUN <<-EOT
30+
mkdir -p /home/vscode/.local/bin
2931
curl -sSL https://install.python-poetry.org | python -
3032
mkdir -p ~/.zfunc
3133
poetry completions zsh > ~/.zfunc/_poetrywhic
3234
fpath+=~/.zfunc
3335
EOT
34-
35-
# Install the latest gh CLI tool. The first request fetches the URL for the
36-
# latest release tarball. The second request downloads the tarball.
37-
RUN <<-EOT
38-
wget --quiet --timeout=30 --output-document=- 'https://api.github.com/repos/cli/cli/releases/latest' |
39-
jq -r ".assets[] | select(.name | test(\"gh_.*?_linux_amd64.tar.gz\")).browser_download_url" |
40-
wget --quiet --timeout=180 --input-file=- --output-document=- |
41-
tar -xvz -C ~/.local/bin --strip-components=2
42-
EOT

0 commit comments

Comments
 (0)