Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
daalvand committed Jul 27, 2023
1 parent 8dbb02a commit 8600e95
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 34 deletions.
32 changes: 2 additions & 30 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,33 +24,5 @@ jobs:

- name: Build and Push Docker images
run: |
DIR=$GITHUB_WORKSPACE
SERVICE_DIR="${DIR}/services"
DOCKER_BUILDKIT=1
docker buildx build -f "$DIR/Dockerfile" "$DIR" -t daalvand/speed-test-base:latest &&
docker buildx build -f "$SERVICE_DIR/pure-php/Dockerfile" "$SERVICE_DIR/pure-php" -t daalvand/speed-test-pure-php:latest &&
docker buildx build -f "$SERVICE_DIR/react-php/Dockerfile" "$SERVICE_DIR/react-php" -t daalvand/speed-test-react-php:latest &&
docker buildx build -f "$SERVICE_DIR/swoole-php/Dockerfile" "$SERVICE_DIR/swoole-php" -t daalvand/speed-test-swoole-php:latest &&
docker buildx build -f "$SERVICE_DIR/yii/Dockerfile" "$SERVICE_DIR/yii" -t daalvand/speed-test-yii:latest &&
docker buildx build -f "$SERVICE_DIR/codeigniter/Dockerfile" "$SERVICE_DIR/codeigniter" -t daalvand/speed-test-codeigniter:latest &&
docker buildx build -f "$SERVICE_DIR/laravel/FPMDockerfile" "$SERVICE_DIR/laravel" -t daalvand/speed-test-laravel:latest &&
docker buildx build -f "$SERVICE_DIR/laravel/SwooleDockerfile" "$SERVICE_DIR/laravel" -t daalvand/speed-test-laravel-octane:latest &&
docker buildx build -f "$SERVICE_DIR/go/Dockerfile" "$SERVICE_DIR/go" -t daalvand/speed-test-go:latest &&
docker buildx build -f "$SERVICE_DIR/fastapi/Dockerfile" "$SERVICE_DIR/fastapi" -t daalvand/speed-test-fastapi:latest &&
docker buildx build -f "$SERVICE_DIR/flask/Dockerfile" "$SERVICE_DIR/flask" -t daalvand/speed-test-flask:latest &&
docker buildx build -f "$SERVICE_DIR/nodejs/Dockerfile" "$SERVICE_DIR/nodejs" -t daalvand/speed-test-nodejs:latest &&
docker push daalvand/speed-test-base:latest &&
docker push daalvand/speed-test-pure-php:latest &&
docker push daalvand/speed-test-react-php:latest &&
docker push daalvand/speed-test-swoole-php:latest &&
docker push daalvand/speed-test-yii:latest &&
docker push daalvand/speed-test-codeigniter:latest &&
docker push daalvand/speed-test-laravel:latest &&
docker push daalvand/speed-test-laravel-octane:latest &&
docker push daalvand/speed-test-go:latest &&
docker push daalvand/speed-test-fastapi:latest &&
docker push daalvand/speed-test-flask:latest &&
docker push daalvand/speed-test-nodejs:latest
echo 'DONE!'
$GITHUB_WORKSPACE/scripts/images_buildx.sh &&
$GITHUB_WORKSPACE/scripts/images_push.sh
4 changes: 2 additions & 2 deletions build.sh → scripts/images_build.sh
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

DIR="$(dirname "$(readlink -f "$0")")"
DIR="$(dirname "$(dirname "$(readlink -f "$0")")")"
SERVICE_DIR="${DIR}/services"
DOCKER_BUILDKIT=1

Expand All @@ -16,4 +16,4 @@ docker build -f "$SERVICE_DIR/go/Dockerfile" "$SERVICE_DIR/go" -t daalvand/speed
docker build -f "$SERVICE_DIR/fastapi/Dockerfile" "$SERVICE_DIR/fastapi" -t daalvand/speed-test-fastapi:latest &&
docker build -f "$SERVICE_DIR/flask/Dockerfile" "$SERVICE_DIR/flask" -t daalvand/speed-test-flask:latest &&
docker build -f "$SERVICE_DIR/nodejs/Dockerfile" "$SERVICE_DIR/nodejs" -t daalvand/speed-test-nodejs:latest &&
echo 'DONE!'
echo 'BUILD DONE!'
19 changes: 19 additions & 0 deletions scripts/images_buildx.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

DIR="$(dirname "$(dirname "$(readlink -f "$0")")")"
SERVICE_DIR="${DIR}/services"
DOCKER_BUILDKIT=1

docker buildx build -f "$DIR/Dockerfile" "$DIR" -t daalvand/speed-test-base:latest &&
docker buildx build -f "$SERVICE_DIR/pure-php/Dockerfile" "$SERVICE_DIR/pure-php" -t daalvand/speed-test-pure-php:latest &&
docker buildx build -f "$SERVICE_DIR/react-php/Dockerfile" "$SERVICE_DIR/react-php" -t daalvand/speed-test-react-php:latest &&
docker buildx build -f "$SERVICE_DIR/swoole-php/Dockerfile" "$SERVICE_DIR/swoole-php" -t daalvand/speed-test-swoole-php:latest &&
docker buildx build -f "$SERVICE_DIR/yii/Dockerfile" "$SERVICE_DIR/yii" -t daalvand/speed-test-yii:latest &&
docker buildx build -f "$SERVICE_DIR/codeigniter/Dockerfile" "$SERVICE_DIR/codeigniter" -t daalvand/speed-test-codeigniter:latest &&
docker buildx build -f "$SERVICE_DIR/laravel/FPMDockerfile" "$SERVICE_DIR/laravel" -t daalvand/speed-test-laravel:latest &&
docker buildx build -f "$SERVICE_DIR/laravel/SwooleDockerfile" "$SERVICE_DIR/laravel" -t daalvand/speed-test-laravel-octane:latest &&
docker buildx build -f "$SERVICE_DIR/go/Dockerfile" "$SERVICE_DIR/go" -t daalvand/speed-test-go:latest &&
docker buildx build -f "$SERVICE_DIR/fastapi/Dockerfile" "$SERVICE_DIR/fastapi" -t daalvand/speed-test-fastapi:latest &&
docker buildx build -f "$SERVICE_DIR/flask/Dockerfile" "$SERVICE_DIR/flask" -t daalvand/speed-test-flask:latest &&
docker buildx build -f "$SERVICE_DIR/nodejs/Dockerfile" "$SERVICE_DIR/nodejs" -t daalvand/speed-test-nodejs:latest &&
echo 'BUILD DONE!'
2 changes: 1 addition & 1 deletion push.sh → scripts/images_push.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ docker push daalvand/speed-test-go:latest &&
docker push daalvand/speed-test-fastapi:latest &&
docker push daalvand/speed-test-flask:latest &&
docker push daalvand/speed-test-nodejs:latest &&
echo 'DONE!'
echo 'PUSH DONE!'
0 plt.sh → scripts/plt.sh
100755 → 100644
File renamed without changes.
6 changes: 5 additions & 1 deletion test-ab.sh → scripts/test-ab.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ TYPE="${1:-ab}"
TIME_LIMIT="${2:-10}"
CONCURRENCY="${3:-100}"

DIR="$(dirname "$(dirname "$(readlink -f "$0")")")"

cd $DIR

docker-compose down --remove-orphans

# Build
Expand All @@ -31,7 +35,7 @@ mkdir -p export/ab
for service in "${services[@]}"; do
echo "AB Test For: ${service}..."
file=${service}-hw-c-${CONCURRENCY}-t${TIME_LIMIT}s.txt
docker-compose run --rm ab -k -c $CONCURRENCY -t $TIME_LIMIT -n 1000000 "http://${service}/hello-world" >"export/ab/${file}"
docker-compose run --rm ab -k -c $CONCURRENCY -t $TIME_LIMIT -n 1000000 "http://${service}/hello-world" > "export/ab/${file}"
done

docker-compose down --remove-orphans
Expand Down
4 changes: 4 additions & 0 deletions test-hey.sh → scripts/test-hey.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
CONCURRENCY="${1:-100}"
TOTAL_COUNT="${2:-10000}"

DIR="$(dirname "$(dirname "$(readlink -f "$0")")")"

cd $DIR

docker-compose down --remove-orphans

# Build
Expand Down
4 changes: 4 additions & 0 deletions test-wrk.sh → scripts/test-wrk.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
TIME_LIMIT="${2:-10}"
CONCURRENCY="${3:-100}"

DIR="$(dirname "$(dirname "$(readlink -f "$0")")")"

cd $DIR

docker-compose down --remove-orphans

# Build
Expand Down

0 comments on commit 8600e95

Please sign in to comment.