Did an "official" docker-compose.yml get posted for Docker deployments?
Yeah. In fact, I burned many hours over the weekend trying to get it working (i.e., with an existing Rails app), but couldn't get past
I will try some more as I have the bandwidth, and if I crack that nut, I'll definitely share with this community.
bundler failures. Looking at SO, this seems to be a common problem, but nobody can agree on a definitive solution (nor could I make any of them work). I will try some more as I have the bandwidth, and if I crack that nut, I'll definitely share with this community.
This is the docker-compose I use for development, and I use the Dockerfile/entrypoint/etc.. in production. Please note my entrypoint does a migrate, you may not want to do that. Maybe that helps?
docker-compose.yml
docker-compose.yml
version: '3'
services:
db:
image: postgres
environment:
- POSTGRES_PASSWORD=postgres
ports:
- "5432:5432"
volumes:
- ./docker/volumes/postgres:/var/lib/postgresql/data
web:
build:
context: .
args:
RAILS_ENV: development
environment:
- RAILS_ENV=development
- RAILS_DATABASE_HOST=db
volumes:
- .:/opt/myapp
ports:
- "3000:3000"
depends_on:
- dbentrypoint.sh
#!/bin/sh set -e # Remove a potentially pre-existing server.pid for Rails. rm -f /opt/myapp/tmp/pids/server.pid # Do migrations bundle exec rake db:migrate # Then exec the container's main process (what's set as CMD in the Dockerfile). exec "$@"
gem_installer.sh
#!/usr/bin/env sh
echo
echo "RAILS ENVIRONMENT: ${RAILS_ENV}"
echo
if [[ "${RAILS_ENV}" == "production" ]]; then
with_or_without='without'; \
else
with_or_without='with'; \
fi
bundle install --jobs `expr $(cat /proc/cpuinfo | grep -c "cpu cores") - 1` \
--retry 3 --${with_or_without}=development,test
apk del --no-cache --update build-base \
linux-headers \
git \
nodejsDockerfile
FROM ruby:2.6-alpine
RUN apk add --no-cache --update build-base \
ca-certificates \
linux-headers \
git \
postgresql-dev \
nodejs \
tzdata
RUN gem install bundler
ARG RAILS_ENV=""
ENV RAILS_ENV=$RAILS_ENV
ENV RAILS_LOG_TO_STDOUT true
ENV APP_PATH /opt/myapp
WORKDIR $APP_PATH
ADD Gemfile $APP_PATH
ADD Gemfile.lock $APP_PATH
ADD gem_installer.sh /usr/bin/
RUN /usr/bin/gem_installer.sh
COPY . $APP_PATH
RUN mv $APP_PATH/entrypoint.sh /usr/bin; chmod +x /usr/bin/entrypoint.sh
ENTRYPOINT ["/usr/bin/entrypoint.sh"]
EXPOSE 3000
CMD ["bundle", "exec", "rails", "server", "-b", "0.0.0.0"]database.yml
default: &default adapter: postgresql host: <%= Settings.database.host %> port: 5432 username: <%= Settings.database.username %> password: <%= Settings.database.password %> pool: <%= Settings.database.pool %> timeout: 5000 reconnect: true development: <<: *default database: myapp-development
settings.yml
database:
host: <%= ENV.fetch('RAILS_DATABASE_HOST', 'localhost') %>
username: <%= ENV.fetch('RAILS_DATABASE_USERNAME', 'postgres') %>
password: <%= ENV.fetch('RAILS_DATABASE_PASSWORD', 'postgres') %>
pool: <%= ENV.fetch('RAILS_MAX_THREADS') { 5 } %>
Notifications
You’re not receiving notifications from this thread.