From 50a9b966aa8f158b3e64fc72c6923a787b3e03ab Mon Sep 17 00:00:00 2001 From: mickamy Date: Sun, 31 Dec 2023 13:59:56 +0900 Subject: [PATCH 01/26] ci: add github actions workflow to run benchmark --- .github/workflows/benchmark.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/benchmark.yml diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml new file mode 100644 index 00000000..b3a0567e --- /dev/null +++ b/.github/workflows/benchmark.yml @@ -0,0 +1,24 @@ +name: Benchmark + +on: + workflow_dispatch: + push: + +concurrency: + group: ${{ github.workflow }}-${{ github.sha }} + cancel-in-progress: true + +jobs: + benchmark: + name: Run benchmark + runs-on: ubuntu-22.04 + timeout-minutes: 60 + strategy: + fail-fast: false + steps: + - uses: actions/checkout@v2 + - run: docker compose build + - run: docker compose up -d + timeout-minutes: 5 + - run: docker exec -it ishocon2_bench_1 ./benchmark --ip app:443 + timeout-minutes: 5 From 154d82ed866219cf7491c6b5c7d0cc74af002bb1 Mon Sep 17 00:00:00 2001 From: mickamy Date: Sun, 31 Dec 2023 14:08:33 +0900 Subject: [PATCH 02/26] fix: use get-pip for python 3.6 --- docker/app/python/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/app/python/Dockerfile b/docker/app/python/Dockerfile index 0479d368..9a2ca349 100644 --- a/docker/app/python/Dockerfile +++ b/docker/app/python/Dockerfile @@ -7,7 +7,7 @@ RUN git clone https://github.com/pyenv/pyenv.git ~/.pyenv && \ PYENV_ROOT="$HOME/.pyenv" && PATH="$PYENV_ROOT/bin:$PATH" && \ eval "$(pyenv init -)" && \ pyenv install 3.6.5 && pyenv global 3.6.5 && \ - cd && curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && python get-pip.py && rm get-pip.py + cd && curl https://bootstrap.pypa.io/pip/3.6/get-pip.py -o get-pip.py && python get-pip.py && rm get-pip.py # アプリケーション RUN mkdir /home/ishocon/data /home/ishocon/webapp From c0635e4f88eb61b9f3d2729dfd6c4fd3d633192c Mon Sep 17 00:00:00 2001 From: mickamy Date: Sun, 31 Dec 2023 14:17:44 +0900 Subject: [PATCH 03/26] ci: waiting for docker compose to be up --- .github/workflows/benchmark.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index b3a0567e..62276de1 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -18,7 +18,7 @@ jobs: steps: - uses: actions/checkout@v2 - run: docker compose build - - run: docker compose up -d + - run: docker compose up -d && sleep 10 timeout-minutes: 5 - run: docker exec -it ishocon2_bench_1 ./benchmark --ip app:443 timeout-minutes: 5 From 42e49301d2e5f2ab47e740292d9e5dc97b7529af Mon Sep 17 00:00:00 2001 From: mickamy Date: Sun, 31 Dec 2023 14:33:23 +0900 Subject: [PATCH 04/26] make: add Makefile and build showwin/ishocon2_app_base everytime --- Makefile | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..d84ee86b --- /dev/null +++ b/Makefile @@ -0,0 +1,5 @@ +common: + docker build -f docker/app/base/Dockerfile -t showwin/ishocon2_app_base:latest . + +build: common + docker compose build From 0195fde258973664c57903226596c1b2078a530b Mon Sep 17 00:00:00 2001 From: mickamy Date: Sun, 31 Dec 2023 14:35:23 +0900 Subject: [PATCH 05/26] ci: make build on CI to build latest version of base image --- .github/workflows/benchmark.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 62276de1..f6a4c576 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -17,7 +17,7 @@ jobs: fail-fast: false steps: - uses: actions/checkout@v2 - - run: docker compose build + - run: make build - run: docker compose up -d && sleep 10 timeout-minutes: 5 - run: docker exec -it ishocon2_bench_1 ./benchmark --ip app:443 From 498b9eb90219895a593b2fd07109de0e9609cab7 Mon Sep 17 00:00:00 2001 From: mickamy Date: Sun, 31 Dec 2023 14:43:33 +0900 Subject: [PATCH 06/26] fix: fix container name --- .github/workflows/benchmark.yml | 2 +- doc/local_manual.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index f6a4c576..06576863 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -20,5 +20,5 @@ jobs: - run: make build - run: docker compose up -d && sleep 10 timeout-minutes: 5 - - run: docker exec -it ishocon2_bench_1 ./benchmark --ip app:443 + - run: docker exec -it ishocon2-bench-1 ./benchmark --ip app:443 timeout-minutes: 5 diff --git a/doc/local_manual.md b/doc/local_manual.md index 71d526f7..7206bfea 100644 --- a/doc/local_manual.md +++ b/doc/local_manual.md @@ -43,6 +43,6 @@ $ docker exec -it ishocon2_app_1 /bin/bash ## ベンチマーカー ``` -$ docker exec -it ishocon2_bench_1 /bin/bash +$ docker exec -it ishocon2-bench-1 /bin/bash $ ./benchmark --ip app:443 # docker-compose.yml で link しているので app で到達できます ``` From ad917515f91cdbf2eff7d90452cb50892d72fe0c Mon Sep 17 00:00:00 2001 From: mickamy Date: Sun, 31 Dec 2023 14:45:16 +0900 Subject: [PATCH 07/26] make: add task to execute bench --- Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile b/Makefile index d84ee86b..ab1c9491 100644 --- a/Makefile +++ b/Makefile @@ -3,3 +3,6 @@ common: build: common docker compose build + +bench: build + docker exec -it ishocon2-bench-1 ./benchmark --ip app:443 From 90d8ecf1769fe4b54b0c5094f89c906ea160d973 Mon Sep 17 00:00:00 2001 From: mickamy Date: Sun, 31 Dec 2023 15:03:55 +0900 Subject: [PATCH 08/26] make: add up and down for docker to make --- Makefile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index ab1c9491..9c918a7e 100644 --- a/Makefile +++ b/Makefile @@ -4,5 +4,11 @@ common: build: common docker compose build -bench: build +up: build + docker compose up -d + +down: + docker compose down + +bench: up docker exec -it ishocon2-bench-1 ./benchmark --ip app:443 From 0cd168f4d0bef42d21a7313bf600d72442462d79 Mon Sep 17 00:00:00 2001 From: mickamy Date: Sun, 31 Dec 2023 15:31:03 +0900 Subject: [PATCH 09/26] feat: add script to run app --- docker-compose.yml | 4 +++- run.sh | 53 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100755 run.sh diff --git a/docker-compose.yml b/docker-compose.yml index d113d6fe..b7a8f5a3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,12 +4,14 @@ services: build: context: . dockerfile: ./docker/app/python/Dockerfile - command: tail -f /dev/null + command: /home/ishocon/run.sh && tail -f /dev/null volumes: - storage_app:/var/lib/mysql - ./webapp:/home/ishocon/webapp ports: - "443:443" + environment: + ISHOCON_APP_LANG: "${ISHOCON_APP_LANG-python}" bench: image: showwin/ishocon2_bench:latest diff --git a/run.sh b/run.sh new file mode 100755 index 00000000..d1ab942b --- /dev/null +++ b/run.sh @@ -0,0 +1,53 @@ +#!/bin/bash -eux + +app_lang="${ISHOCON_APP_LANG:-"python"}" + +check_message="start application..." + +make up +sleep 10 + +figlet -f slant "ISHOCON2" +echo "Ready." + +echo "app_lang: $app_lang" + +function run_ruby() { + echo "run python app..." + cd ~/webapp/ruby + unicorn -c unicorn_config.rb + echo "$check_message" +} + +function run_python() { + echo "run ruby app..." + cd ~/webapp/ruby + bundle install + echo "$check_message" + bundle exec puma -C config_puma.rb +} + +function run_go() { + echo "run go app..." + cd ~/webapp/go + go install + go build -o /tmp/webapp + ./webapp + echo "$check_message" +} + +function run_nodejs() { + echo "run nodejs app..." + npm install + node index.js + echo "$check_message" +} + +function run_crystal() { + echo "run crystal app..." + shards install + crystal app.cr + echo "$check_message" +} + +"run_$app_lang" From ac623b581b726c9846f969573494e015fac27453 Mon Sep 17 00:00:00 2001 From: mickamy Date: Sun, 31 Dec 2023 15:31:28 +0900 Subject: [PATCH 10/26] ci: run benchmark for all lang on CI --- .github/workflows/benchmark.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 06576863..1aaa15e8 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -15,6 +15,14 @@ jobs: timeout-minutes: 60 strategy: fail-fast: false + matrix: + language: + - "crystal" + - "go" + - "nodejs" + - "php" + - "python" + - "ruby" steps: - uses: actions/checkout@v2 - run: make build From 6c7ce8d86b5057b0730f0e5497e70d54e1c653dd Mon Sep 17 00:00:00 2001 From: mickamy Date: Sun, 31 Dec 2023 16:12:41 +0900 Subject: [PATCH 11/26] script: remove unnecessary lines --- run.sh | 7 ------- 1 file changed, 7 deletions(-) diff --git a/run.sh b/run.sh index d1ab942b..1f5bb01b 100755 --- a/run.sh +++ b/run.sh @@ -4,10 +4,7 @@ app_lang="${ISHOCON_APP_LANG:-"python"}" check_message="start application..." -make up sleep 10 - -figlet -f slant "ISHOCON2" echo "Ready." echo "app_lang: $app_lang" @@ -22,7 +19,6 @@ function run_ruby() { function run_python() { echo "run ruby app..." cd ~/webapp/ruby - bundle install echo "$check_message" bundle exec puma -C config_puma.rb } @@ -30,7 +26,6 @@ function run_python() { function run_go() { echo "run go app..." cd ~/webapp/go - go install go build -o /tmp/webapp ./webapp echo "$check_message" @@ -38,14 +33,12 @@ function run_go() { function run_nodejs() { echo "run nodejs app..." - npm install node index.js echo "$check_message" } function run_crystal() { echo "run crystal app..." - shards install crystal app.cr echo "$check_message" } From d641e45cfd9d92d89728aa4f8e352ee3df2f2abd Mon Sep 17 00:00:00 2001 From: mickamy Date: Sun, 31 Dec 2023 17:03:01 +0900 Subject: [PATCH 12/26] fix: run.sh and make file --- .github/workflows/benchmark.yml | 5 ++-- Makefile | 2 +- docker-compose.yml | 2 +- docker/app/base/Dockerfile | 1 + run.sh | 47 ++++++++++++++++++++------------- 5 files changed, 33 insertions(+), 24 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 1aaa15e8..40c6348c 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -26,7 +26,6 @@ jobs: steps: - uses: actions/checkout@v2 - run: make build - - run: docker compose up -d && sleep 10 - timeout-minutes: 5 - - run: docker exec -it ishocon2-bench-1 ./benchmark --ip app:443 + - run: make up && sleep 10 + - run: make bench timeout-minutes: 5 diff --git a/Makefile b/Makefile index 9c918a7e..de7d9d56 100644 --- a/Makefile +++ b/Makefile @@ -11,4 +11,4 @@ down: docker compose down bench: up - docker exec -it ishocon2-bench-1 ./benchmark --ip app:443 + docker exec -it ishocon2-bench-1 sh -c "./benchmark --ip app:443" diff --git a/docker-compose.yml b/docker-compose.yml index b7a8f5a3..d54227eb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,7 +4,7 @@ services: build: context: . dockerfile: ./docker/app/python/Dockerfile - command: /home/ishocon/run.sh && tail -f /dev/null + command: /home/ishocon/run.sh volumes: - storage_app:/var/lib/mysql - ./webapp:/home/ishocon/webapp diff --git a/docker/app/base/Dockerfile b/docker/app/base/Dockerfile index a961d0f0..e8d38081 100644 --- a/docker/app/base/Dockerfile +++ b/docker/app/base/Dockerfile @@ -23,5 +23,6 @@ COPY admin/config/nginx.conf /etc/nginx/nginx.conf # 各言語のインストールに必要なもの下準備 RUN apt-get install -y curl git gcc make libssl-dev libreadline-dev +COPY run.sh /home/ishocon/run.sh USER ishocon diff --git a/run.sh b/run.sh index 1f5bb01b..86c5daf6 100755 --- a/run.sh +++ b/run.sh @@ -1,46 +1,55 @@ #!/bin/bash -eux -app_lang="${ISHOCON_APP_LANG:-"python"}" +app_lang="${ISHOCON_APP_LANG}" -check_message="start application..." +if [ -z "$app_lang" ] +then + echo "ISHOCON_APP_LANG is not set" + exit 1 +fi -sleep 10 -echo "Ready." +check_message="start application w/ ${app_lang}..." echo "app_lang: $app_lang" function run_ruby() { - echo "run python app..." - cd ~/webapp/ruby - unicorn -c unicorn_config.rb - echo "$check_message" + bundle install + bundle exec puma -C config_puma.rb } function run_python() { - echo "run ruby app..." - cd ~/webapp/ruby + uwsgi --ini app.ini echo "$check_message" - bundle exec puma -C config_puma.rb } +function run_python_sanic() { + uwsgi --ini app.ini + echo "$check_message" +} + + function run_go() { - echo "run go app..." - cd ~/webapp/go - go build -o /tmp/webapp + go get -t -d -v ./... + go build -o webapp *.go ./webapp echo "$check_message" } -function run_nodejs() { - echo "run nodejs app..." - node index.js - echo "$check_message" +function run_php() { + cat README.md + tail -f /dev/null } function run_crystal() { - echo "run crystal app..." + shards install crystal app.cr echo "$check_message" } +echo "run $app_lang app..." +ls -alt /home/ishocon +ls -alt "/home/ishocon/webapp" +ls -alt "/home/ishocon/webapp/$app_lang" +cd "/home/ishocon/webapp/$app_lang" + "run_$app_lang" From c1b0fbb4df2fd83909ad895b32628f2ccfe9005c Mon Sep 17 00:00:00 2001 From: mickamy Date: Sun, 31 Dec 2023 17:43:27 +0900 Subject: [PATCH 13/26] docker: set tty true for app --- docker-compose.yml | 1 + run.sh | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index d54227eb..13c35d3e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,6 +5,7 @@ services: context: . dockerfile: ./docker/app/python/Dockerfile command: /home/ishocon/run.sh + tty: true volumes: - storage_app:/var/lib/mysql - ./webapp:/home/ishocon/webapp diff --git a/run.sh b/run.sh index 86c5daf6..c5d8556b 100755 --- a/run.sh +++ b/run.sh @@ -37,7 +37,6 @@ function run_go() { function run_php() { cat README.md - tail -f /dev/null } function run_crystal() { From 3e31a17b5cb84136c394757ae121f4414427a6d9 Mon Sep 17 00:00:00 2001 From: mickamy Date: Sun, 31 Dec 2023 17:45:17 +0900 Subject: [PATCH 14/26] refactor: dockerfile and environment should be closer for it would be changed at same time --- docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 13c35d3e..47f10b1c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,6 +4,8 @@ services: build: context: . dockerfile: ./docker/app/python/Dockerfile + environment: + ISHOCON_APP_LANG: "${ISHOCON_APP_LANG-python}" command: /home/ishocon/run.sh tty: true volumes: @@ -11,8 +13,6 @@ services: - ./webapp:/home/ishocon/webapp ports: - "443:443" - environment: - ISHOCON_APP_LANG: "${ISHOCON_APP_LANG-python}" bench: image: showwin/ishocon2_bench:latest From 048dd8d178ef8235c9b18a38796648300403f4e5 Mon Sep 17 00:00:00 2001 From: mickamy Date: Sun, 31 Dec 2023 19:02:43 +0900 Subject: [PATCH 15/26] docker: run sudo apt-get update for all Dockerfiles --- docker/app/crystal/Dockerfile | 2 +- docker/app/python/Dockerfile | 3 ++- docker/app/ruby/Dockerfile | 1 + docker/benchmarker/Dockerfile | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/docker/app/crystal/Dockerfile b/docker/app/crystal/Dockerfile index 9c8eea49..2a4b8921 100644 --- a/docker/app/crystal/Dockerfile +++ b/docker/app/crystal/Dockerfile @@ -2,10 +2,10 @@ FROM showwin/ishocon2_app_base:latest 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-get update RUN sudo apt install -y libssl1.0-dev crystal # アプリケーション diff --git a/docker/app/python/Dockerfile b/docker/app/python/Dockerfile index 9a2ca349..74c1963e 100644 --- a/docker/app/python/Dockerfile +++ b/docker/app/python/Dockerfile @@ -2,7 +2,8 @@ FROM showwin/ishocon2_app_base:latest ENV APP_LANG 'Python' # Python のインストール -RUN sudo apt-get install -y zlib1g-dev +RUN sudo apt-get update +RUN apt-get install -y zlib1g-dev RUN git clone https://github.com/pyenv/pyenv.git ~/.pyenv && \ PYENV_ROOT="$HOME/.pyenv" && PATH="$PYENV_ROOT/bin:$PATH" && \ eval "$(pyenv init -)" && \ diff --git a/docker/app/ruby/Dockerfile b/docker/app/ruby/Dockerfile index 30ab2418..f1891698 100644 --- a/docker/app/ruby/Dockerfile +++ b/docker/app/ruby/Dockerfile @@ -2,6 +2,7 @@ FROM showwin/ishocon2_app_base:latest ENV APP_LANG 'Ruby' # Ruby のインストール +RUN sudo apt-get update RUN sudo apt-get install -y ruby-dev libmysqlclient-dev && \ git clone https://github.com/sstephenson/rbenv.git ~/.rbenv RUN PATH="$HOME/.rbenv/bin:$PATH" && \ diff --git a/docker/benchmarker/Dockerfile b/docker/benchmarker/Dockerfile index cf9ef06b..d4ae10f1 100644 --- a/docker/benchmarker/Dockerfile +++ b/docker/benchmarker/Dockerfile @@ -1,6 +1,6 @@ FROM ubuntu:18.04 -RUN apt-get update +RUN sudo apt-get update RUN apt-get install -y wget # Go のインストール From 06bf57cc7e59ebc1111dcd225dc10f32b7bbc45a Mon Sep 17 00:00:00 2001 From: mickamy Date: Sun, 31 Dec 2023 19:20:34 +0900 Subject: [PATCH 16/26] python: sudo on install --- docker/app/python/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/app/python/Dockerfile b/docker/app/python/Dockerfile index 74c1963e..bb4c97ac 100644 --- a/docker/app/python/Dockerfile +++ b/docker/app/python/Dockerfile @@ -3,7 +3,7 @@ ENV APP_LANG 'Python' # Python のインストール RUN sudo apt-get update -RUN apt-get install -y zlib1g-dev +RUN sudo apt-get install -y zlib1g-dev RUN git clone https://github.com/pyenv/pyenv.git ~/.pyenv && \ PYENV_ROOT="$HOME/.pyenv" && PATH="$PYENV_ROOT/bin:$PATH" && \ eval "$(pyenv init -)" && \ From 55959fcbd182ba4b174f8cbf8ea00c5af6f3917e Mon Sep 17 00:00:00 2001 From: mickamy Date: Sun, 31 Dec 2023 19:23:44 +0900 Subject: [PATCH 17/26] ci: make every language app to be runned on CI --- .github/workflows/benchmark.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 40c6348c..5ad2e051 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -22,10 +22,13 @@ jobs: - "nodejs" - "php" - "python" + - "python_sanic" - "ruby" steps: - uses: actions/checkout@v2 - run: make build + env: + ISHOCON_APP_LANG: run_${{ matrix.language }} - run: make up && sleep 10 - run: make bench timeout-minutes: 5 From f3af7b6b9923a1fcca390823c87cad719b61b88f Mon Sep 17 00:00:00 2001 From: mickamy Date: Sun, 31 Dec 2023 19:42:26 +0900 Subject: [PATCH 18/26] docker: copy run.sh on each Dockerfile --- docker/app/base/Dockerfile | 1 - docker/app/crystal/Dockerfile | 2 ++ docker/app/go/Dockerfile | 2 ++ docker/app/nodejs/Dockerfile | 2 ++ docker/app/php/Dockerfile | 2 ++ docker/app/python/Dockerfile | 2 ++ docker/app/ruby/Dockerfile | 2 ++ 7 files changed, 12 insertions(+), 1 deletion(-) diff --git a/docker/app/base/Dockerfile b/docker/app/base/Dockerfile index e8d38081..a961d0f0 100644 --- a/docker/app/base/Dockerfile +++ b/docker/app/base/Dockerfile @@ -23,6 +23,5 @@ COPY admin/config/nginx.conf /etc/nginx/nginx.conf # 各言語のインストールに必要なもの下準備 RUN apt-get install -y curl git gcc make libssl-dev libreadline-dev -COPY run.sh /home/ishocon/run.sh USER ishocon diff --git a/docker/app/crystal/Dockerfile b/docker/app/crystal/Dockerfile index 2a4b8921..2d9397b8 100644 --- a/docker/app/crystal/Dockerfile +++ b/docker/app/crystal/Dockerfile @@ -17,6 +17,8 @@ COPY admin/config/bashrc /home/ishocon/.bashrc WORKDIR /home/ishocon EXPOSE 443 +COPY run.sh /home/ishocon/run.sh + COPY docker/app/entrypoint.sh /home/ishocon/docker/app/entrypoint.sh ENTRYPOINT ["/home/ishocon/docker/app/entrypoint.sh"] diff --git a/docker/app/go/Dockerfile b/docker/app/go/Dockerfile index 0bf5fd3e..bf6fe443 100644 --- a/docker/app/go/Dockerfile +++ b/docker/app/go/Dockerfile @@ -19,6 +19,8 @@ COPY admin/config/bashrc /home/ishocon/.bashrc WORKDIR /home/ishocon EXPOSE 443 +COPY run.sh /home/ishocon/run.sh + COPY docker/app/entrypoint.sh /home/ishocon/docker/app/entrypoint.sh ENTRYPOINT ["/home/ishocon/docker/app/entrypoint.sh"] diff --git a/docker/app/nodejs/Dockerfile b/docker/app/nodejs/Dockerfile index 66894826..0d670920 100644 --- a/docker/app/nodejs/Dockerfile +++ b/docker/app/nodejs/Dockerfile @@ -18,6 +18,8 @@ RUN cd /home/ishocon/webapp/nodejs && \ WORKDIR /home/ishocon EXPOSE 443 +COPY run.sh /home/ishocon/run.sh + COPY docker/app/entrypoint.sh /home/ishocon/docker/app/entrypoint.sh ENTRYPOINT ["/home/ishocon/docker/app/entrypoint.sh"] diff --git a/docker/app/php/Dockerfile b/docker/app/php/Dockerfile index 09e0949a..93ac966c 100644 --- a/docker/app/php/Dockerfile +++ b/docker/app/php/Dockerfile @@ -21,6 +21,8 @@ RUN cd /home/ishocon/webapp/php && \ WORKDIR /home/ishocon EXPOSE 443 +COPY run.sh /home/ishocon/run.sh + COPY docker/app/entrypoint.sh /home/ishocon/docker/app/entrypoint.sh ENTRYPOINT ["/home/ishocon/docker/app/entrypoint.sh"] diff --git a/docker/app/python/Dockerfile b/docker/app/python/Dockerfile index bb4c97ac..de949065 100644 --- a/docker/app/python/Dockerfile +++ b/docker/app/python/Dockerfile @@ -24,6 +24,8 @@ RUN LC_ALL=C.UTF-8 && LANG=C.UTF-8 && cd /home/ishocon/webapp/python && \ WORKDIR /home/ishocon EXPOSE 443 +COPY run.sh /home/ishocon/run.sh + COPY docker/app/entrypoint.sh /home/ishocon/docker/app/entrypoint.sh ENTRYPOINT ["/home/ishocon/docker/app/entrypoint.sh"] diff --git a/docker/app/ruby/Dockerfile b/docker/app/ruby/Dockerfile index f1891698..1ef34865 100644 --- a/docker/app/ruby/Dockerfile +++ b/docker/app/ruby/Dockerfile @@ -22,6 +22,8 @@ RUN cd /home/ishocon/webapp/ruby && sudo gem install bundler -v "1.16.1" && bund WORKDIR /home/ishocon EXPOSE 443 +COPY run.sh /home/ishocon/run.sh + COPY docker/app/entrypoint.sh /home/ishocon/docker/app/entrypoint.sh ENTRYPOINT ["/home/ishocon/docker/app/entrypoint.sh"] From 75f10653640ee78fbe588172172777a435e0d01b Mon Sep 17 00:00:00 2001 From: mickamy Date: Sun, 31 Dec 2023 19:43:52 +0900 Subject: [PATCH 19/26] ruby: fix run.sh to use unicorn --- run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run.sh b/run.sh index c5d8556b..d41b021e 100755 --- a/run.sh +++ b/run.sh @@ -14,7 +14,7 @@ echo "app_lang: $app_lang" function run_ruby() { bundle install - bundle exec puma -C config_puma.rb + unicorn -c unicorn_config.rbs } function run_python() { From 36328bd8e8ca5fc605357ca210913a1b2c5c4d10 Mon Sep 17 00:00:00 2001 From: mickamy Date: Sun, 31 Dec 2023 19:47:00 +0900 Subject: [PATCH 20/26] fix: idk why but uwsgi not found, so specify it with absolute path --- run.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/run.sh b/run.sh index d41b021e..39333766 100755 --- a/run.sh +++ b/run.sh @@ -18,12 +18,12 @@ function run_ruby() { } function run_python() { - uwsgi --ini app.ini + /home/ishocon/.pyenv/shims/uwsgi --ini app.ini echo "$check_message" } function run_python_sanic() { - uwsgi --ini app.ini + /home/ishocon/.pyenv/shims/uwsgi --ini app.ini echo "$check_message" } From 7a64de5cf31324e1843b87f8fc2cd45bfc6011f7 Mon Sep 17 00:00:00 2001 From: mickamy Date: Sun, 31 Dec 2023 19:47:17 +0900 Subject: [PATCH 21/26] chore: echo check message on ruby app run --- run.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/run.sh b/run.sh index 39333766..805d10d1 100755 --- a/run.sh +++ b/run.sh @@ -15,6 +15,7 @@ echo "app_lang: $app_lang" function run_ruby() { bundle install unicorn -c unicorn_config.rbs + echo "$check_message" } function run_python() { From b1da2d2fc16a545edc97dd45d8b2d5c8054f8c0f Mon Sep 17 00:00:00 2001 From: mickamy Date: Sun, 31 Dec 2023 19:51:40 +0900 Subject: [PATCH 22/26] ruby: fix typo in extension --- run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run.sh b/run.sh index 805d10d1..b4872739 100755 --- a/run.sh +++ b/run.sh @@ -14,7 +14,7 @@ echo "app_lang: $app_lang" function run_ruby() { bundle install - unicorn -c unicorn_config.rbs + unicorn -c unicorn_config.rb echo "$check_message" } From 340f1eb8877af2d3bcd3ef6656964df8e469d722 Mon Sep 17 00:00:00 2001 From: mickamy Date: Sun, 31 Dec 2023 20:24:06 +0900 Subject: [PATCH 23/26] chore: remove -t option from docker exec --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index de7d9d56..73c2477f 100644 --- a/Makefile +++ b/Makefile @@ -11,4 +11,4 @@ down: docker compose down bench: up - docker exec -it ishocon2-bench-1 sh -c "./benchmark --ip app:443" + docker exec -i ishocon2-bench-1 sh -c "./benchmark --ip app:443" From 509a17b0be020900a62e3eb8053293c42f12c264 Mon Sep 17 00:00:00 2001 From: mickamy Date: Sun, 31 Dec 2023 20:33:50 +0900 Subject: [PATCH 24/26] php: make php to be runnable by script --- run.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/run.sh b/run.sh index b4872739..d8495eb6 100755 --- a/run.sh +++ b/run.sh @@ -37,7 +37,10 @@ function run_go() { } function run_php() { - cat README.md + sudo mv -f /etc/nginx/nginx.conf /etc/nginx/nginx.conf.orig + sudo cp webapp/php/php-nginx.conf /etc/nginx/nginx.conf + sudo service nginx reload + echo "$check_message" } function run_crystal() { From 9f0367119566d8597e7b84c34ac708724287839f Mon Sep 17 00:00:00 2001 From: mickamy Date: Sun, 31 Dec 2023 21:09:25 +0900 Subject: [PATCH 25/26] ci: replace python to $ISUCON_APP_LANG --- .github/workflows/benchmark.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 5ad2e051..9ecdb72d 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -26,7 +26,7 @@ jobs: - "ruby" steps: - uses: actions/checkout@v2 - - run: make build + - run: sed -i 's/python/'"$ISUCON_APP_LANG"'/g' ./docker-compose.yml && make build env: ISHOCON_APP_LANG: run_${{ matrix.language }} - run: make up && sleep 10 From 7ecccac53506d19f39ccaa98995feae09756ea5c Mon Sep 17 00:00:00 2001 From: mickamy Date: Sun, 31 Dec 2023 21:15:18 +0900 Subject: [PATCH 26/26] ci: fix run command and other things --- .github/workflows/benchmark.yml | 10 +++++++--- Makefile | 2 +- docker-compose.yml | 2 +- docker/app/entrypoint.sh | 3 ++- docker/benchmarker/entrypoint.sh | 3 ++- run.sh | 3 --- 6 files changed, 13 insertions(+), 10 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 9ecdb72d..8b883e56 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -26,9 +26,13 @@ jobs: - "ruby" steps: - uses: actions/checkout@v2 - - run: sed -i 's/python/'"$ISUCON_APP_LANG"'/g' ./docker-compose.yml && make build + - 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: run_${{ matrix.language }} - - run: make up && sleep 10 + ISHOCON_APP_LANG: ${{ matrix.language }} + - run: make up && sleep 30 - run: make bench timeout-minutes: 5 diff --git a/Makefile b/Makefile index 73c2477f..1d19f64a 100644 --- a/Makefile +++ b/Makefile @@ -10,5 +10,5 @@ up: build down: docker compose down -bench: up +bench: docker exec -i ishocon2-bench-1 sh -c "./benchmark --ip app:443" diff --git a/docker-compose.yml b/docker-compose.yml index 47f10b1c..63abc4d3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,7 +6,7 @@ services: dockerfile: ./docker/app/python/Dockerfile environment: ISHOCON_APP_LANG: "${ISHOCON_APP_LANG-python}" - command: /home/ishocon/run.sh + command: [/home/ishocon/run.sh] tty: true volumes: - storage_app:/var/lib/mysql diff --git a/docker/app/entrypoint.sh b/docker/app/entrypoint.sh index 550bb516..0de1fe52 100755 --- a/docker/app/entrypoint.sh +++ b/docker/app/entrypoint.sh @@ -1,4 +1,5 @@ -#!/bin/bash +#!/bin/bash -eux + sudo service nginx start sudo service mysql start sudo chown -R mysql:mysql /var/lib/mysql /var/run/mysqld diff --git a/docker/benchmarker/entrypoint.sh b/docker/benchmarker/entrypoint.sh index dd93fcbc..36679d2d 100755 --- a/docker/benchmarker/entrypoint.sh +++ b/docker/benchmarker/entrypoint.sh @@ -1,4 +1,5 @@ -#!/bin/bash +#!/bin/bash -ux + service mysql start # なぜか失敗する(調査中) chown -R mysql:mysql /var/lib/mysql /var/run/mysqld service mysql start # 正しく起動 diff --git a/run.sh b/run.sh index d8495eb6..2bb0b68a 100755 --- a/run.sh +++ b/run.sh @@ -50,9 +50,6 @@ function run_crystal() { } echo "run $app_lang app..." -ls -alt /home/ishocon -ls -alt "/home/ishocon/webapp" -ls -alt "/home/ishocon/webapp/$app_lang" cd "/home/ishocon/webapp/$app_lang" "run_$app_lang"