Separated mysql / rails container
docker-compose.yaml
version: '3'
services:
db:
container_name: mysql
image: mysql:8.0.21
command: --default-authentication-plugin=mysql_native_password
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
MYSQL_DATABASE: root
TZ: 'Asia/Tokyo'
ports:
- "3306:3306"
tty: true
ruby:
container_name: ruby
build: .
volumes:
- ".:/runteq:cached"
# 1. exclude volumes
- /runteq/vendor
- /runteq/node_modules
- /runteq/tmp
- /runteq/log
- /runteq/.git
ports:
- 3000:3000
tty: true
Dockerfile
FROM ruby:2.6.4
ADD . /runteq
WORKDIR /runteq
SHELL ["/bin/bash", "-c"]
ENTRYPOINT [ "/bin/bash" ]
EXPOSE 3000
# WORKING USER
ARG DOCKER_UID=1000
ARG DOCKER_USER=runteq
ARG DOCKER_PASSWORD=runteq
RUN useradd -m --uid ${DOCKER_UID} --groups sudo ${DOCKER_USER} && echo ${DOCKER_USER}:${DOCKER_PASSWORD} | chpasswd
ENV APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1
ENV DEBCONF_NOWARNINGS=yes
# INIT
RUN apt-get -y update
RUN apt-get install -y apt-utils
RUN apt-get install -y build-essential
RUN apt-get install -y git-core
RUN apt-get install -y vim
# bundler
RUN apt-get install -y bundler
RUN gem install bundler:2.1.4
# YARN
RUN apt-get -y remove cmdtest
RUN apt-get -y remove yarn
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN apt-get update
RUN apt-get -y install yarn
# rbenv
RUN apt-get remove rbenv
RUN git clone https://github.com/rbenv/rbenv.git ~/.rbenv
RUN echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
RUN source ~/.bashrc
RUN ~/.rbenv/bin/rbenv init -
RUN echo 'eval "$(rbenv init -)"' >> ~/.bashrc
RUN mkdir -p ~/.rbenv/plugins
RUN git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
# RUN curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash
# nodeenv
RUN apt-get remove nodeenv
RUN git clone https://github.com/OiNutter/nodenv /usr/local/nodenv
RUN echo 'export NODENV_ROOT=/usr/local/nodenv' >> ~/.bashrc
RUN echo 'export PATH=$NODENV_ROOT/bin:$PATH' >> ~/.bashrc
RUN source ~/.bashrc
RUN echo 'eval "$(nodenv init -)"' >> ~/.bashrc
RUN mkdir -p /usr/local/nodenv/plugins
RUN git clone https://github.com/OiNutter/node-build /usr/local/nodenv/plugins/node-build
# Google chrome
RUN /bin/bash -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'
RUN curl -sS https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
RUN apt-get -y update
RUN apt-get install -y google-chrome-stable
# sqlite3
RUN apt-get install -y sqlite3
# ETC
RUN git config --global credential.helper store