Skip to content

Instantly share code, notes, and snippets.

@claudiosikeda
Last active May 2, 2017 01:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save claudiosikeda/546e26f7da8ca6df95c400b5ff4e3b4f to your computer and use it in GitHub Desktop.
Save claudiosikeda/546e26f7da8ca6df95c400b5ff4e3b4f to your computer and use it in GitHub Desktop.
Configure a rails 5.0 app to run inside docker using postgis 9.6, on Ubuntu 16.04

Run guard

docker-compose run -e "RAILS_ENV=test" app bundle exec guard

Import .sql file

cat dump.sql | docker container exec -i my_container_db_1 psql -U postgres my_database
# PostGIS is a spatial database extender for PostgreSQL
db:
image: mdillon/postgis:9.6
ports:
- "5432"
app:
build: .
command: bundle exec rails s -p 3000 -b '0.0.0.0'
volumes:
- .:/app
ports:
- "3000:3000"
links:
- db
FROM ruby:2.3.1
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs
# postgresql repo for Ubuntu 16.04
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main" > /etc/apt/sources.list.d/pgdg.list
RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
# install postgresql-client
RUN apt-get update && apt-get install -y postgresql-client-9.6 --no-install-recommends && rm -rf /var/lib/apt/lists/*
RUN mkdir -p /app
WORKDIR /app
COPY Gemfile Gemfile.lock ./
RUN gem install bundler && bundle install --jobs 20 --retry 5
COPY . ./
EXPOSE 3000
CMD ["bundle", "exec", "rails", "server", "-b", "0.0.0.0"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment