Skip to content

Commit

Permalink
DBP-830 Revert some changes
Browse files Browse the repository at this point in the history
  • Loading branch information
simoncolincap committed Sep 11, 2024
1 parent c4de7ee commit cee2d39
Show file tree
Hide file tree
Showing 26 changed files with 150 additions and 171 deletions.
48 changes: 21 additions & 27 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Base stage with common dependencies
FROM alpine:3.17 AS base
FROM alpine:3.17 AS alpine

ARG RAILS_ROOT=/usr/src/app
ENV RAILS_ROOT=${RAILS_ROOT}
WORKDIR $RAILS_ROOT

FROM alpine AS base
WORKDIR $RAILS_ROOT
RUN apk add --no-cache \
libpq \
libxml2 \
Expand All @@ -18,11 +18,7 @@ RUN apk add --no-cache \
bash \
shared-mime-info



# Builder stage for installing build dependencies
FROM base AS builder

FROM base as builder
RUN apk add --no-cache \
build-base \
curl-dev \
Expand All @@ -35,24 +31,17 @@ RUN apk add --no-cache \
nodejs \
yarn \
yaml-dev \
zlib-dev



zlib-dev \
&& ( echo 'install: --no-document' ; echo 'update: --no-document' ) >>/etc/gemrc
COPY Gemfile* ./

RUN bundle lock --add-platform x86_64-linux-musl
RUN bundle config build.nokogiri --use-system-libraries \
&& bundle config set --local deployment 'true' --without 'development test' \
&& bundle install -j4 \
&& bundle config set --local deployment 'true' without 'development:test'
RUN bundle install --deployment -j4 \
&& yarn install

RUN rm -rf vendor/bundle/ruby/*/cache
COPY . ./

# Final stage
FROM base

# Ensure development dependencies are installed
RUN apk add --no-cache \
build-base \
curl-dev \
Expand All @@ -64,18 +53,23 @@ RUN apk add --no-cache \
nodejs \
yarn \
yaml-dev \
zlib-dev

COPY --from=builder $RAILS_ROOT $RAILS_ROOT
RUN chmod +x ./bin/start
zlib-dev \
&& ( echo 'install: --no-document' ; echo 'update: --no-document' ) >>/etc/gemrc
#USER greenlight:greenlight

# Set environment variables
ARG RAILS_ENV
ENV RAILS_ENV=${RAILS_ENV:-development}
ENV RAILS_ENV=${RAILS_ENV:-production}
ARG RAILS_LOG_TO_STDOUT
ENV RAILS_LOG_TO_STDOUT=${RAILS_LOG_TO_STDOUT:-true}

ARG VERSION_CODE
ENV VERSION_CODE=$VERSION_CODE

RUN pwd
COPY --from=builder $RAILS_ROOT $RAILS_ROOT
RUN ls -al

EXPOSE 3000
CMD ["bash", "-c", "./bin/start"]
CMD [ "./bin/start" ]
#ENTRYPOINT [ "./bin/start" ]

4 changes: 2 additions & 2 deletions Procfile.dev
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
web: ruby bin/rails server -p $PORT
web: bin/rails server -p $PORT
js: yarn build:development
css: yarn build:development:css --watch
css: yarn build:development:css --watch
6 changes: 3 additions & 3 deletions app/assets/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@
"default_role_description": "Standard-Rolle, die neuen Nutzer:innen zugeteilt wird",
"registration_method": "Registrierungs-Methode",
"registration_method_description": "Registrierungs-Methoden ändern",
"registration_methods": {
"registration_methods" : {
"open": "Offene Registrierung",
"invite": "Per Einladung teilnehmen",
"approval": "Zulassen/Ablehnen"
Expand Down Expand Up @@ -529,8 +529,8 @@
"room_join": {
"fields": {
"name": {
"label": "Name",
"placeholder": "Namen eingeben"
"label": "Name",
"placeholder": "Namen eingeben"
},
"access_code": {
"label": "Zugangscode",
Expand Down
6 changes: 3 additions & 3 deletions app/assets/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@
"default_role_description": "The default role to be assigned to newly created users",
"registration_method": "Registration Method",
"registration_method_description": "Change the way that users register to the website",
"registration_methods": {
"registration_methods" : {
"open": "Open Registration",
"invite": "Join by Invitation",
"approval": "Approve/Decline"
Expand Down Expand Up @@ -534,8 +534,8 @@
"room_join": {
"fields": {
"name": {
"label": "Name",
"placeholder": "Enter your name"
"label": "Name",
"placeholder": "Enter your name"
},
"access_code": {
"label": "Access Code",
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def current_user

# Returns whether hcaptcha is enabled by checking if ENV variables are set
def hcaptcha_enabled?
ENV['HCAPTCHA_SITE_KEY'].present? && ENV['HCAPTCHA_SECRET_KEY'].present?
(ENV['HCAPTCHA_SITE_KEY'].present? && ENV['HCAPTCHA_SECRET_KEY'].present?)
end

# Returns the current provider value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,13 @@ export default function UserSignupForm({ handleClose }) {
<FormControl field={fields.password} type="password" />
<FormControl field={fields.password_confirmation} type="password" />


<Stack className="mt-1" direction="horizontal" gap={1}>
<Button variant="neutral" className="ms-auto" onClick={handleClose}>
{t('close')}
</Button>
<Button variant="brand" type="submit" disabled={createUserAPI.isLoading}>
{createUserAPI.isLoading && <Spinner className="me-2" />}
{t('admin.manage_users.create_account')}
{ createUserAPI.isLoading && <Spinner className="me-2" /> }
{ t('admin.manage_users.create_account') }
</Button>
</Stack>
</Form>
Expand Down
6 changes: 3 additions & 3 deletions app/models/recording.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def self.search(input)
input: "%#{input}%").includes(:formats)
end

includes(:formats)
all.includes(:formats)
end

def self.public_search(input)
Expand All @@ -55,7 +55,7 @@ def self.public_search(input)
input: "%#{input}%").includes(:formats)
end

includes(:formats)
all.includes(:formats)
end

def self.server_search(input)
Expand All @@ -68,7 +68,7 @@ def self.server_search(input)
.includes(:formats)
end

includes(:formats)
all.includes(:formats)
end

private
Expand Down
2 changes: 1 addition & 1 deletion app/models/role.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def self.search(input)
def create_role_permissions
return if %w[Administrator User Guest SuperAdmin].include? name # skip creation for default roles

Permission.find_each do |permission|
Permission.all.find_each do |permission|
value = case permission.name
when 'CreateRoom', 'SharedList', 'CanRecord'
'true'
Expand Down
10 changes: 5 additions & 5 deletions app/models/room.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def get_setting(name:)
def create_meeting_options
configs = RoomsConfiguration.joins(:meeting_option).where(provider: user.provider).pluck(:name, :value).to_h

MeetingOption.find_each do |option|
MeetingOption.all.find_each do |option|
value = if %w[true default_enabled].include? configs[option.name]
option.true_value
else
Expand Down Expand Up @@ -103,10 +103,10 @@ def set_meeting_id

# Create unique pin for voice brige max 10^5 - 10000 unique ids
def set_voice_brige
unless Rails.application.config.voice_bridge_phone_number.nil?
id = SecureRandom.random_number(10.pow(5) - 1)
raise if Room.exists?(voice_bridge: id) || id < 10_000

if Rails.application.config.voice_bridge_phone_number != nil
id = SecureRandom.random_number((10.pow(5)) - 1)
raise if Room.exists?(voice_bridge: id) || id < 10000
self.voice_bridge = id
end
rescue StandardError
Expand Down
3 changes: 1 addition & 2 deletions app/services/meeting_starter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ def initialize(room:, base_url:, current_user:, provider:)

def call
# TODO: amir - Check the legitimately of the action.
options = RoomSettingsGetter.new(room_id: @room.id, provider: @room.user.provider, current_user: @current_user, only_bbb_options: true,
voice_bridge: @room.voice_bridge).call
options = RoomSettingsGetter.new(room_id: @room.id, provider: @room.user.provider, current_user: @current_user, only_bbb_options: true, voice_bridge: @room.voice_bridge).call
viewer_code = RoomSettingsGetter.new(
room_id: @room.id,
provider: @room.user.provider,
Expand Down
6 changes: 3 additions & 3 deletions app/services/room_settings_getter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ def infer_can_record(room_settings:)
end

def set_voice_brige(room_settings:)
return if @voice_bridge.nil?

room_settings['voiceBridge'] = @voice_bridge.to_s
if @voice_bridge != nil
room_settings['voiceBridge'] = "#{@voice_bridge}"
end
end
end
5 changes: 3 additions & 2 deletions bin/dev
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#!/usr/bin/env bash

if [ -f .env ]; then
export $(echo $(cat .env | sed 's/#.*//g' | xargs) | envsubst)
export $(echo $(cat .env | sed 's/#.*//g'| xargs) | envsubst)
fi
export PORT="${PORT:=3000}"
echo "Web app starting on port: $PORT"

if ! command -v foreman &>/dev/null; then
if ! command -v foreman &> /dev/null
then
echo "Installing foreman..."
gem install foreman
fi
Expand Down
14 changes: 8 additions & 6 deletions bin/start
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,21 @@ echo "Redis host: $RDHOST"
echo "Redis port: $RDPORT"

if [ "$RAILS_ENV" = "production" ]; then
while ! nc -zw3 $PGHOST $PGPORT; do
while ! nc -zw3 $PGHOST $PGPORT
do
echo "Waiting for postgres to start up ..."
sleep 1
done

while ! nc -zw3 $RDHOST $RDPORT; do
while ! nc -zw3 $RDHOST $RDPORT
do
echo "Waiting for redis to start up ..."
sleep 1
done
fi

./bin/rails assets:precompile
./bin/rails db:create
./bin/rails db:migrate:with_data
rails assets:precompile
rails db:create
rails db:migrate:with_data

exec ./bin/rails s -b 0.0.0.0 -p $PORT
exec rails s -b 0.0.0.0 -p $PORT
1 change: 0 additions & 1 deletion config/initializers/content_security_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
# with Greenlight; if not, see <http://www.gnu.org/licenses/>.

# frozen_string_literal: true

# Be sure to restart your server when you modify this file.

# Define an application-wide content security policy
Expand Down
1 change: 0 additions & 1 deletion config/initializers/inflections.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
# with Greenlight; if not, see <http://www.gnu.org/licenses/>.

# frozen_string_literal: true

# Be sure to restart your server when you modify this file.

# Add new inflection rules using the following format. Inflections
Expand Down
1 change: 0 additions & 1 deletion config/initializers/permissions_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
# with Greenlight; if not, see <http://www.gnu.org/licenses/>.

# frozen_string_literal: true

# Define an application-wide HTTP permissions policy. For further
# information see https://developers.google.com/web/updates/2018/06/feature-policy
#
Expand Down
2 changes: 1 addition & 1 deletion config/locales/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@ de:
link_expires: Der Link wird in 1 Stunde ungültig.
ignore_request: "Wenn du dein Passwort nicht ändern wolltest, dann ignoriere bitte diese E-Mail."
room:
new_room_name: "%{username}'s Raum"
new_room_name: "%{username}'s Raum"
24 changes: 16 additions & 8 deletions db/data/20230328124724_populate_voice_brige_for_existing_rooms.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,28 @@

class PopulateVoiceBrigeForExistingRooms < ActiveRecord::Migration[7.0]
def up
return if Rails.application.config.voice_bridge_phone_number.nil?
if Rails.application.config.voice_bridge_phone_number == nil
return
end

raise 'The db contains to many rooms to assign each one a unique voice_bridge' if Room.all.length > 89_999
if Room.all.length > 89999
raise "The db contains to many rooms to assign each one a unique voice_bridge"
end

Room.where(voice_bridge: nil).find_each do |room|
id = SecureRandom.random_number(10.pow(5) - 1)
Room.where(voice_bridge: nil).each do |room|
id = SecureRandom.random_number((10.pow(5)) - 1)

id += 10_000 if id < 10_000
if id < 10000
id = id + 10000
end

while Room.exists?(voice_bridge: id)
id += 1
id = 10_000 if id >= 99_999
id = id + 1
if id >= 99999
id = 10000
end
end

room.update(voice_bridge: id)
end
end
Expand Down
2 changes: 1 addition & 1 deletion db/data/20231030185844_lowercase_emails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class LowercaseEmails < ActiveRecord::Migration[7.1]
def up
User.find_each(batch_size: 250) do |user|
User.all.find_each(batch_size: 250) do |user|
downcase = user.email.downcase
next if user.email == downcase

Expand Down
2 changes: 1 addition & 1 deletion db/data/20231117151542_add_email_on_sign_up_permission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def up

values = [{ role: admin, permission: email_permission, value: 'true' }]

Role.where.not(name: 'Administrator').find_each do |role|
Role.where.not(name: 'Administrator').each do |role|
values.push({ role:, permission: email_permission, value: 'false' })
end

Expand Down
Loading

0 comments on commit cee2d39

Please sign in to comment.