Skip to content

Commit 6a45ea9

Browse files
authored
Merge pull request #14 from mickamy/try-with-apple-silicon
Try with apple silicon
2 parents ffddd75 + fcd5114 commit 6a45ea9

File tree

18 files changed

+902
-65
lines changed

18 files changed

+902
-65
lines changed

.env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ISHOCON_APP_LANG=ruby
2+

.envrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dotenv
2+

.github/workflows/benchmark.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ jobs:
1313
fail-fast: false
1414
matrix:
1515
language:
16-
- "crystal"
17-
- "go"
18-
- "nodejs"
19-
- "php"
20-
- "python"
16+
# - "crystal"
17+
# - "go"
18+
# - "nodejs"
19+
# - "php"
20+
# - "python"
2121
- "ruby"
2222
env:
2323
ISHOCON_APP_LANG: ${{ matrix.language }}
@@ -41,7 +41,7 @@ jobs:
4141
make pull || true
4242
make build
4343
timeout-minutes: 20
44-
- run: make up bench-with-db-init
44+
- run: make up bench-with-db-init WORKLOAD=4
4545
timeout-minutes: 10
4646
- name: Dump docker logs
4747
uses: jwalton/gh-docker-logs@v2

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
WORKLOAD = 3
1+
WORKLOAD = 7
22
ifeq ($(UNAME),)
33
UNAME = $(shell whoami)
44
endif

admin/config/bashrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,5 @@ alias ll='ls -alF'
2828
alias la='ls -A'
2929
alias l='ls -CF'
3030
alias grep='grep --color=auto'
31+
32+
export PATH="$HOME/scripts:$PATH"

admin/config/my.app.cnf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,11 @@
11
[mysqld]
22
bind-address = 0.0.0.0
3+
4+
#slow_query_log=1
5+
#long_query_time=1
6+
#log_queries_not_using_indexes=1
7+
#slow_query_log_file=/var/log/mysql/slow_query.log
8+
9+
innodb_buffer_pool_size = 2G
10+
innodb_log_file_size = 512M
11+
query_cache_size = 0

admin/config/nginx.conf

Lines changed: 55 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
user www-data;
2-
worker_processes 4;
2+
worker_processes auto;
33
pid /run/nginx.pid;
44

55
events {
@@ -10,19 +10,68 @@ http {
1010
include /etc/nginx/mime.types;
1111
default_type application/octet-stream;
1212

13-
access_log /var/log/nginx/access.log;
14-
error_log /var/log/nginx/error.log;
13+
14+
# access_log /var/log/nginx/access.log;
15+
# error_log /var/log/nginx/error.log;
16+
17+
access_log off;
18+
error_log /dev/null;
19+
20+
# alp 用のログフォーマット
21+
# log_format ltsv "time:$time_local"
22+
# "\thost:$remote_addr"
23+
# "\tforwardedfor:$http_x_forwarded_for"
24+
# "\treq:$request"
25+
# "\tstatus:$status"
26+
# "\tmethod:$request_method"
27+
# "\turi:$request_uri"
28+
# "\tsize:$body_bytes_sent"
29+
# "\treferer:$http_referer"
30+
# "\tua:$http_user_agent"
31+
# "\treqtime:$request_time"
32+
# "\tcache:$upstream_http_x_cache"
33+
# "\truntime:$upstream_http_x_runtime"
34+
# "\tapptime:$upstream_response_time"
35+
# "\tvhost:$host";
36+
# access_log /var/log/nginx/access.log ltsv;
37+
38+
proxy_cache_path /var/nginx/cache levels=1:2 keys_zone=CACHE:10m max_size=1g
39+
inactive=1m use_temp_path=off;
1540

1641
upstream app {
17-
server 127.0.0.1:8080;
42+
server 127.0.0.1:8080;
1843
}
1944

2045
server {
21-
listen 443;
22-
ssl on;
46+
listen 443 ssl http2;
2347
ssl_certificate /etc/nginx/ssl/server.crt;
2448
ssl_certificate_key /etc/nginx/ssl/server.key;
2549

50+
rewrite ^/(.*)/$ /$1 permanent;
51+
52+
location ~* ^/candidates/[^/]+/?$ {
53+
proxy_cache CACHE;
54+
proxy_pass http://app;
55+
proxy_set_header Host $host;
56+
proxy_cache_valid 200 302 60m;
57+
proxy_cache_valid 404 1m;
58+
}
59+
60+
location ~* ^/political_parties/[^/]+/?$ {
61+
proxy_cache CACHE;
62+
proxy_pass http://app;
63+
proxy_set_header Host $host;
64+
proxy_cache_valid 200 302 60m;
65+
proxy_cache_valid 404 1m;
66+
}
67+
68+
# alias access to /css/
69+
location /css/ {
70+
# set max-age=1year
71+
expires 31536000s;
72+
alias /home/ishocon/webapp/ruby/public/css/;
73+
}
74+
2675
location / {
2776
proxy_set_header Host $host;
2877
proxy_pass http://app;

docker-compose.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
version: '3.9'
22
services:
33
app:
4-
build:
4+
build:
55
context: .
6-
dockerfile: ./docker/app/python/Dockerfile
6+
dockerfile: ./docker/app/ruby/Dockerfile
77
args:
88
BASE_IMAGE: ishocon2-app-base:latest
99
# ローカルで base image をビルドしない場合は以下を利用すること
1010
# BASE_IMAGE: showwin/ishocon2_app_base:latest
11-
image: ishocon2-app-python:latest
11+
image: ishocon2-app-ruby:latest
1212
environment:
13-
ISHOCON_APP_LANG: "${ISHOCON_APP_LANG-python}"
13+
ISHOCON_APP_LANG: "${ISHOCON_APP_LANG-ruby}"
1414
healthcheck:
1515
test: ["CMD", "test", "-f", "/tmp/ishocon-app"]
1616
interval: 10s
@@ -19,6 +19,8 @@ services:
1919
start_period: 120s
2020
command: [/home/ishocon/run.sh]
2121
tty: true
22+
volumes:
23+
- rbenv:/home/ishocon/.rbenv
2224
ports:
2325
- "443:443"
2426
- "3306:3306"
@@ -30,8 +32,11 @@ services:
3032
command: tail -f /dev/null
3133
links:
3234
- app
33-
environment:
35+
environment:
3436
TARGET: app
3537
depends_on:
3638
app:
3739
condition: service_healthy
40+
41+
volumes:
42+
rbenv:

docker/app/base/Dockerfile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ENV LANG=en_US.UTF-8 \
77
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
88

99
RUN apt-get update && \
10-
apt-get install -y sudo wget less vim tzdata nginx \
10+
apt-get install -y sudo wget less vim tzdata nginx htop \
1111
# 各言語のインストールに必要なもの下準備 \
1212
curl git gcc make libssl-dev libreadline-dev && \
1313
apt-get clean
@@ -23,7 +23,6 @@ COPY admin/config/bashrc /home/ishocon/.bashrc
2323

2424
# Nginx の設定
2525
COPY admin/ssl/ /etc/nginx/ssl/
26-
COPY admin/config/nginx.conf /etc/nginx/nginx.conf
2726

2827
# MySQL のインストールと dump, cnf の配置
2928
RUN ["/bin/bash", "-c", "debconf-set-selections <<< 'mysql-server mysql-server/root_password password ishocon'"]
@@ -32,7 +31,6 @@ RUN ["/bin/bash", "-c", "debconf-set-selections <<< 'mysql-service mysql-server/
3231
RUN apt-get install -y mysql-server
3332
RUN mkdir -m 777 /home/ishocon/data
3433
COPY admin/ishocon2.dump.tar.bz2 /home/ishocon/data/ishocon2.dump.tar.bz2
35-
COPY admin/config/my.app.cnf /etc/mysql/my.cnf
3634

3735
USER ishocon
3836

docker/app/ruby/Dockerfile

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,40 @@ FROM ${BASE_IMAGE}
33

44
# Ruby のインストール
55
RUN sudo apt-get update && \
6-
sudo apt-get install -y ruby-dev libmysqlclient-dev libffi6 libffi-dev libyaml-dev bzip2 && \
6+
sudo apt-get install -y ruby-dev libmysqlclient-dev libffi6 libffi-dev libyaml-dev bzip2 percona-toolkit && \
77
sudo apt-get clean && \
88
git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
99
RUN PATH="$HOME/.rbenv/bin:$PATH" && \
1010
eval "$(rbenv init -)" && \
1111
git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build && \
12-
rbenv install 2.5.1 && rbenv rehash && rbenv global 2.5.1
12+
rbenv install 3.2.2 && rbenv rehash && rbenv global 3.2.2
13+
14+
ARG TARGETARCH
15+
16+
# install alp
17+
RUN sudo curl -L -O https://github.com/tkuchiki/alp/releases/download/v1.0.21/alp_linux_${TARGETARCH}.zip && \
18+
sudo unzip alp_linux_${TARGETARCH}.zip && \
19+
sudo rm -rf unzip alp_linux_${TARGETARCH}.zip && \
20+
sudo mv alp /usr/local/bin/ && \
21+
alp --version
22+
23+
ENV RUBY_YJIT_ENABLE=1
24+
25+
# 頻繁に書き換えるファイルのコピー
26+
COPY admin/config/my.app.cnf /etc/mysql/my.cnf
27+
COPY admin/config/nginx.conf /etc/nginx/nginx.conf
1328

1429
# アプリケーション
1530
COPY --chown=ishocon:ishocon webapp/ /home/ishocon/webapp
1631

32+
# pt-query-digest 用のスクリプト配置
33+
COPY --chown=ishocon:ishocon --chmod=777 scripts/ /home/ishocon/scripts/
34+
1735
WORKDIR /home/ishocon
1836

19-
RUN sudo gem install bundler -v "1.16.1" && \
20-
cd webapp/ruby && \
37+
RUN cd webapp/ruby && \
2138
. /home/ishocon/.bashrc && \
39+
gem install bundler -v "2.5.4" && \
2240
bundle install
2341

2442
COPY run.sh /home/ishocon/run.sh

0 commit comments

Comments
 (0)