first usable devcontainer

This commit is contained in:
usrbinkat 2025-01-29 22:58:59 +00:00
parent 2c42efe1db
commit d7f363bcaf

View File

@ -1,4 +1,9 @@
# TODO:
# - add gitpod cli https://gitpod.io/static/bin/gitpod-cli-linux-amd64
FROM docker.io/library/rust:1.84.0-bullseye
ENV BIN=/usr/local/bin
SHELL ["/bin/bash", "-c"]
# Create a non-root user with same UID/GID as host user
ARG USERNAME=vscode
@ -6,12 +11,18 @@ ARG USER_UID=1000
ARG USER_GID=$USER_UID
# Install basic tools
RUN apt-get update && apt-get install -y \
sudo \
curl \
git \
build-essential \
&& rm -rf /var/lib/apt/lists/*
ARG APT_LIST="\
jq \
git \
sudo \
curl \
gitlab-cli \
build-essential \
"
RUN set -ex \
&& apt-get update \
&& apt-get install -y ${APT_LIST} \
&& echo
# Create the user
RUN groupadd --gid $USER_GID $USERNAME \
@ -19,6 +30,53 @@ RUN groupadd --gid $USER_GID $USERNAME \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME
# Install GitHub `gh` cli from github.com/cli/cli
RUN set -ex \
&& export NAME=gh \
&& export TEST="${NAME} version" \
&& export REPOSITORY="cli/cli" \
&& export VERSION="$(curl -Lks https://api.github.com/repos/${REPOSITORY}/releases/latest | jq --raw-output .tag_name)" \
&& export ARCH=$(uname -m | awk '{ if ($1 == "x86_64") print "amd64"; else if ($1 == "aarch64" || $1 == "arm64") print "arm64"; else print "unknown" }') \
&& export PKG="${NAME}_${VERSION:1}_linux_${ARCH}.tar.gz" \
&& export URL="https://github.com/${REPOSITORY}/releases/download/${VERSION}/${PKG}" \
&& echo "---------------------------------------------------------"\
&& echo "INFO[${NAME}] Installed:" \
&& echo "INFO[${NAME}] Command: ${NAME}" \
&& echo "INFO[${NAME}] Package: ${PKG}" \
&& echo "INFO[${NAME}] Latest Release: ${VERSION}" \
&& echo "INFO[${NAME}] Architecture: ${ARCH}" \
&& echo "INFO[${NAME}] Source: ${URL}" \
&& echo "---------------------------------------------------------"\
&& curl -Lks ${URL} | tar xzvf - --directory /tmp \
&& sudo install -m 755 /tmp/${NAME}_${VERSION:1}_linux_${ARCH}/bin/${NAME} ${BIN}/${NAME} \
&& rm -rf /tmp/${NAME}_${VERSION:1}_linux_${ARCH} \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean \
&& ${TEST} \
&& echo
# Install Gitpod CLI from gitpod.io
RUN set -ex \
&& export NAME=gp \
&& export TEST="${NAME} version" \
&& export VERSION="$(curl -s https://gitpod.io/static/bin/manifest.json | jq --raw-output .version)" \
&& export ARCH=$(uname -m | awk '{ if ($1 == "x86_64") print "amd64"; else if ($1 == "aarch64" || $1 == "arm64") print "arm64"; else print "unknown" }') \
&& export PKG="gitpod-cli-linux-${ARCH}" \
&& export URL="https://gitpod.io/static/bin/${PKG}" \
&& echo "---------------------------------------------------------" \
&& echo "INFO[${NAME}] Installed:" \
&& echo "INFO[${NAME}] Command: ${NAME}" \
&& echo "INFO[${NAME}] Binary: ${PKG}" \
&& echo "INFO[${NAME}] Version: ${VERSION}" \
&& echo "INFO[${NAME}] Architecture: ${ARCH}" \
&& echo "INFO[${NAME}] Source: ${URL}" \
&& echo "---------------------------------------------------------" \
&& curl -fSL ${URL} -o /tmp/${PKG} \
&& chmod +x /tmp/${PKG} \
&& sudo mv /tmp/${PKG} /usr/local/bin/${NAME} \
&& ${TEST} \
&& echo
# Set working directory
WORKDIR /workspaces/veilid