Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

devcontainer: Fix kubectl path #1441

Merged
merged 9 commits into from
Jan 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ FROM docker.io/rust:1.56.1-bullseye

ENV DEBIAN_FRONTEND=noninteractive
RUN apt update && apt upgrade -y
RUN apt install -y \
RUN apt install -y --no-install-recommends \
clang \
cmake \
golang \
jq \
lldb \
lsb-release \
sudo \
Expand All @@ -30,17 +31,17 @@ ENV HOME=/home/$USER
RUN mkdir -p $HOME/bin
ENV PATH=$HOME/bin:$PATH

RUN curl --proto '=https' --tlsv1.3 -vsSfLo $HOME/kubectl "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" \
&& chmod 755 $HOME/kubectl
ARG KUBECTL_VERSION=v1.23.2
RUN curl --proto '=https' --tlsv1.3 -vsSfLo $HOME/bin/kubectl "https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl" \
&& chmod 755 $HOME/bin/kubectl
RUN curl --proto '=https' --tlsv1.3 -vsSfL https://raw.githubusercontent.com/rancher/k3d/main/install.sh \
| USE_SUDO=false K3D_INSTALL_DIR=$HOME/bin bash

RUN rustup component add clippy rustfmt
RUN mkdir /tmp/cargo-deny && cd /tmp/cargo-deny && \
curl --proto '=https' --tlsv1.3 -vsSfL https://github.com/EmbarkStudios/cargo-deny/releases/download/0.11.0/cargo-deny-0.11.0-x86_64-unknown-linux-musl.tar.gz \
| tar zxf - \
&& mv cargo-deny-0.11.0-x86_64-unknown-linux-musl/cargo-deny $HOME/bin \
&& cd .. && rm -rf /tmp/cargo-deny

ARG CARGO_DENY_VERSION=0.11.0
RUN curl --proto '=https' --tlsv1.3 -vsSfL "https://github.com/EmbarkStudios/cargo-deny/releases/download/${CARGO_DENY_VERSION}/cargo-deny-${CARGO_DENY_VERSION}-x86_64-unknown-linux-musl.tar.gz" \
| tar zvxf - --strip-components=1 -C $HOME/bin "cargo-deny-${CARGO_DENY_VERSION}-x86_64-unknown-linux-musl/cargo-deny"

RUN curl --proto '=https' --tlsv1.3 -vsSfL https://run.linkerd.io/install-edge | sh \
&& ln -s $(readlink ~/.linkerd2/bin/linkerd) ~/bin/linkerd
Expand Down
4 changes: 2 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "linkerd2-proxy",
"image": "ghcr.io/linkerd/dev-proxy:v3",
//"dockerFile": "./Dockerfile",
"image": "ghcr.io/linkerd/dev-proxy:v5",
// "dockerFile": "./Dockerfile",
"extensions": [
"DavidAnson.vscode-markdownlint",
"matklad.rust-analyzer",
Expand Down
51 changes: 51 additions & 0 deletions .github/workflows/devcontainer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: devcontainer

# When a pull request is opened that changes the Devcontainer configuration,
# ensure that the container continues to build properly.
on:
pull_request:
paths:
- rust-toolchain
- .devcontainer/**

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
- run: docker build .devcontainer

rust-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
- run: |
versions=$(sed -nE 's|^FROM (.*/)?rust:([^ -]+)|\2|p' .devcontainer/Dockerfile)
ex=0
for mismatch in $(echo "$versions" | grep -vF "$(cat rust-toolchain)" || true) ; do
echo "::error file=.devcontainer/Dockerfile::Devcontainer uses incorrect rust version(s): $mismatch"
ex=$((ex + 1))
done
exit $ex

devcontainer-image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
- run: |
export DEBIAN_FRONTEND=noninteractive
sudo apt-get update
sudo apt-get -y --no-install-recommends install jq
- run: |
image=$(sed -E '/^\s*\/\/.*/d' .devcontainer/devcontainer.json |jq -Mr .image)
if [ "$image" == "null" ]; then
echo "::error file=.devcontainer/devcontainer.json::Missing image"
exit 1
fi
if ! docker pull "$image" ; then
echo "::error file=.devcontainer/devcontainer.json::Unable to pull image: $image"
exit 1
fi