Skip to content

Commit

Permalink
dev: optimize image build (#2452)
Browse files Browse the repository at this point in the history
- `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 <[email protected]>
Signed-off-by: Loong <[email protected]>
Co-authored-by: Oliver Gould <[email protected]>
  • Loading branch information
daixiang0 and olix0r authored Nov 13, 2023
1 parent e62cc28 commit 048542a
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 13 deletions.
7 changes: 7 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"
10 changes: 8 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand All @@ -15,7 +22,6 @@
"settings": {}
}
},
"onCreateCommand": ".devcontainer/on-create.sh",
// Support docker + debugger
"runArgs": [
"--init",
Expand Down
10 changes: 0 additions & 10 deletions .devcontainer/on-create.sh

This file was deleted.

27 changes: 26 additions & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 048542a

Please sign in to comment.