dev: optimize image build (#2452)

- `on-create` uses much time to download and install without cache, any changes about devcontainer will make it run again. If we put those into Dockerfile, we will have cache and speed up this process.
- Add proxy settings for development behind a proxy server

Signed-off-by: Loong <loong.dai@intel.com>
Signed-off-by: Loong <loong.dai@intel.com>
Co-authored-by: Oliver Gould <ver@buoyant.io>
This commit is contained in:
Loong Dai 2023-11-14 07:43:19 +08:00 committed by GitHub
parent e62cc28ffe
commit 048542ae77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 41 additions and 13 deletions

7
.devcontainer/Dockerfile Normal file
View File

@ -0,0 +1,7 @@
ARG DEV_VERSION
FROM ghcr.io/linkerd/dev:${DEV_VERSION}
RUN rustup toolchain install --profile=minimal nightly && \
cargo +nightly install cargo-fuzz
RUN scurl https://run.linkerd.io/install-edge | sh && \
mkdir -p "$HOME/bin" && ln -s "$HOME/.linkerd2/bin/linkerd" "$HOME/bin/linkerd"

View File

@ -1,6 +1,13 @@
{
"name": "linkerd2-proxy",
"image": "ghcr.io/linkerd/dev:v42",
"build": {
"dockerfile": "Dockerfile",
"args": {
"DEV_VERSION": "v42",
"http_proxy": "${localEnv:http_proxy}",
"https_proxy": "${localEnv:https_proxy}"
}
},
"customizations": {
"vscode": {
"extensions": [
@ -15,7 +22,6 @@
"settings": {}
}
},
"onCreateCommand": ".devcontainer/on-create.sh",
// Support docker + debugger
"runArgs": [
"--init",

View File

@ -1,10 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
rustup toolchain install --profile=minimal nightly
cargo +nightly install cargo-fuzz
scurl https://run.linkerd.io/install-edge | sh
mkdir -p "$HOME/bin"
(cd "$HOME/bin" && ln -s "$HOME/.linkerd2/bin/linkerd" .)

View File

@ -196,7 +196,32 @@ action-lint:
@just-dev lint-actions
action-dev-check:
@just-dev check-action-images
#!/usr/bin/env bash
# TODO(ver) consolidate this again with just-dev
#@just-dev check-action-images
set -euo pipefail
VERSION=$(j5j .devcontainer/devcontainer.json |jq -r '.build.args["DEV_VERSION"]')
EX=0
while IFS= read filelineimg ; do
# Parse lines in the form `file:line img:tag`
fileline="${filelineimg%% *}"
file="${fileline%%:*}"
line="${fileline##*:}"
img="${filelineimg##* }"
name="${img%%:*}"
# Tag may be in the form of `version[-variant]`
tag="${img##*:}"
version="${tag%%-*}"
if [ "$name" = 'ghcr.io/linkerd/dev' ] && [ "$version" != "$VERSION" ]; then
if [ "${GITHUB_ACTIONS:-}" = "true" ]; then
echo "::error file=${file},line=${line}::Expected image 'ghcr.io/linkerd/dev:$VERSION'; found '${img}'" >&2
else
echo "${file}:${line}: Expected image 'ghcr.io/linkerd/dev:$VERSION'; found '${img}'" >&2
fi
EX=$(( EX+1 ))
fi
done < <( /usr/local/bin/action-images )
exit $EX
##
## Linkerd