docker-compose and postgres basic rails app skeleton
This commit is contained in:
parent
91aa86ad99
commit
63636ec562
6 changed files with 60 additions and 19 deletions
17
Dockerfile
17
Dockerfile
|
@ -0,0 +1,17 @@
|
||||||
|
# syntax=docker/dockerfile:1
|
||||||
|
FROM ruby:2.7.0
|
||||||
|
RUN apt-get update -qq && apt-get install -y nodejs postgresql-client
|
||||||
|
WORKDIR /data_importer
|
||||||
|
COPY Gemfile /data_importer/Gemfile
|
||||||
|
COPY Gemfile.lock /data_importer/Gemfile.lock
|
||||||
|
RUN bundle install
|
||||||
|
|
||||||
|
# Add a script to be executed every time the container starts.
|
||||||
|
COPY entrypoint.sh /usr/bin/
|
||||||
|
RUN chmod +x /usr/bin/entrypoint.sh
|
||||||
|
ENTRYPOINT ["entrypoint.sh"]
|
||||||
|
EXPOSE 3000
|
||||||
|
|
||||||
|
# Configure the main process to run when running the image
|
||||||
|
CMD ["rails", "server", "-b", "0.0.0.0"]
|
||||||
|
|
4
Gemfile
4
Gemfile
|
@ -5,8 +5,8 @@ ruby '2.7.0'
|
||||||
|
|
||||||
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
|
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
|
||||||
gem 'rails', '~> 5.2.3'
|
gem 'rails', '~> 5.2.3'
|
||||||
# Use sqlite3 as the database for Active Record
|
# Use postgres as the database for Active Record
|
||||||
gem 'sqlite3'
|
gem 'pg'
|
||||||
# Use Puma as the app server
|
# Use Puma as the app server
|
||||||
gem 'puma', '~> 3.11'
|
gem 'puma', '~> 3.11'
|
||||||
# Use SCSS for stylesheets
|
# Use SCSS for stylesheets
|
||||||
|
|
5
bin/docker_rebuild.sh
Executable file
5
bin/docker_rebuild.sh
Executable file
|
@ -0,0 +1,5 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
# docker rebuild and bundle install
|
||||||
|
# updates Gemfile.lock
|
||||||
|
|
||||||
|
docker-compose run web bundle install
|
|
@ -1,25 +1,17 @@
|
||||||
# SQLite version 3.x
|
|
||||||
# gem install sqlite3
|
|
||||||
#
|
|
||||||
# Ensure the SQLite 3 gem is defined in your Gemfile
|
|
||||||
# gem 'sqlite3'
|
|
||||||
#
|
|
||||||
default: &default
|
default: &default
|
||||||
adapter: sqlite3
|
adapter: postgresql
|
||||||
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
|
encoding: unicode
|
||||||
timeout: 5000
|
host: db
|
||||||
|
username: postgres
|
||||||
|
password: password
|
||||||
|
pool: 5
|
||||||
|
|
||||||
development:
|
development:
|
||||||
<<: *default
|
<<: *default
|
||||||
database: db/development.sqlite3
|
database: data_importer_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:
|
test:
|
||||||
<<: *default
|
<<: *default
|
||||||
database: db/test.sqlite3
|
database: data_importer_test
|
||||||
|
|
||||||
production:
|
|
||||||
<<: *default
|
|
||||||
database: db/production.sqlite3
|
|
||||||
|
|
18
docker-compose.yml
Normal file
18
docker-compose.yml
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
version: "3.3"
|
||||||
|
services:
|
||||||
|
db:
|
||||||
|
image: postgres
|
||||||
|
volumes:
|
||||||
|
- ./tmp/db:/var/lib/postgresql/data
|
||||||
|
environment:
|
||||||
|
POSTGRES_PASSWORD: password
|
||||||
|
web:
|
||||||
|
build: .
|
||||||
|
command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'"
|
||||||
|
volumes:
|
||||||
|
- .:/data_importer
|
||||||
|
ports:
|
||||||
|
- "3000:3000"
|
||||||
|
depends_on:
|
||||||
|
- db
|
||||||
|
|
9
entrypoint.sh
Normal file
9
entrypoint.sh
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Remove a potentially pre-existing server.pid for Rails.
|
||||||
|
rm -f /myapp/tmp/pids/server.pid
|
||||||
|
|
||||||
|
# Then exec the container's main process (what's set as CMD in the Dockerfile).
|
||||||
|
exec "$@"
|
||||||
|
|
Loading…
Add table
Reference in a new issue