Last active
August 11, 2018 10:38
-
-
Save tiagopog/32bb84115ebcfe2b69bf882c3acf8dc1 to your computer and use it in GitHub Desktop.
Docker + Docker Compose example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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