This repository has been archived by the owner on Apr 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 470
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The database configuration has been extended to also support PostgreSQL as the database. This is relevant if you are using CoreOS Clair as the security scanner and you don't want to have multiple databases. In theory with this implementation we could have support for other RDBMs as well, but that would mean to add gems for each support and call `bundle`. To avoid these kinds of scenarios, we stick with just two options: with MariaDB (the currently supported option) and PostgreSQL. Signed-off-by: Miquel Sabaté Solà <msabate@suse.com>
- Loading branch information
Showing
34 changed files
with
301 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,37 @@ | ||
default: &default | ||
adapter: mysql2 | ||
encoding: utf8 | ||
<% if ENV['COMPOSE'] %> | ||
host: <%= ENV['PORTUS_DB_HOST'] %> | ||
username: root | ||
password: portus | ||
<% end %> | ||
# You could theoretically use anything for the database with this setup, but we | ||
# have decided on two choices: MariaDB (default) and PostgreSQL. In order to | ||
# support other RDBMS we would need to add them in the Gemfile and call | ||
# `bundle`, which is a burden in containerized scenarios. | ||
# | ||
# You can pick the adapter with the `PORTUS_DB_ADAPTER` environment variable | ||
# (defaults to 'mysql2'. If you want to use PostgreSQL you need to set it to | ||
# `postgresql`). | ||
# | ||
# For more documentation check: | ||
# - The `examples/development/postgresql` directory. Read the `README.md` file | ||
# for more information. | ||
# - Our mailing list: https://groups.google.com/forum/#!forum/portus-dev. | ||
|
||
development: | ||
<<: *default | ||
database: portus_development | ||
default: &default | ||
adapter: <%= ENV["PORTUS_DB_ADAPTER"] || "mysql2" %> | ||
|
||
staging: | ||
<<: *default | ||
database: portus_staging | ||
host: <%= ENV['PORTUS_DB_HOST'] || "localhost" %> | ||
username: <%= ENV['PORTUS_DB_USERNAME'] || "root" %> | ||
password: <%= ENV['PORTUS_DB_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: portus_test | ||
encoding: utf8 | ||
|
||
production: | ||
<<: *default | ||
<% if ENV["PORTUS_PRODUCTION_HOST"] %> | ||
host: <%= ENV["PORTUS_PRODUCTION_HOST"] %> | ||
<% end %> | ||
<% if ENV["PORTUS_PRODUCTION_USERNAME"] %> | ||
username: <%= ENV["PORTUS_PRODUCTION_USERNAME"] %> | ||
# Optional stuff. | ||
<% if ENV["PORTUS_DB_PORT"] %> | ||
port: <%= ENV['PORTUS_DB_PORT'] %> | ||
<% end %> | ||
<% if ENV["PORTUS_PRODUCTION_PASSWORD"] %> | ||
password: <%= ENV["PORTUS_PRODUCTION_PASSWORD"] %> | ||
<% if ENV["PORTUS_DB_POOL"] %> | ||
pool: <%= ENV['PORTUS_DB_POOL'] %> | ||
<% end %> | ||
<% if ENV["PORTUS_PRODUCTION_DATABASE"] %> | ||
database: <%= ENV["PORTUS_PRODUCTION_DATABASE"] %> | ||
<% if ENV["PORTUS_DB_TIMEOUT"] %> | ||
timeout: <%= ENV['PORTUS_DB_TIMEOUT'] %> | ||
<% end %> | ||
|
||
<%= Rails.env.downcase %>: | ||
<<: *default | ||
database: <%= ENV["PORTUS_DB_DATABASE"] || "portus_#{Rails.env.downcase}" %> |
10 changes: 8 additions & 2 deletions
10
db/migrate/20150521145620_add_fulltext_indexes_on_repositories_namespaces.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,12 @@ | ||
class AddFulltextIndexesOnRepositoriesNamespaces < ActiveRecord::Migration | ||
def change | ||
add_index :namespaces, :name, type: :fulltext, name: 'fulltext_index_namespaces_on_name' | ||
add_index :repositories, :name, type: :fulltext, name: 'fulltext_index_repositories_on_name' | ||
# This `if` statement has been added after this migration was | ||
# created. Modifying migrations is generally a *bad* idea but this will only | ||
# apply to PostgreSQL deployments that start from scratch, which haven't | ||
# been supported until now. | ||
if ENV["PORTUS_DB_ADAPTER"].blank? || ENV["PORTUS_DB_ADAPTER"] == "mysql" | ||
add_index :namespaces, :name, type: :fulltext, name: 'fulltext_index_namespaces_on_name' | ||
add_index :repositories, :name, type: :fulltext, name: 'fulltext_index_repositories_on_name' | ||
end | ||
end | ||
end |
10 changes: 10 additions & 0 deletions
10
db/migrate/20171011150408_remove_fulltext_index_repositories_on_name_index.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class RemoveFulltextIndexRepositoriesOnNameIndex < ActiveRecord::Migration | ||
def change | ||
remove_index_if_exists :repositories, "fulltext_index_repositories_on_name" | ||
remove_index_if_exists :namespaces, "fulltext_index_namespaces_on_name" | ||
end | ||
|
||
def remove_index_if_exists(table, name) | ||
remove_index table, name: name if index_exists?(table, :name, name: name) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# About this example | ||
|
||
This example runs Portus using PostgreSQL instead of MySQL. This is achieved | ||
through environment variables. You have to set `PORTUS_DB_ADAPTER` to | ||
`postgresql` so this RDBMS is picked instead of the default MYSQL adapter. | ||
|
||
## How to run this example | ||
|
||
This example is similar to the `docker-compose.yml` file from the root of the | ||
project, but using PostgreSQL. If you want to use it, perform the following | ||
commands (from the root of the project): | ||
|
||
``` | ||
$ cp examples/postgresql/docker-compose.yml docker-compose.postgres.yml | ||
$ docker-compose -f docker-compose.postgres.yml up | ||
``` | ||
|
||
## Tips for production | ||
|
||
If you want to run PostgreSQL and Portus in production, having to call `bundle` | ||
when bringing up the containers is a bad idea. Instead, create a new Docker | ||
image that derives from the [official Portus image](https://github.com/openSUSE/docker-containers/tree/master/derived_images/portus) and install the `pg` gem | ||
there. |
Oops, something went wrong.