Skip to content

Instantly share code, notes, and snippets.

@Vasyl-Varkholyak
Forked from tiagopog/Dockerfile
Created June 23, 2017 17:54
Show Gist options
  • Save Vasyl-Varkholyak/103cc94ed484dae277cb9540c295da46 to your computer and use it in GitHub Desktop.
Save Vasyl-Varkholyak/103cc94ed484dae277cb9540c295da46 to your computer and use it in GitHub Desktop.
Docker + Docker Compose example
default: &default
adapter: postgresql
encoding: unicode
pool: 5
timeout: 5000
username: postgres
host: postgres
port: 5432
development:
<<: *default
database: app_development
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: app_test
production:
<<: *default
database: app_production
version: "2"
volumes:
web-sync:
external: true
services:
web:
volumes:
- web-sync:/b2beauty/beautydate:rw
# - /Users/tiagopog/Dev/ruby/jsonapi-utils:/usr/local/bundle/gems/jsonapi-utils-0.4.3
app:
tty: true
stdin_open: true
build: .
command: bash -c "rake db:create db:migrate db:migrate && rails s -p 3000 -b '0.0.0.0'"
volumes:
- .:/app
environment:
- FOO=bar
ports:
- "3000:3000"
links:
- postgres
db_data:
image: busybox
volumes:
- /var/lib/postgresql/data
postgres:
image: postgres:9.4
volumes_from:
- db_data
ports:
- "5432"
FROM ruby:2.2.3
MAINTAINER tiagopog@gmail.com
# Install apt based dependencies required to run Rails as
# well as RubyGems. As the Ruby image itself is based on a
# Debian image, we use apt-get to install those.
RUN apt-get update && apt-get install -y \
build-essential \
nodejs
# Configure the main working directory. This is the base
# directory used in any further RUN, COPY, and ENTRYPOINT
# commands.
RUN mkdir -p /app
WORKDIR /app
# Copy the Gemfile as well as the Gemfile.lock and install
# the RubyGems. This is a separate step so the dependencies
# will be cached unless changes to one of those two files
# are made.
COPY Gemfile Gemfile.lock ./
RUN gem install bundler && bundle install --jobs 20 --retry 5
# Copy the main application.
COPY . ./
# Expose port 3000 to the Docker host, so we can access it
# from the outside.
EXPOSE 3000
ENTRYPOINT ["bundle", "exec"]
# The main command to run when the container starts. Also
# tell the Rails dev server to bind to all interfaces by
# default.
CMD ["rails", "server", "-b", "0.0.0.0"]
FROM node:4.4.7
RUN useradd --user-group --create-home --shell /bin/false app
ENV HOME=/home
ENV APP_PATH=$HOME/app
ENV LIB_PATH=$HOME/lib
RUN mkdir -p $APP_PATH &&\
mkdir -p $LIB_PATH
WORKDIR $APP_PATH
COPY package.json $LIB_PATH
RUN chown -R app:app $HOME
USER app
RUN npm install --prefix $LIB_PATH --silent &&\
npm install express --prefix $LIB_PATH --silent &&\
npm install --prefix $LIB_PATH --save-dev nodemon --silent &&\
npm cache clean &&\
ln -s $LIB_PATH/node_modules/ node_modules
EXPOSE 3000
CMD ["node_modules/.bin/nodemon", "config/server.js"]
FROM gcr.io/google_appengine/ruby
RUN mkdir -p /app
WORKDIR /app
RUN cd /rbenv/plugins/ruby-build &&\
git pull &&\
rbenv install -s 2.3.0 &&\
rbenv global 2.3.0 &&\
gem install -q --no-rdoc --no-ri bundler --version 1.12.5
ENV RBENV_VERSION=2.3.0\
HANAMI_ENV=production\
APPSERVER=puma
COPY Gemfile* /app/
RUN bundle install --jobs 2 --retry 10 --binstubs --deployment
COPY . /app
EXPOSE 8080
ENTRYPOINT []
CMD ["bundle", "exec", "hanami", "server", "--host", "0.0.0.0", "--port", "8080", "--no-code-reloading"]
FROM gcr.io/google_appengine/ruby
RUN mkdir -p /app
WORKDIR /app
ENV RBENV_VERSION=2.3.0\
HANAMI_ENV=development
RUN curl https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-117.0.0-linux-x86_64.tar.gz\
> /google-cloud-sdk-117.0.0-linux-x86_64.tar.gz
RUN tar xfvz /google-cloud-sdk-117.0.0-linux-x86_64.tar.gz -C / &&\
rm -f /google-cloud-sdk-117.0.0-linux-x86_64.tar.gz
RUN /google-cloud-sdk/install.sh --quiet
ENV PATH /google-cloud-sdk/bin:$PATH
RUN gem install bundler
COPY Gemfile* /app/
RUN bundle install --jobs 4 --retry 10 --binstubs
COPY . /app
EXPOSE 8080
ENTRYPOINT []
CMD ["bundle", "exec", "shotgun", "--host", "0.0.0.0", "--port", "8080"]
payments:
build: .
command: bash -c "node_modules/.bin/nodemon config/server.js"
ports:
- "3000:3000"
expose:
- "3000"
volumes:
- .:/home/app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment