Skip to content

Instantly share code, notes, and snippets.

@kelby
Last active January 4, 2017 09:12
Show Gist options
  • Save kelby/54527f8c10a348628102d7a9f790dfdc to your computer and use it in GitHub Desktop.
Save kelby/54527f8c10a348628102d7a9f790dfdc to your computer and use it in GitHub Desktop.
sx docker 初步
db:
image: mysql
ports:
# - "3306"
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: ''
# MYSQL_USER: dev
# MYSQL_PASSWORD: 123456
MYSQL_DATABASE: get_real_development
# rails:
# image: rails:4.2.5
# node:
# image: node
# java:
# image: java
# javasdk:
# image: javasdk
redis:
image: redis
ports:
- "6379"
elasticsearch:
image: elasticsearch
ports:
- "9920"
web:
build: .
command: bundle exec rails s -p 3000 -b0
volumes:
- ~/get-real/:/var/www/get-real
ports:
- "3000:3000"
links:
- db
- redis
- elasticsearch
# 独占端口、socket:nginx
# 语言:ruby, node, java
# 服务:mysql, redis, elasticsearch, memcached, cron
# 其它:sidekiq、tmux、unicorn、rbenv
# 软件:rails, gem, openjdk, openssh, git, image_magic, nokogiri
FROM ruby:2.3.0
RUN cp /etc/apt/sources.list /etc/apt/sources.list.backup
RUN sed -i -e "s/archive\.ubuntu\.com/mirrors\.163\.com/g" /etc/apt/sources.list
RUN apt-get update
RUN apt-get update -qq && apt-get install -y build-essential
RUN apt-get install -y git-core curl
RUN apt-get install -y ruby-dev
# for nokogiri
RUN apt-get install -y libxml2-dev libxslt1-dev
# for a JS runtime
RUN apt-get install -y nodejs
# install essentials
RUN apt-get -y install build-essential
RUN apt-get install -y -q git
# RUN add-apt-repository -y ppa:chris-lea/nginx-devel
# RUN apt-get install -y -q nginx-full
# Install rbenv
# RUN git clone https://github.com/sstephenson/rbenv.git /usr/local/rbenv
# RUN echo '# rbenv setup' > /etc/profile.d/rbenv.sh
# RUN echo 'export RBENV_ROOT=/usr/local/rbenv' >> /etc/profile.d/rbenv.sh
# RUN echo 'export PATH="$RBENV_ROOT/bin:$PATH"' >> /etc/profile.d/rbenv.sh
# RUN echo 'eval "$(rbenv init -)"' >> /etc/profile.d/rbenv.sh
# RUN chmod +x /etc/profile.d/rbenv.sh
# install ruby-build
# RUN mkdir /usr/local/rbenv/plugins
# RUN git clone https://github.com/sstephenson/ruby-build.git /usr/local/rbenv/plugins/ruby-build
# ENV RBENV_ROOT /usr/local/rbenv
# ENV PATH "$RBENV_ROOT/bin:$RBENV_ROOT/shims:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
# does not work. PATH is set to
# $RBENV_ROOT/shims:$RBENV_ROOT/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
# install ruby3
# RUN rbenv install 2.3.0
# RUN mkdir -p /var/www/get-real/
VOLUME ["/var/www/get-real"]
ENV APP_HOME /var/www/get-real
# RUN mkdir $APP_HOME
WORKDIR $APP_HOME
# ADD Gemfile* $APP_HOME/
RUN gem sources --remove https://rubygems.org/
RUN gem sources --remove http://rubygems.org/
RUN gem sources --add https://gems.ruby-china.org/
RUN echo 'gem: --no-rdoc --no-ri' >> /.gemrc
RUN gem install bundler
# RUN gem update --system
# RUN bundle install -V
# ADD . $APP_HOME
EXPOSE 3000
CMD ["rails", "server", "-b", "0.0.0.0"]
# 已经有 image 的,则直接用,注意版本;
# 其它的软件统统放到自己的 ubuntu 里。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment