Skip to content

Commit 6f97431

Browse files
committed
improvements to dummy app
1 parent 349e56d commit 6f97431

File tree

14 files changed

+168
-36
lines changed

14 files changed

+168
-36
lines changed

.dokku/web.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
#!/bin/bash
33
set -e
44

5-
mkdir -p tmp/pids
6-
bundle exec puma -C config/puma.rb
5+
mkdir -p spec/dummy/tmp/pids
6+
bash -c "rm -f spec/dummy/tmp/pids/server.pid && cd ./spec/dummy && bundle exec puma -C config/puma.rb"

Dockerfile

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ RUN apt-get update -qq \
3636
WORKDIR /community-engine
3737

3838
# Copy Gemfile and Gemfile.lock
39-
COPY Gemfile Gemfile.lock ./
39+
COPY Gemfile Gemfile.lock better_together.gemspec ./
40+
41+
COPY lib lib
4042

4143
# Install bundler and gems
4244
RUN gem uninstall bundler \
@@ -47,7 +49,8 @@ RUN gem uninstall bundler \
4749
COPY . .
4850

4951
# Precompile assets and sync to S3
50-
RUN bundle exec rake assets:precompile
52+
RUN bundle exec rake app:assets:precompile
53+
RUN bundle exec rake app:assets:sync
5154

5255
# Stage 2: Runtime environment
5356
FROM ruby:3.2.2
@@ -69,13 +72,13 @@ WORKDIR /community-engine
6972
# Copy the application code from the build stage
7073
COPY --from=builder /community-engine /community-engine
7174

72-
# Create and set permissions for tmp/pids directory
73-
RUN mkdir -p tmp/pids
74-
RUN chmod -R 755 tmp
75+
# Create and set permissions for spec/dummy/tmp/pids directory
76+
RUN mkdir -p spec/dummy/tmp/pids
77+
RUN chmod -R 755 spec/dummy/tmp
7578

7679
# Set environment variables
7780
ENV RAILS_ENV=production
7881
ENV RACK_ENV=production
7982

8083
# Run the application
81-
CMD ["bundle", "exec", "puma", "-C", "config/puma.rb"]
84+
CMD ["./spec/dummy","bundle", "exec", "puma", "-C", "config/puma.rb"]

Gemfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ gem 'rails', '~> 7.0.8'
3131

3232
# Redis for ActionCable and background jobs
3333
gem 'redis', '~> 5.2'
34+
35+
gem 'rswag'
36+
3437
# Sidekiq for background processing
3538
gem 'sidekiq', '~> 7.2.4'
3639

@@ -57,7 +60,6 @@ group :development, :test do
5760
gem 'fuubar'
5861
# Pry for a powerful shell alternative to IRB
5962
gem 'pry'
60-
gem 'rswag'
6163
# RuboCop for static code analysis
6264
gem 'rubocop'
6365
end

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ GEM
167167
regexp_parser (>= 1.5, < 3.0)
168168
xpath (~> 3.2)
169169
coderay (1.1.3)
170-
concurrent-ruby (1.3.2)
170+
concurrent-ruby (1.3.3)
171171
connection_pool (2.4.1)
172172
coveralls (0.7.1)
173173
multi_json (~> 1.3)

docker-compose.prod.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: '3.6'
22

33
volumes:
44
community-engine-bundler-gems:
5-
community-engine-db-data:
5+
community-engine-db-data-prod:
66
community-engine-redis:
77

88
x-env-info: &env-info
@@ -16,6 +16,7 @@ x-app-shared: &app-shared
1616
services:
1717
app: &app
1818
<<: *app-shared
19+
container_name: community-engine-app
1920
build: # "context" and "dockerfile" fields have to be under "build"
2021
args:
2122
AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID}
@@ -30,4 +31,10 @@ services:
3031
command: bash -c "rm -f spec/dummy/tmp/pids/server.pid && cd ./spec/dummy && bundle exec puma -C config/puma.rb"
3132
ports:
3233
- '5000:5000'
34+
db:
35+
<<: *env-info
36+
volumes:
37+
- community-engine-db-data-prod:/var/lib/postgresql/data
3338

39+
sidekiq:
40+
<<: *app-shared

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ services:
4242
sidekiq:
4343
<<: *app-shared
4444
container_name: community-engine-sidekiq
45-
command: bundle exec sidekiq -C config/sidekiq.yml
45+
command: bash -c "rm -f spec/dummy/tmp/pids/server.pid && cd ./spec/dummy && bundle exec sidekiq -C config/sidekiq.yml"
4646
depends_on:
4747
- app
4848

spec/dummy/config/cable.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
development:
2+
adapter: async
3+
4+
test:
5+
adapter: test
6+
7+
production:
8+
adapter: redis
9+
url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
10+
channel_prefix: better_together_production

spec/dummy/config/database.yml

Lines changed: 45 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,64 @@
1-
# MySQL. Versions 5.1.10 and up are supported.
1+
# PostgreSQL. Versions 9.1 and up are supported.
22
#
3-
# Install the MySQL driver
4-
# gem install mysql2
3+
# Install the pg driver:
4+
# gem install pg
5+
# On OS X with Homebrew:
6+
# gem install pg -- --with-pg-config=/usr/local/bin/pg_config
7+
# On OS X with MacPorts:
8+
# gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
9+
# On Windows:
10+
# gem install pg
11+
# Choose the win32 build.
12+
# Install PostgreSQL and put its /bin directory on your path.
513
#
6-
# Ensure the MySQL gem is defined in your Gemfile
7-
# gem 'mysql2'
14+
# Configure Using Gemfile
15+
# gem 'pg'
816
#
9-
# And be sure to use new-style password hashing:
10-
# https://dev.mysql.com/doc/refman/5.7/en/password-hashing.html
11-
#
12-
1317
default: &default
1418
adapter: postgis
1519
encoding: unicode
16-
# host: localhost
17-
host: db
18-
username: <%= ENV['POSTGRES_USER'] %>
19-
password: <%= ENV['POSTGRES_PASSWORD'] %>
2020
# For details on connection pooling, see Rails configuration guide
2121
# http://guides.rubyonrails.org/configuring.html#database-pooling
2222
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
23+
url: <%= ENV.fetch("DATABASE_URL") { 'postgres://postgres:postgres@community-engine-db' } %>
2324

2425
development:
2526
<<: *default
26-
database: community-engine_dummy_development
27+
database: community_engine_development
28+
29+
# The specified database role being used to connect to postgres.
30+
# To create additional roles in postgres see `$ createuser --help`.
31+
# When left blank, postgres will use the default role. This is
32+
# the same name as the operating system user that initialized the database.
33+
#username: community_engine
34+
35+
# The password associated with the postgres role (username).
36+
#password:
37+
38+
# Connect on a TCP socket. Omitted by default since the client uses a
39+
# domain socket that doesn't need configuration. Windows does not have
40+
# domain sockets, so uncomment these lines.
41+
#host: localhost
42+
43+
# The TCP port the server listens on. Defaults to 5432.
44+
# If your server runs on a different port number, change accordingly.
45+
#port: 5432
46+
47+
# Schema search path. The server defaults to $user,public
48+
#schema_search_path: myapp,sharedapp,public
49+
50+
# Minimum log levels, in increasing order:
51+
# debug5, debug4, debug3, debug2, debug1,
52+
# log, notice, warning, error, fatal, and panic
53+
# Defaults to warning.
54+
#min_messages: notice
2755

2856
# Warning: The database defined as "test" will be erased and
2957
# re-generated from your development database when you run "rake".
3058
# Do not set this db to the same as development or production.
3159
test:
3260
<<: *default
33-
database: community-engine_dummy_test
61+
database: community_engine_test
3462

3563
# As with config/secrets.yml, you never want to store sensitive information,
3664
# like your database password, in your source code. If your source code is
@@ -44,7 +72,7 @@ test:
4472
# On Heroku and other platform providers, you may have a full connection URL
4573
# available as an environment variable. For example:
4674
#
47-
# DATABASE_URL="mysql2://myuser:mypass@localhost/somedatabase"
75+
# DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase"
4876
#
4977
# You can use this database configuration with:
5078
#
@@ -53,6 +81,4 @@ test:
5381
#
5482
production:
5583
<<: *default
56-
database: community-engine_dummy_production
57-
username: dummy
58-
password: <%= ENV['BETTER_TOGETHER_DATABASE_PASSWORD'] %>
84+
url: <%= ENV['DATABASE_URL'] %>

spec/dummy/config/environments/development.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@
6565
# yet still be able to expire them through the digest params.
6666
config.assets.digest = true
6767

68+
config.sass.inline_source_maps = true
69+
6870
# Raises error for missing translations.
6971
# config.i18n.raise_on_missing_translations = true
7072

spec/dummy/config/environments/production.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@
3030
# config.assets.css_compressor = :sass
3131

3232
# Do not fallback to assets pipeline if a precompiled asset is missed.
33-
config.assets.compile = true
33+
config.assets.compile = false
3434
config.assets.digest = true
3535
config.assets.enabled = true
36+
config.assets.initialize_on_precompile = true
3637

3738
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
3839
config.asset_host = ENV.fetch('ASSET_HOST')

0 commit comments

Comments
 (0)