Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testing #556

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.7.5
2.7.6
20 changes: 9 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
# Use the official Ruby image because the Rails images have been deprecated
FROM ruby:2.7.5
FROM ruby:2.7.6

RUN apt-get update \
&& apt-get install -y --no-install-recommends postgresql-client \
&& rm -rf /var/lib/apt/lists/*

RUN mkdir /usr/local/node \
&& curl -L https://nodejs.org/dist/v4.4.7/node-v4.4.7-linux-x64.tar.xz | tar Jx -C /usr/local/node --strip-components=1
RUN ln -s ../node/bin/node /usr/local/bin/
RUN apt-get update -qq && apt-get install -y nodejs postgresql-client

WORKDIR /ohana-api

COPY Gemfile /ohana-api
COPY Gemfile.lock /ohana-api
COPY Gemfile /ohana-api/Gemfile
COPY Gemfile.lock /ohana-api/Gemfile.lock

RUN gem install bundler
RUN bundle install --jobs 20 --retry 5 --without production

COPY entrypoint.sh /usr/bin/
RUN chmod +x /usr/bin/entrypoint.sh
ENTRYPOINT ["entrypoint.sh"]
EXPOSE 8080

COPY . /ohana-api

EXPOSE 8080
CMD ["rails", "server", "-b", "0.0.0.0", "-p", "8080"]
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
source 'https://rubygems.org'

ruby '2.7.5'
ruby '2.7.6'
gem 'active_model_serializers', '~> 0.8.0'
gem 'ancestry'
gem 'auto_strip_attributes', '~> 2.0'
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ DEPENDENCIES
webmock

RUBY VERSION
ruby 2.7.5p203
ruby 2.7.6p219

BUNDLED WITH
2.2.17
4 changes: 3 additions & 1 deletion config/database.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
default: &default
adapter: postgresql
encoding: utf8
host: localhost
host: <%= ENV['DOCKER_DB_HOST'] || 'localhost' %>
port: 5432
pool: <%= ENV['DB_POOL'] || ENV['MAX_THREADS'] || 5 %>
url: <%= ENV['DATABASE_URL'] %>
Expand All @@ -10,13 +10,15 @@ default: &default
development:
<<: *default
database: ohana_api_development
password: password

# 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: ohana_api_test
password: password

production:
pool: <%= ENV['DB_POOL'] || ENV['MAX_THREADS'] || 5 %>
Expand Down
12 changes: 9 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
version: '2'
version: "3.9"
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 8080 -b '0.0.0.0'"
volumes:
- .:/ohana-api
ports:
- "8080:8080"
environment:
DATABASE_URL: "postgres://postgres@db"
DOCKER_DB_HOST: 'db'
depends_on:
- db
db:
image: postgres
8 changes: 8 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/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 "$@"
Empty file added foo.txt
Empty file.
4 changes: 1 addition & 3 deletions script/bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ echo "===> Building the Docker image..."
docker-compose build

echo "===> Setting up the database on the Docker image..."
docker-compose run --rm web bundle exec rake db:reset RAILS_ENV=development
docker-compose run --rm web bundle exec rails db:environment:set RAILS_ENV=test
docker-compose run --rm web bundle exec rake db:reset RAILS_ENV=test
docker-compose run --rm web bundle exec rake db:create
docker-compose run --rm web pg_restore -c --no-owner -d ohana_api_development /ohana-api/data/ohana_api_development.dump -U postgres -h db

echo "===> Starting the Docker image..."
Expand Down