Skip to content

Instantly share code, notes, and snippets.

@schuster-rainer
Created September 13, 2018 14:39
Show Gist options
  • Save schuster-rainer/a1d86d639ab7163d6cde6b3d53c2b344 to your computer and use it in GitHub Desktop.
Save schuster-rainer/a1d86d639ab7163d6cde6b3d53c2b344 to your computer and use it in GitHub Desktop.
CentOS based rails docker setup
version: '3.6'
services:
rails:
# - container_name: my-app
depends_on:
- 'mariadb'
- 'redis'
build: .
ports:
- '80:3000'
- '1234:1234' #ruby-debug-ide
- '26126:26126'
# environment:
env_file:
- '.env'
# restart: on-failure
command: bash -c 'bundle check || bundle install && sleep 100d'
volumes:
- '.bash_history:/root/.bash_history'
- './:/home/myapp/application'
- 'bundle:/bundle'
mariadb:
image: mariadb:${MARIADB_VERSION:-10.3.2}
restart: always
ports:
- 3306
env_file:
- '.env'
volumes:
- 'mariadb:/var/lib/mysql'
- './dump.sql:/docker-entrypoint-initdb.d/dump.sql'
redis:
image: 'redis:3.2-alpine'
ports:
- '6379:6379'
volumes:
- 'redis:/data'
command: redis-server --appendonly yes
# restart: on-failure
# Needs proper CORS setup on the rails server
ui: # alpine based
image: 'node:8.11-jessie'
ports:
- '3000:3000'
volumes:
- '../your_js_frontend_repo:/ui'
- 'node_modules:/ui/node_modules'
command: bash -c 'sleep 100d'
# command: yarn start
env_file:
- '.env'
environment:
HOST: 0.0.0.0
sidekiq:
depends_on:
- 'rails'
- 'mariadb'
- 'redis'
build: .
command: bundle exec sidekiq -C config/sidekiq.yml
volumes:
- './:/home/myapp/application'
- 'bundle:/bundle'
env_file:
- '.env'
# restart: on-failure
# cable:
# depends_on:
# - 'redis'
# build: .
# command: puma -p 28080 cable/config.ru
# ports:
# - '28080:28080'
# volumes:
# - 'data:/app'
# env_file:
# - '.env'
volumes:
redis:
mariadb:
bundle:
node_modules:
FROM drecom/centos-ruby:2.2.3
MAINTAINER Rainer Schuster <schuster-rainer@web.de>
ENV TZ Europe/Berlin
ENV LANG en_US.UTF-8
ENV APP_USER myapp
ENV APP_GROUP web
ENV HOME_DIR /home/${APP_USER}
ENV APP_DIR ${HOME_DIR}/application
ENV SHARED_DIR ${HOME_DIR}/shared
# ENV LOG_DIR $INSTALL_PATH/log
ENV APP_TMP_DIR ${APP_DIR}/tmp
# RUN yum check-update -y && yum upgrade -y &&
RUN yum install -y build-essential htop vim curl ssh rsync bzip2 libicu-devel ntp && yum clean all
RUN groupadd --gid 1000 $APP_GROUP && useradd --create-home --uid 1000 --gid 1000 --shell /bin/bash $APP_USER
RUN mkdir -p $APP_DIR
RUN mkdir -p $APP_TMP_DIR
RUN mkdir -p $SHARED_DIR
WORKDIR $APP_DIR
COPY app app/
COPY lib lib/
COPY bin bin/
COPY config config/
COPY db db/
# COPY public public/
COPY Gemfile* Rakefile config.ru Rakefile .pryrc *.rb ./
# RUN chown -R ${APP_USER}:${APP_GROUP} ${HOME_DIR}
# USER ${APP_USER}
ENV BUNDLE_PATH /bundle
VOLUME ["$APP_DIR"]
# CMD bundle exec unicorn -c config/unicorn.rb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment