Skip to content

Commit

Permalink
Initial commit to add postgres dependency and database configs
Browse files Browse the repository at this point in the history
  • Loading branch information
syed-ali-tw committed Feb 25, 2025
1 parent 374de00 commit 7b2874a
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ RUN rails assets:precompile && rm -fr log node_modules

FROM --platform=$TARGETPLATFORM $base_image

ENV GOVUK_APP_NAME=publisher
ENV GOVUK_APP_NAME=publisher-on-pg

WORKDIR $APP_HOME
COPY --from=builder $BUNDLE_PATH $BUNDLE_PATH
COPY --from=builder $BOOTSNAP_CACHE_DIR $BOOTSNAP_CACHE_DIR
COPY --from=builder $APP_HOME .

RUN chown -R app:app app
USER app
CMD ["puma"]
5 changes: 5 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ gem "strip_attributes"
gem "terser"
gem "whenever", require: false

# postgres dependencies
gem "pg"
gem "state_machines-activerecord"
gem "database_cleaner-active_record"

group :test do
gem "capybara-select-2"
gem "ci_reporter_minitest"
Expand Down
10 changes: 10 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ GEM
dartsass-rails (0.5.1)
railties (>= 6.0.0)
sass-embedded (~> 1.63)
database_cleaner-active_record (2.2.0)
activerecord (>= 5.a)
database_cleaner-core (~> 2.0.0)
database_cleaner-core (2.0.1)
database_cleaner-mongoid (2.0.1)
database_cleaner-core (~> 2.0.0)
Expand Down Expand Up @@ -642,6 +645,7 @@ GEM
parser (3.3.7.0)
ast (~> 2.4.1)
racc
pg (1.5.9)
plek (5.2.0)
pp (0.6.2)
prettyprint
Expand Down Expand Up @@ -835,6 +839,9 @@ GEM
state_machines-activemodel (0.9.0)
activemodel (>= 6.0)
state_machines (>= 0.6.0)
state_machines-activerecord (0.9.0)
activerecord (>= 6.0)
state_machines-activemodel (>= 0.9.0)
state_machines-graphviz (0.0.2)
ruby-graphviz
state_machines
Expand Down Expand Up @@ -891,6 +898,7 @@ DEPENDENCIES
ci_reporter_minitest
climate_control
dartsass-rails
database_cleaner-active_record
database_cleaner-mongoid
diffy
erb_lint
Expand Down Expand Up @@ -924,6 +932,7 @@ DEPENDENCIES
mousetrap-rails
nested_form!
null_logger
pg
plek
prometheus-client
pry-byebug
Expand All @@ -940,6 +949,7 @@ DEPENDENCIES
simplecov
sprockets-rails
state_machines
state_machines-activerecord
state_machines-graphviz
state_machines-mongoid
strip_attributes
Expand Down
40 changes: 40 additions & 0 deletions config/database.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# This file is overwritten by one in alphagov-deployment at deploy time
default: &default
adapter: postgresql
encoding: utf8
pool: 12
template: template0

development:
<<: *default
database: publisher_development
username: publisher
password: publisher
clients:
default:
uri: <%= "postgresql://postgres@postgres-13/publisher" %>
options:
# use_activesupport_time_zone: true
# belongs_to_required_by_default: false

test:
<<: *default
clients:
default:
uri: <%= "postgresql://postgres@postgres-13/publisher" %>
options:
read:
mode: :primary
max_pool_size: 1
options:
# use_activesupport_time_zone: true
# belongs_to_required_by_default: false

# set these environment variables on your prod server
production:
clients:
default:
uri: <%= ENV['MONGODB_URI'] %>
options:
# use_activesupport_time_zone: true
# belongs_to_required_by_default: false
2 changes: 1 addition & 1 deletion config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@

# Enable DNS rebinding protection and other `Host` header attacks.
config.hosts = [
/publisher\..*\.gov.uk/,
/publisher-on-pg\..*\.gov.uk/,
]

# Skip DNS rebinding protection for the default health check endpoint.
Expand Down

0 comments on commit 7b2874a

Please sign in to comment.