Skip to content

Commit

Permalink
Merge branch 'mickamy' into imp1
Browse files Browse the repository at this point in the history
  • Loading branch information
mickamy authored Jan 2, 2024
2 parents 7e78231 + 21941aa commit 79e8d82
Show file tree
Hide file tree
Showing 10 changed files with 98 additions and 55 deletions.
38 changes: 21 additions & 17 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,32 @@ concurrency:
jobs:
benchmark:
name: Run benchmark
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
language:
# - "crystal"
# - "go"
# - "nodejs"
# - "php"
# - "python"
# - "python_sanic"
# - "crystal"
# - "go"
# - "nodejs"
# - "php"
# - "python"
- "ruby"
env:
ISHOCON_APP_LANG: ${{ matrix.language }}
steps:
- uses: actions/checkout@v2
- run: echo 'Run benchmark for ISHOCON2'
- run: |
sed -i 's/python/'"$ISHOCON_APP_LANG"'/g' ./docker-compose.yml
cat ./docker-compose.yml
make build
env:
ISHOCON_APP_LANG: ${{ matrix.language }}
- run: make up && sleep 30
- run: make bench-with-db-init
- uses: actions/checkout@v4
- run: make change-lang LANG=$ISHOCON_APP_LANG
- uses: docker/setup-buildx-action@v3
- uses: docker/build-push-action@v5.1.0
with:
context: .
file: ./docker/app/${{ env.ISHOCON_APP_LANG }}/Dockerfile
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ${{ github.actor }}/ishocon2-app-${{ env.ISHOCON_APP_LANG }}:latest
- run: make build
timeout-minutes: 5
- run: make up bench-with-db-init
timeout-minutes: 10
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,6 @@ __pycache__/
.DS_Store
.python-version
.idea

# go
/webapp/go/webapp
18 changes: 12 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
common:
docker build -f docker/app/base/Dockerfile -t showwin/ishocon2_app_base:latest .
build-base:
docker build -f ./docker/app/base/Dockerfile -t showwin/ishocon2_app_base:latest .;

build: common
docker compose build --progress=plain
build:
docker compose -f ./docker-compose.yml build;

build-app:
docker build -f "./docker/app/$(LANG)/Dockerfile" -t ishocon2-app:latest .;

up:
docker compose up -d
docker compose up -d;

up-nod:
docker compose up;

down:
docker compose down
docker compose down;

bench:
docker exec -i ishocon2-bench-1 sh -c "./benchmark --ip app:443 --workload 6"
Expand Down
11 changes: 11 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,16 @@ services:
build:
context: .
dockerfile: ./docker/app/ruby/Dockerfile
image: ishocon2-app-ruby:latest
platform: linux/amd64
environment:
ISHOCON_APP_LANG: "${ISHOCON_APP_LANG-ruby}"
healthcheck:
test: ["CMD", "test", "-f", "/tmp/ishocon-app"]
interval: 10s
timeout: 3s
retries: 5
start_period: 10s
command: [/home/ishocon/run.sh]
tty: true
volumes:
Expand All @@ -25,6 +33,9 @@ services:
- app
environment:
- TARGET=app
depends_on:
app:
condition: service_healthy

volumes:
storage_bench:
Expand Down
6 changes: 2 additions & 4 deletions docker/app/crystal/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ ENV APP_LANG 'Crystal'

# Crystal のインストール
RUN sudo apt-get update
RUN sudo apt-get install -y gnupg2
RUN curl -sL "https://keybase.io/crystal/pgp_keys.asc" | sudo apt-key add -
RUN echo "deb https://dist.crystal-lang.org/apt crystal main" | sudo tee /etc/apt/sources.list.d/crystal.list
RUN sudo apt install -y libssl1.0-dev crystal
RUN sudo apt install -y libssl1.0-dev gnupg2
RUN curl -fsSL https://crystal-lang.org/install.sh | sudo bash

# アプリケーション
RUN mkdir /home/ishocon/data /home/ishocon/webapp
Expand Down
1 change: 1 addition & 0 deletions docker/app/go/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ FROM showwin/ishocon2_app_base:latest
ENV APP_LANG 'Go'

# Go のインストール
RUN sudo apt-get update
RUN sudo wget -q https://dl.google.com/go/go1.15.8.linux-amd64.tar.gz && \
sudo tar -C /usr/local -xzf go1.15.8.linux-amd64.tar.gz && \
sudo rm go1.15.8.linux-amd64.tar.gz
Expand Down
1 change: 1 addition & 0 deletions docker/app/nodejs/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ FROM showwin/ishocon2_app_base:latest
ENV APP_LANG 'Node.js'

# NodeJS のインストール
RUN sudo apt-get update
RUN sudo apt install -y nodejs-dev node-gyp libssl1.0-dev
RUN sudo apt install -y nodejs npm

Expand Down
1 change: 1 addition & 0 deletions docker/app/php/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ ENV APP_LANG 'PHP'

# PHP のインストール
RUN sudo mkdir /run/php
RUN sudo apt-get update
RUN sudo apt install -y php php-fpm php-mysql php-cli

# アプリケーション
Expand Down
52 changes: 33 additions & 19 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,41 +17,55 @@ echo "app_lang: $app_lang"
function run_ruby() {
rbenv global 3.1.4
unicorn -c unicorn_config.rb
echo "$check_message"
echo "app_lang: $app_lang"

function make_tmp_file() {
touch /tmp/ishocon-app
}

function run_python() {
/home/ishocon/.pyenv/shims/uwsgi --ini app.ini
function run_ruby() {
rbenv global 3.1.4
unicorn -c unicorn_config.rb
echo "$check_message"
}

function run_python_sanic() {
function run_python() {
cd "/home/ishocon/webapp/$app_lang"
make_tmp_file
/home/ishocon/.pyenv/shims/uwsgi --ini app.ini
echo "$check_message"
}


function run_go() {
go get -t -d -v ./...
go build -o webapp *.go
./webapp
echo "$check_message"
cd "/home/ishocon/webapp/$app_lang"
# put output file into /tmp/go for it cannot be created in webapp somehow because of permission denied
mkdir -p /tmp/go
go build -o /tmp/go/webapp *.go
make_tmp_file
/tmp/go/webapp
}

function run_php() {
cd "/home/ishocon/webapp/$app_lang"
sudo mv -f /etc/nginx/nginx.conf /etc/nginx/nginx.conf.orig
sudo cp /home/ishocon/webapp/php/php-nginx.conf /etc/nginx/nginx.conf
sudo service nginx reload
echo "$check_message"
sudo service nginx reload
make_tmp_file
tail -f /dev/null
}

function run_crystal() {
shards install
crystal app.cr
echo "$check_message"
function run_nodejs() {
cd "/home/ishocon/webapp/$app_lang"
sudo npm install
make_tmp_file
sudo node index.js
}

echo "run $app_lang app..."
cd "/home/ishocon/webapp/$app_lang"
function run_crystal() {
cd "/home/ishocon/webapp/$app_lang"
sudo shards install
make_tmp_file
sudo crystal app.cr
}

"run_$app_lang"
echo "starting running $app_lang app..."
"run_${app_lang}"
22 changes: 13 additions & 9 deletions webapp/crystal/shard.lock
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
version: 2.0
shards:
backtracer:
git: https://github.com/sija/backtracer.cr.git
version: 1.2.2

db:
git: https://github.com/crystal-lang/crystal-db.git
version: 0.5.0
version: 0.13.1

exception_page:
git: https://github.com/crystal-loot/exception_page.git
version: 0.3.1

kemal:
git: https://github.com/kemalcr/kemal.git
version: 0.23.0
version: 1.4.0

kemal-session:
git: https://github.com/kemalcr/kemal-session.git
version: 0.10.0

kilt:
git: https://github.com/jeromegn/kilt.git
version: 0.4.0
version: 1.0.0

mysql:
git: https://github.com/crystal-lang/crystal-mysql.git
version: 0.5.0
version: 0.16.0

radix:
git: https://github.com/luislavena/radix.git
version: 0.3.8
version: 0.4.1

0 comments on commit 79e8d82

Please sign in to comment.