Skip to content

Commit

Permalink
Merge pull request #36 from showwin/docker-ruby
Browse files Browse the repository at this point in the history
Add Docker env for Ruby version
  • Loading branch information
showwin authored Sep 30, 2024
2 parents 5c86bd5 + 34593b5 commit 29d67c0
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
# - "go"
# - "nodejs"
- "python"
# - "ruby"
- "ruby"
env:
ISHOCON_APP_LANG: ${{ matrix.language }}
UNAME: ${{ secrets.DOCKER_HUB_USERNAME }}
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ change-lang: check-lang
if sed --version 2>&1 | grep -q GNU; then \
echo "GNU sed"; \
sed -i 's/\(ruby\|python\|go\|nodejs\)/'"$(ISHOCON_APP_LANG)"'/g' ./docker-compose.yml; \
export ISHOCON_APP_LANG=$(ISHOCON_APP_LANG); \
else \
echo "BSD sed"; \
sed -i '' -E 's/(ruby|python|go|nodejs)/'"$(ISHOCON_APP_LANG)"'/g' ./docker-compose.yml; \
Expand Down
1 change: 0 additions & 1 deletion doc/local_manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ $ cd ISHOCON1

```
$ make change-lang ISHOCON_APP_LANG=<your_language>
$ export ISHOCON_APP_LANG=<your_language>
```

```
Expand Down
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ services:
app:
build:
context: .
dockerfile: ./docker/app/python/Dockerfile
dockerfile: ./docker/app/ruby/Dockerfile
args:
BASE_IMAGE: ishocon1-app-base:latest
# ローカルで base image をビルドしない場合は以下を利用すること
# BASE_IMAGE: showwin/ishocon1_app_base:latest
image: ishocon1-app-python:latest
image: ishocon1-app-ruby:latest
environment:
ISHOCON_APP_LANG: "${ISHOCON_APP_LANG-python}"
ISHOCON_APP_LANG: "${ISHOCON_APP_LANG-ruby}"
healthcheck:
test: ["CMD", "test", "-f", "/tmp/ishocon-app"]
interval: 10s
Expand Down
10 changes: 5 additions & 5 deletions docker/app/base/.bashrc
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
export PATH=$PATH:/usr/local/go/bin
export GOROOT=/usr/local/go
export GOPATH=$HOME/gocode
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
# export PATH="$HOME/.rbenv/bin:$PATH"
# eval "$(rbenv init -)"
# export PYENV_ROOT="$HOME/.pyenv"
# export PATH="$PYENV_ROOT/bin:$PATH"
# eval "$(pyenv init -)"

export ISHOCON1_DB_HOST="127.0.0.1"
export ISHOCON1_DB_PORT=3306
Expand Down
4 changes: 3 additions & 1 deletion docker/app/python/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
ARG BASE_IMAGE=ishocon1-app-base:latest
FROM ${BASE_IMAGE}

ENV PYTHON_VERSION=3.8.5

# Python のインストール
RUN sudo apt-get update && \
sudo apt-get install -y zlib1g-dev libbz2-dev libffi-dev libsqlite3-dev liblzma-dev libmariadb-dev pkgconf && \
sudo apt-get clean
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.8.5 && pyenv global 3.8.5
pyenv install $PYTHON_VERSION && pyenv global $PYTHON_VERSION

# アプリケーション
COPY --chown=ishocon:ishocon webapp/ /home/ishocon/webapp
Expand Down
26 changes: 26 additions & 0 deletions docker/app/ruby/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
ARG BASE_IMAGE=ishocon2-app-base:latest
FROM ${BASE_IMAGE}

ENV RUBY_VERSION=2.7.1

# Ruby のインストール
RUN sudo apt-get update && \
sudo apt-get install -y ruby-dev libmysqlclient-dev libffi-dev libyaml-dev bzip2 && \
sudo apt-get clean && \
git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
RUN PATH="$HOME/.rbenv/bin:$PATH" && \
eval "$(rbenv init -)" && \
git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build && \
rbenv install $RUBY_VERSION && rbenv rehash && rbenv global $RUBY_VERSION

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

WORKDIR /home/ishocon

RUN sudo gem install bundler -v "1.16.1" && \
cd webapp/ruby && \
. /home/ishocon/.bashrc && \
bundle install

COPY run.sh /home/ishocon/run.sh
2 changes: 1 addition & 1 deletion webapp/ruby/unicorn_config.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
worker_processes 4
preload_app true
pid './unicorn.pid'
pid '/tmp/unicorn.pid'
listen 8080

0 comments on commit 29d67c0

Please sign in to comment.