Compare commits

...

5 Commits

Author SHA1 Message Date
Ivaylo Markov 428bfb9639 Make Postgres default since SQLite doesn't work anymore 2020-11-14 20:02:08 +02:00
Ivaylo Markov d718850253 Add instructions for using Docker Compose 2020-11-05 21:14:15 +02:00
Ivaylo Markov 5ba2709a8e Add example conference on DB seed 2020-11-05 21:13:32 +02:00
Ivaylo Markov 6386ae6db9 Add Docker Compose file 2020-11-05 21:13:09 +02:00
Ivaylo Markov 6bbd39dc23 Make DB configurable with environment variables 2020-11-05 21:12:42 +02:00
9 changed files with 76 additions and 28 deletions

1
.gitignore vendored
View File

@ -14,7 +14,6 @@
# Ignore all logfiles and tempfiles. # Ignore all logfiles and tempfiles.
/log/*.log /log/*.log
/tmp /tmp
/config/database.yml
/config/secrets.yml /config/secrets.yml
/db/schema.rb /db/schema.rb
/erd.pdf /erd.pdf

View File

@ -8,4 +8,14 @@ Installation
1. `git clone https://github.com/ignisf/clarion.git` 1. `git clone https://github.com/ignisf/clarion.git`
2. Run `bundle install; bin/rake bootstrap` 2. Run `bundle install; bin/rake bootstrap`
3. You can now run the rails server with `bin/rails s` 3. You can now run the rails server with `bin/rails s`
Usage with Docker
-----------------
Requires [Docker](https://www.docker.com/) and [Docker Compose](https://docs.docker.com/compose/).
1. Run `git clone https://github.com/ignisf/clarion.git`.
2. Run `docker-compose up --build --detach`.
3. Add `127.0.0.1 clarion.openfest.test` to your system's host file.
4. Open http://clarion.openfest.test:3000/management in your browser and log in with username `foo@example.com` and password `123qweASD`.

View File

@ -20,10 +20,15 @@ default: &default
# For details on connection pooling, see Rails configuration guide # For details on connection pooling, see Rails configuration guide
# http://guides.rubyonrails.org/configuring.html#database-pooling # http://guides.rubyonrails.org/configuring.html#database-pooling
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
database: <%= ENV.fetch("POSTGRES_DB") { "clarion" } %>
username: <%= ENV.fetch("POSTGRES_USER") { "clarion" } %>
password: <%= ENV["POSTGRES_PASSWORD"] %>
host: <%= ENV.fetch("POSTGRES_HOST") { "localhost" } %>
port: <%= ENV.fetch("POSTGRES_PORT") { 5432 } %>
development: development:
<<: *default <<: *default
database: clarion_development database: <%= ENV.fetch("POSTGRES_DB") { "clarion_development" } %>
# The specified database role being used to connect to postgres. # The specified database role being used to connect to postgres.
# To create additional roles in postgres see `$ createuser --help`. # To create additional roles in postgres see `$ createuser --help`.

View File

@ -1,25 +0,0 @@
# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
#
default: &default
adapter: sqlite3
pool: 5
timeout: 5000
development:
<<: *default
database: db/development.sqlite3
# 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: db/test.sqlite3
production:
<<: *default
database: db/production.sqlite3

View File

@ -10,3 +10,13 @@ User.create(email: "foo@example.com",
password_confirmation: "123qweASD", password_confirmation: "123qweASD",
confirmed_at: Time.current, confirmed_at: Time.current,
admin: true) admin: true)
Conference.create(
title: "TestFest",
email: "foo@example.com",
host_name: "clarion.openfest.test",
description: "Test Conference",
start_date: Date.today,
end_date: Date.today,
planned_cfp_end_date: Date.today.prev_day
)

27
docker-compose.yml Normal file
View File

@ -0,0 +1,27 @@
version: '3.7'
services:
app:
build:
context: ./docker/app
depends_on:
- db
env_file:
- "./docker/dev.env"
volumes:
- ./:/clarion
environment:
- BUNDLE_PATH=./vendor
working_dir: "/clarion"
command: "./docker/app/run.sh"
ports:
- 127.0.0.1:3000:3000
db:
image: postgres:11.9
volumes:
- clarion-db:/var/lib/postgresql/data
env_file:
- "./docker/dev.env"
volumes:
clarion-db:

3
docker/app/Dockerfile Normal file
View File

@ -0,0 +1,3 @@
FROM ruby:2.6.5
RUN apt-get update && apt-get install -y postgresql-client

13
docker/app/run.sh Executable file
View File

@ -0,0 +1,13 @@
#!/bin/sh
# Install dependencies
bundle install
# DB migrations
./bin/rails db:create
./bin/rails db:migrate
./bin/rails db:seed
# Remove leftover PID file from non-clean exit
rm tmp/pids/server.pid
./bin/rails server --binding=0.0.0.0

6
docker/dev.env Normal file
View File

@ -0,0 +1,6 @@
RAILS_ENV=development
POSTGRES_HOST=db
POSTGRES_USER=clarion
POSTGRES_PASSWORD=clarion
POSTGRES_DB=clarion