Skip to content

Commit

Permalink
Merge pull request #3 from grafana/2-support-the-alpine-base-image
Browse files Browse the repository at this point in the history
Added alpine image support
  • Loading branch information
szkiba authored Feb 13, 2025
2 parents af6a160 + 7b8d408 commit cc01cce
Show file tree
Hide file tree
Showing 13 changed files with 43 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/k6/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "A modern load testing tool, using Go and JavaScript",
"id": "k6",
"version": "1.0.0",
"version": "1.0.1",
"description": "**k6** is a modern load-testing tool, built on our years of experience in the performance and testing industries. It's built to be powerful, extensible, and full-featured. The key design goal is to provide **the best developer experience**.",
"documentationURL": "https://github.com/grafana/k6",
"options": {
Expand Down
14 changes: 6 additions & 8 deletions src/k6/gh-release-installer-patched.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@

set -e

if ! which curl > /dev/null; then
if grep -q "alpine" /etc/os-release; then
apk add --no-cache curl
else
if ! which wget > /dev/null; then
if grep -vq "alpine" /etc/os-release; then
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y -q curl ca-certificates
DEBIAN_FRONTEND=noninteractive apt-get install -y -q wget ca-certificates
fi
fi

get_version() {
if [ -z "$VERSION" ] || [ "$VERSION" = "latest" ]; then
url=$(curl "https://github.com/${OWNER}/${NAME}/releases/latest" -s -L -I -o /dev/null -w '%{url_effective}')
url=$(wget -q -O - --spider -S "https://github.com/${OWNER}/${NAME}/releases/latest" 2>&1 | grep Location)
echo -n "${url##*v}"
else
echo -n "$VERSION"
Expand Down Expand Up @@ -47,5 +45,5 @@ PLATFORM="$(get_platform)"

echo "Activating feature '${NAME}' version $VERSION on platform $PLATFORM"

curl -sL "https://github.com/${OWNER}/${NAME}/releases/download/v${VERSION}/${NAME}-v${VERSION}-${PLATFORM}.tar.gz" | \
tar -xzf - -C /usr/local/bin --strip-components=1 --wildcards "${NAME}*/${NAME}"
wget -qO - "https://github.com/${OWNER}/${NAME}/releases/download/v${VERSION}/${NAME}-v${VERSION}-${PLATFORM}.tar.gz" | \
tar x -zf - -C /usr/local/bin --strip-components 1 "${NAME}-v${VERSION}-${PLATFORM}/k6"
2 changes: 1 addition & 1 deletion src/xk6/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Build k6 with extensions",
"id": "xk6",
"version": "1.0.0",
"version": "1.0.1",
"description": "This command line tool and associated Go package makes it easy to make custom builds of [k6](https://github.com/grafana/k6). It is used heavily by k6 extension developers as well as anyone who wishes to make custom `k6` binaries (with or without extensions).",
"documentationURL": "https://github.com/grafana/xk6",
"options": {
Expand Down
13 changes: 6 additions & 7 deletions src/xk6/gh-release-installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@

set -e

if ! which curl > /dev/null; then
if grep -q "alpine" /etc/os-release; then
apk add --no-cache curl
else
if ! which wget > /dev/null; then
if grep -vq "alpine" /etc/os-release; then
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y -q curl ca-certificates
DEBIAN_FRONTEND=noninteractive apt-get install -y -q wget ca-certificates
fi
fi

get_version() {
if [ -z "$VERSION" ] || [ "$VERSION" = "latest" ]; then
url=$(curl "https://github.com/${OWNER}/${NAME}/releases/latest" -s -L -I -o /dev/null -w '%{url_effective}')
url=$(wget -q -O - --spider -S "https://github.com/${OWNER}/${NAME}/releases/latest" 2>&1 | grep Location)
echo -n "${url##*v}"
else
echo -n "$VERSION"
Expand Down Expand Up @@ -47,4 +45,5 @@ PLATFORM="$(get_platform)"

echo "Activating feature '${NAME}' version $VERSION on platform $PLATFORM"

curl -sL "https://github.com/${OWNER}/${NAME}/releases/download/v${VERSION}/${NAME}_${VERSION}_${PLATFORM}.tar.gz" | tar -xzf - -C /usr/local/bin ${NAME}
wget -qO - "https://github.com/${OWNER}/${NAME}/releases/download/v${VERSION}/${NAME}_${VERSION}_${PLATFORM}.tar.gz" | \
tar x -zf - -C /usr/local/bin ${NAME}
3 changes: 3 additions & 0 deletions test/_global/alpine.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

. ./all.sh $@
3 changes: 3 additions & 0 deletions test/_global/debian.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

. ./all.sh $@
16 changes: 15 additions & 1 deletion test/_global/scenarios.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
{
"all": {
"ubuntu": {
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"xk6": {},
"k6": {}
}
},
"debian": {
"image": "mcr.microsoft.com/devcontainers/base:debian",
"features": {
"xk6": {},
"k6": {}
}
},
"alpine": {
"image": "mcr.microsoft.com/devcontainers/base:alpine",
"features": {
"xk6": {},
"k6": {}
}
}
}
3 changes: 3 additions & 0 deletions test/_global/ubuntu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

. ./all.sh $@
File renamed without changes.
2 changes: 1 addition & 1 deletion test/k6/scenarios.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"k6": {
"k6-with-version": {
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"k6": {
Expand Down
5 changes: 3 additions & 2 deletions test/k6/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ set -e
source dev-container-features-test-lib

# Feature-specific tests
url=$(curl "https://github.com/grafana/k6/releases/latest" -s -L -I -o /dev/null -w '%{url_effective}')
latest="${url##*v}"
url=$(wget -q -O - --spider -S "https://github.com/grafana/k6/releases/latest" 2>&1 | grep Location)
echo -n "${url##*v}"

check "execute command" bash -c "k6 --version | grep '$latest'"

# Report results
Expand Down
2 changes: 1 addition & 1 deletion test/xk6/scenarios.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"xk6": {
"xk6-with-version": {
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"xk6": {
Expand Down
File renamed without changes.

0 comments on commit cc01cce

Please sign in to comment.