Skip to content

Commit 349e56d

Browse files
committed
Migrate BT host app files and configuration to the Engine and dummy app.
Ensure as close as possible match betwen Engine dev env and real-world use cases
1 parent abdcb97 commit 349e56d

29 files changed

+880
-143
lines changed

.dokku/predeploy

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
bundle install
3+
bundle exec rails db:migrate

.dokku/release.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
3+
# Exit immediately if a command exits with a non-zero status.
4+
set -e
5+
6+
# Ensure Sentry CLI is installed
7+
if ! command -v sentry-cli &> /dev/null
8+
then
9+
echo "sentry-cli could not be found, please install it."
10+
exit 1
11+
fi
12+
13+
# Set the release version
14+
RELEASE_VERSION=$(git rev-parse --short HEAD)
15+
16+
# Export the release version as an environment variable
17+
export SENTRY_RELEASE=$RELEASE_VERSION
18+
19+
# Notify Sentry of the new release
20+
sentry-cli releases new $SENTRY_RELEASE
21+
sentry-cli releases finalize $SENTRY_RELEASE
22+
23+
echo "Sentry release $SENTRY_RELEASE has been set."
24+
25+
# Run any pending migrations (if needed)
26+
bundle exec rails db:migrate
27+
28+
echo "Release step completed."

.dokku/web.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# release.sh
2+
#!/bin/bash
3+
set -e
4+
5+
mkdir -p tmp/pids
6+
bundle exec puma -C config/puma.rb

.env.sample

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
ALLOWED_HOSTS='http://localhost:3001'
2+
APP_HOST='http://localhost:3001'
3+
ASSET_HOST=
4+
AWS_ACCESS_KEY_ID=
5+
AWS_SECRET_ACCESS_KEY=
6+
BASE_URL='http://localhost:3001'
7+
CDN_DISTRIBUTION_ID=
8+
DATABASE_URL='postgres://postgres:postgres@better-together-db:5435/better_together_production'
9+
FOG_DIRECTORY=
10+
FOG_HOST=
11+
FOG_REGION='ca-central-1'
12+
GIT_REV=
13+
LANG='en_US.UTF-8'
14+
PORT='5000'
15+
RACK_ENV='production'
16+
RAILS_ENV='production'
17+
RAILS_LOG_LEVEL='debug'
18+
RAILS_LOG_TO_STDOUT='true'
19+
RAILS_SERVE_STATIC_FILES='true'
20+
REDIS_URL='redis://better-together-redis:6379'
21+
S3_BUCKET_NAME=
22+
S3_REGION=
23+
SECRET_KEY_BASE=
24+
SENTRY_DSN=
25+
SMTP_PASSWORD=
26+
SMTP_USERNAME='apikey'
27+
SMTP_address='smtp.sendgrid.net'

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,6 @@ node_modules/
5252

5353
spec/dummy/storage/og/9g/og9gmixuxfbx1sl5rgk6brbjmvms
5454
spec/dummy/storage/va/ri/variants/og9gmixuxfbx1sl5rgk6brbjmvms/6e7b83b26e6f33c216f6d559f3b939a455b14b656f2fc1797c3cfcef371301b5
55-
spec/dummy/storage/*
55+
spec/dummy/storage/*
56+
.env.dev
57+
.env.prod

Dockerfile

Lines changed: 72 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,81 @@
1+
# Stage 1: Build environment
2+
FROM ruby:3.2.2 AS builder
13

2-
FROM ruby:3.2.2
4+
# Define build-time variables
5+
ARG AWS_ACCESS_KEY_ID
6+
ARG AWS_SECRET_ACCESS_KEY
7+
ARG FOG_DIRECTORY
8+
ARG FOG_HOST
9+
ARG FOG_REGION
10+
ARG ASSET_HOST
11+
ARG CDN_DISTRIBUTION_ID
12+
13+
# Set environment variables for asset precompilation
14+
ENV AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
15+
ENV AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
16+
ENV FOG_DIRECTORY=${FOG_DIRECTORY}
17+
ENV FOG_HOST=${FOG_HOST}
18+
ENV FOG_REGION=${FOG_REGION}
19+
ENV ASSET_HOST=${ASSET_HOST}
20+
ENV CDN_DISTRIBUTION_ID=${CDN_DISTRIBUTION_ID}
321

22+
# Install dependencies
423
RUN apt-get update -qq \
5-
&& apt-get install -y build-essential postgresql-client libpq-dev nodejs libssl-dev apt-transport-https ca-certificates libvips42
24+
&& apt-get install -y --no-install-recommends \
25+
build-essential \
26+
postgresql-client \
27+
libpq-dev \
28+
nodejs \
29+
libssl-dev \
30+
apt-transport-https \
31+
ca-certificates \
32+
libvips42 \
33+
curl
34+
35+
# Set working directory
36+
WORKDIR /community-engine
37+
38+
# Copy Gemfile and Gemfile.lock
39+
COPY Gemfile Gemfile.lock ./
40+
41+
# Install bundler and gems
42+
RUN gem uninstall bundler \
43+
&& gem install bundler:2.4.13 \
44+
&& bundle install --jobs 4 --retry 3
645

7-
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
8-
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
46+
# Copy the rest of the application code
47+
COPY . .
948

10-
RUN apt-get update -qq && apt-get install -y yarn
49+
# Precompile assets and sync to S3
50+
RUN bundle exec rake assets:precompile
1151

12-
RUN mkdir /community-engine
52+
# Stage 2: Runtime environment
53+
FROM ruby:3.2.2
54+
55+
# Install runtime dependencies
56+
RUN apt-get update -qq \
57+
&& apt-get install -y --no-install-recommends \
58+
libpq-dev \
59+
nodejs \
60+
libssl-dev \
61+
libvips42 \
62+
curl \
63+
&& curl -sL https://sentry.io/get-cli/ | bash \
64+
&& rm -rf /var/lib/apt/lists/*
65+
66+
# Set working directory
1367
WORKDIR /community-engine
14-
COPY Gemfile /community-engine/Gemfile
15-
COPY Gemfile.lock /community-engine/Gemfile.lock
1668

17-
RUN gem uninstall bundler
18-
RUN gem install bundler:2.4.13
69+
# Copy the application code from the build stage
70+
COPY --from=builder /community-engine /community-engine
71+
72+
# Create and set permissions for tmp/pids directory
73+
RUN mkdir -p tmp/pids
74+
RUN chmod -R 755 tmp
75+
76+
# Set environment variables
77+
ENV RAILS_ENV=production
78+
ENV RACK_ENV=production
1979

20-
COPY . /community-engine
80+
# Run the application
81+
CMD ["bundle", "exec", "puma", "-C", "config/puma.rb"]

Dockerfile.dev

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM ruby:3.2.2
2+
3+
RUN apt-get update -qq \
4+
&& apt-get install -y build-essential postgresql-client libpq-dev nodejs libssl-dev apt-transport-https ca-certificates libvips42
5+
6+
RUN mkdir /community-engine
7+
WORKDIR /community-engine
8+
COPY Gemfile /community-engine/Gemfile
9+
COPY Gemfile.lock /community-engine/Gemfile.lock
10+
11+
RUN gem uninstall bundler
12+
RUN gem install bundler:2.4.13
13+
14+
COPY . /community-engine

Dockerfile.old

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
FROM ruby:3.2.2
3+
4+
RUN apt-get update -qq \
5+
&& apt-get install -y build-essential postgresql-client libpq-dev nodejs libssl-dev apt-transport-https ca-certificates libvips42
6+
7+
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
8+
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
9+
10+
RUN apt-get update -qq && apt-get install -y yarn
11+
12+
RUN mkdir /community-engine
13+
WORKDIR /community-engine
14+
COPY Gemfile /community-engine/Gemfile
15+
COPY Gemfile.lock /community-engine/Gemfile.lock
16+
17+
RUN gem uninstall bundler
18+
RUN gem install bundler:2.4.13
19+
20+
COPY . /community-engine

Gemfile

Lines changed: 85 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,47 +3,108 @@
33
source 'https://rubygems.org'
44
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
55

6+
ruby '3.2.2'
7+
68
gemspec
79

8-
gem 'pundit-resources',
9-
github: 'better-together-org/pundit-resources'
10+
gem 'asset_sync'
11+
gem 'aws-sdk-s3', require: false
1012

11-
group :development do
13+
# bcrypt for secure password handling
14+
gem 'bcrypt', '~> 3.1.20'
15+
# Bootsnap for faster boot times
16+
gem 'bootsnap', '>= 1.7.0', require: false
17+
18+
gem 'fog-aws'
19+
20+
# Database adapter for PostgreSQL
21+
gem 'pg', '>= 0.18', '< 2.0'
22+
# Puma as the app server
23+
gem 'puma', '~> 6.4'
24+
25+
# Pundit for authorization, custom fork for Better Together
26+
gem 'pundit-resources', '~> 1.1.4', github: 'better-together-org/pundit-resources'
27+
28+
# Core Rails gem
29+
gem 'rack-protection'
30+
gem 'rails', '~> 7.0.8'
31+
32+
# Redis for ActionCable and background jobs
33+
gem 'redis', '~> 5.2'
34+
# Sidekiq for background processing
35+
gem 'sidekiq', '~> 7.2.4'
36+
37+
# Error and performance monitoring with Sentry
38+
gem 'sentry-rails'
39+
gem 'sentry-ruby'
40+
gem 'stackprof'
41+
42+
# Uglifier for JavaScript compression
43+
gem 'uglifier', '>= 1.3.0'
44+
45+
group :development, :test do
46+
# Better errors for enhanced error pages
1247
gem 'better_errors'
48+
# Binding of caller provides pry console at breakpoints
1349
gem 'binding_of_caller'
14-
gem 'execjs'
15-
gem 'listen'
16-
gem 'pg'
17-
gem 'puma', '~> 6.0'
18-
gem 'rack-mini-profiler'
19-
gem 'rb-readline'
20-
gem 'rbtrace'
50+
# Debugger tool
51+
gem 'byebug', platforms: %i[mri mingw x64_mingw]
52+
# Faker for generating fake data
53+
gem 'faker'
54+
# FactoryBot for setting up test data
55+
gem 'factory_bot_rails'
56+
# Fuubar for fancy test progress bar
57+
gem 'fuubar'
58+
# Pry for a powerful shell alternative to IRB
59+
gem 'pry'
60+
gem 'rswag'
61+
# RuboCop for static code analysis
2162
gem 'rubocop'
22-
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
23-
gem 'spring'
24-
gem 'spring-watcher-listen', '~> 2.1.0'
25-
gem 'web-console', '>= 3.3.0'
2663
end
2764

28-
group :development, :test do
65+
group :development do
66+
# Brakeman for static analysis security vulnerability scanning
2967
gem 'brakeman', require: false
68+
# Bundler audit for checking gem vulnerabilities
3069
gem 'bundler-audit', require: false
31-
gem 'byebug'
32-
gem 'factory_bot_rails'
33-
gem 'faker'
34-
gem 'pry'
35-
gem 'rswag'
70+
# Listen for file system changes
71+
gem 'listen', '>= 3.0.5', '< 3.10'
72+
# Rack mini profiler for performance profiling
73+
gem 'rack-mini-profiler'
74+
# Readline implementation for Ruby
75+
gem 'rb-readline'
76+
# Spring for fast Rails actions via pre-loading
77+
gem 'spring'
78+
# Spring watcher for file changes
79+
gem 'spring-watcher-listen', '~> 2.1.0'
80+
# Tracing tool
81+
gem 'rbtrace'
82+
# Web-console for an interactive console on exception pages
83+
gem 'web-console', '>= 3.3.0'
3684
end
3785

3886
group :test do
39-
# gem 'capybara'
40-
# gem 'chromedriver-helper'
87+
# Capybara for integration testing
88+
gem 'capybara', '>= 2.15'
89+
# Coveralls for test coverage reporting
4190
gem 'coveralls'
91+
# Database cleaner for test database cleaning
92+
gem 'database_cleaner'
4293
gem 'database_cleaner-active_record'
43-
gem 'fuubar'
94+
# # Easy installation and use of chromedriver to run system tests with Chrome
95+
gem 'webdrivers'
96+
# RuboCop RSpec for RSpec-specific code analysis
97+
gem 'rubocop-rspec'
98+
# RSpec for unit testing
99+
gem 'rspec'
100+
# RSpec Rails integration
44101
gem 'rspec-rails'
102+
# Selenium WebDriver for browser automation
103+
gem 'selenium-webdriver'
104+
# Shoulda Callback Matchers for testing callbacks
45105
gem 'shoulda-callback-matchers'
106+
# Shoulda Matchers for simplifying model tests
46107
gem 'shoulda-matchers'
108+
# SimpleCov for test coverage analysis
47109
gem 'simplecov', require: false
48-
# gem 'selenium-webdriver'
49110
end

0 commit comments

Comments
 (0)