Skip to content

Commit 45daf67

Browse files
committed
Cleanup setup and update dependencies
1 parent 1515046 commit 45daf67

17 files changed

+65
-240
lines changed

.env.docker

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
RAILS_PORT=3001
22
REDIS_URL=redis://localhost:6389/1
33
DB_HOST=db
4-
DB_PORT=5432
4+
DB_PORT=5442
55
APPSIGNAL_PUSH_API_KEY=
6+
RAILS_LOG_TO_STDOUT=true

.env.example

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# You can leave those as defaults
22
RAILS_PORT=3001
3-
REDIS_URL=redis://localhost:6379/1
3+
REDIS_URL=redis://localhost:6389/1
44
DB_HOST=localhost
5-
DB_PORT=5432
5+
DB_PORT=5442
6+
7+
# This helps with ruby on macOS
68
OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
79

810
# You need to set those

.ruby-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.1.4
1+
3.3.0

Dockerfile

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
# Make sure it matches the Ruby version in .ruby-version and Gemfile
2-
ARG RUBY_VERSION=3.1.4
3-
FROM ruby:$RUBY_VERSION
2+
ARG RUBY_VERSION=3.3.0
3+
FROM ruby:$RUBY_VERSION-alpine
44

55
# Install libvips for Active Storage preview support
6-
RUN apt-get update -qq && \
7-
apt-get install -y build-essential libvips nodejs && \
8-
apt-get clean && \
9-
rm -rf /var/lib/apt/lists/* /usr/share/doc /usr/share/man
6+
RUN apk add --no-cache --update nodejs npm build-base vips-dev libpq postgresql-dev gcompat tzdata
107

118
# Rails app lives here
12-
WORKDIR /app
9+
#WORKDIR /app
1310

1411
# Set production environment
1512
ENV RAILS_LOG_TO_STDOUT="1" \
@@ -30,10 +27,8 @@ RUN mkdir -p /rails/log
3027
# Precompiling assets for production without requiring secret RAILS_MASTER_KEY
3128
RUN bundle exec rails assets:precompile
3229

33-
# Entrypoint prepares the database.
34-
RUN chmod +x /app/bin/docker-entrypoint
35-
ENTRYPOINT ["/app/bin/docker-entrypoint"]
30+
WORKDIR /app
3631

3732
# Start the server by default, this can be overwritten at runtime
38-
EXPOSE 3000
39-
CMD ["./bin/rails", "server"]
33+
EXPOSE 3001
34+
CMD ["./bin/rails", "server", "-b", "0.0.0.0", "-p", "3001"]

Gemfile

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,11 @@
11
source 'https://rubygems.org'
22

3-
ruby '~> 3.1.4'
3+
ruby '~> 3.3.0'
44

5-
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main'
6-
gem 'rails', '~> 6.1.7'
7-
# Use postgresql as the database for Active Record
5+
gem 'rails', '~> 6.1.7', '>= 6.1.7.6'
86
gem 'pg', '~> 1.1'
9-
# Use Puma as the app server
107
gem 'puma', '~> 5.0'
11-
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
12-
# gem 'jbuilder', '~> 2.7'
13-
# Use Redis adapter to run Action Cable in production
148
gem 'redis', '~> 4.0'
15-
# Use Active Model has_secure_password
16-
# gem 'bcrypt', '~> 3.1.7'
17-
18-
# Use Active Storage variant
19-
# gem 'image_processing', '~> 1.2'
209
gem 'faker', '~> 2.18.0'
2110

2211
gem 'faraday', '~> 1.4.3'
@@ -27,7 +16,6 @@ gem 'appsignal', '~> 3.5.3'
2716

2817
gem "jquery-rails"
2918
gem "non-stupid-digest-assets"
30-
gem "react-rails" # https://github.com/reactjs/react-rails
3119
gem "sass-rails"
3220
gem "uglifier"
3321
gem "geocoder"

Gemfile.lock

Lines changed: 29 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -69,24 +69,19 @@ GEM
6969
minitest (>= 5.1)
7070
tzinfo (~> 2.0)
7171
zeitwerk (~> 2.3)
72-
appsignal (3.5.3)
72+
appsignal (3.5.6)
7373
rack
74-
babel-source (5.8.35)
75-
babel-transpiler (0.7.0)
76-
babel-source (>= 4.0, < 6)
77-
execjs (~> 2.0)
7874
bootstrap-kaminari-views (0.0.5)
7975
kaminari (>= 0.13)
8076
rails (>= 3.1)
8177
builder (3.2.4)
8278
concurrent-ruby (1.2.3)
83-
connection_pool (2.4.1)
8479
crass (1.0.6)
8580
date (3.3.4)
86-
debug (1.9.1)
81+
debug (1.9.2)
8782
irb (~> 1.10)
8883
reline (>= 0.3.8)
89-
diff-lcs (1.5.0)
84+
diff-lcs (1.5.1)
9085
dotenv (3.1.0)
9186
dotenv-rails (3.1.0)
9287
dotenv (= 3.1.0)
@@ -119,8 +114,8 @@ GEM
119114
activesupport (>= 6.1)
120115
i18n (1.14.4)
121116
concurrent-ruby (~> 1.0)
122-
io-console (0.7.1)
123-
irb (1.11.1)
117+
io-console (0.7.2)
118+
irb (1.12.0)
124119
rdoc
125120
reline (>= 0.4.2)
126121
jquery-rails (4.6.0)
@@ -139,7 +134,7 @@ GEM
139134
activerecord
140135
kaminari-core (= 1.2.2)
141136
kaminari-core (1.2.2)
142-
listen (3.8.0)
137+
listen (3.9.0)
143138
rb-fsevent (~> 0.10, >= 0.10.3)
144139
rb-inotify (~> 0.9, >= 0.9.10)
145140
loofah (2.22.0)
@@ -154,36 +149,36 @@ GEM
154149
method_source (1.0.0)
155150
mini_mime (1.1.5)
156151
minitest (5.22.3)
157-
multipart-post (2.3.0)
152+
multipart-post (2.4.0)
158153
net-imap (0.4.10)
159154
date
160155
net-protocol
161156
net-pop (0.1.2)
162157
net-protocol
163158
net-protocol (0.2.2)
164159
timeout
165-
net-smtp (0.4.0.1)
160+
net-smtp (0.5.0)
166161
net-protocol
167-
nio4r (2.7.0)
168-
nokogiri (1.16.2-aarch64-linux)
162+
nio4r (2.7.1)
163+
nokogiri (1.16.3-aarch64-linux)
169164
racc (~> 1.4)
170-
nokogiri (1.16.2-arm64-darwin)
165+
nokogiri (1.16.3-arm64-darwin)
171166
racc (~> 1.4)
172-
nokogiri (1.16.2-x86_64-darwin)
167+
nokogiri (1.16.3-x86_64-darwin)
173168
racc (~> 1.4)
174-
nokogiri (1.16.2-x86_64-linux)
169+
nokogiri (1.16.3-x86_64-linux)
175170
racc (~> 1.4)
176-
non-stupid-digest-assets (1.0.10)
171+
non-stupid-digest-assets (1.0.11)
177172
sprockets (>= 2.0)
178-
pg (1.5.4)
179-
pghero (3.4.0)
173+
pg (1.5.6)
174+
pghero (3.4.1)
180175
activerecord (>= 6)
181176
psych (5.1.2)
182177
stringio
183178
puma (5.6.8)
184179
nio4r (~> 2.0)
185180
racc (1.7.3)
186-
rack (2.2.8.1)
181+
rack (2.2.9)
187182
rack-test (2.1.0)
188183
rack (>= 1.3)
189184
rails (6.1.7.7)
@@ -214,29 +209,23 @@ GEM
214209
method_source
215210
rake (>= 12.2)
216211
thor (~> 1.0)
217-
rake (13.1.0)
212+
rake (13.2.1)
218213
rb-fsevent (0.11.2)
219214
rb-inotify (0.10.1)
220215
ffi (~> 1.0)
221216
rdoc (6.6.3.1)
222217
psych (>= 4.0.0)
223-
react-rails (3.2.0)
224-
babel-transpiler (>= 0.7.0)
225-
connection_pool
226-
execjs
227-
railties (>= 3.2)
228-
tilt
229218
redis (4.8.1)
230-
reline (0.4.2)
219+
reline (0.5.1)
231220
io-console (~> 0.5)
232-
rspec-core (3.12.2)
233-
rspec-support (~> 3.12.0)
234-
rspec-expectations (3.12.3)
221+
rspec-core (3.13.0)
222+
rspec-support (~> 3.13.0)
223+
rspec-expectations (3.13.0)
235224
diff-lcs (>= 1.2.0, < 2.0)
236-
rspec-support (~> 3.12.0)
237-
rspec-mocks (3.12.6)
225+
rspec-support (~> 3.13.0)
226+
rspec-mocks (3.13.0)
238227
diff-lcs (>= 1.2.0, < 2.0)
239-
rspec-support (~> 3.12.0)
228+
rspec-support (~> 3.13.0)
240229
rspec-rails (5.0.3)
241230
actionpack (>= 5.2)
242231
activesupport (>= 5.2)
@@ -245,7 +234,7 @@ GEM
245234
rspec-expectations (~> 3.10)
246235
rspec-mocks (~> 3.10)
247236
rspec-support (~> 3.10)
248-
rspec-support (3.12.1)
237+
rspec-support (3.13.1)
249238
ruby2_keywords (0.0.5)
250239
sass-rails (6.0.0)
251240
sassc-rails (~> 2.1, >= 2.1.1)
@@ -281,6 +270,7 @@ PLATFORMS
281270
aarch64-linux
282271
arm64-darwin-21
283272
arm64-darwin-22
273+
arm64-darwin-23
284274
x86_64-darwin-21
285275
x86_64-darwin-23
286276
x86_64-linux
@@ -301,17 +291,16 @@ DEPENDENCIES
301291
pg (~> 1.1)
302292
pghero
303293
puma (~> 5.0)
304-
rails (~> 6.1.7)
294+
rails (~> 6.1.7, >= 6.1.7.6)
305295
rails-assets-bootswatch-sass (< 4.0.0)!
306296
rails-assets-jquery!
307-
react-rails
308297
redis (~> 4.0)
309298
rspec-rails (~> 5.0.0)
310299
sass-rails
311300
uglifier
312301

313302
RUBY VERSION
314-
ruby 3.1.4p223
303+
ruby 3.3.0p0
315304

316305
BUNDLED WITH
317306
2.3.3

README.md

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,6 @@
88
- Create account on https://appsignal.com
99
- APPSIGNAL_PUSH_API_KEY should be set in your env for configuration scripts to pick them up
1010

11-
**Important note for users of MacBooks:**
12-
13-
When you see error
14-
```
15-
objc[18501]: +[__NSCFConstantString initialize] may have been in progress in another thread when fork() was called.
16-
objc[18501]: +[__NSCFConstantString initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.
17-
```
18-
19-
Please set OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES in your env
20-
21-
```
22-
export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
23-
```
24-
2511
## Setup
2612

2713
1. Create account on https://appsignal.com and set as an environment variable "APPSIGNAL_PUSH_API_KEY"
@@ -37,19 +23,6 @@ export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
3723
docker-compose up
3824
```
3925

40-
## Setup the Local Environment
41-
42-
1. Install Ruby 3.1.4.
43-
44-
1. Install PostgreSQL. Application was tested with PostgreSQL 16.0
45-
46-
1. Install Redis
47-
48-
1. Install gems
49-
```ruby
50-
bundle install
51-
```
52-
5326
1. Copy `.env.example` to `.env` and update ports based on your setup.
5427
```ruby
5528
cp .env.example .env

app/models/pet.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ class Pet < ApplicationRecord
2828
near([city[:latitude], city[:longitude]], distance, unit: :km)
2929
end
3030

31+
scope :random, -> { order("RANDOM()") }
32+
3133
enum pet_type: { dog: 0, cat: 1 }
3234
enum gender: { male: 0, female: 1, unknown: 2 }
3335
enum size: { small: 0, medium: 1, large: 2, extra_large: 3 }
@@ -47,15 +49,15 @@ def image_url(width: 100, height: 100)
4749
end
4850

4951
def similar_type_pets
50-
Pet.where("id != ?", id).where(pet_type: pet_type).order("random()")
52+
Pet.where.not(id: id).where(pet_type: pet_type).random
5153
end
5254

5355
def similiar_name_pets
5456
first_name = name.split(" ").first
5557
last_name = name.split(" ").last
56-
Pet.where("id != ?", id).where("name ILIKE ?", "%#{last_name}%").or(
57-
Pet.where("id != ?", id).where("name ILIKE ?", "%#{first_name}%")
58-
).order("random()")
58+
Pet.where.not(id: id).where("name ILIKE ?", "%#{last_name}%").or(
59+
Pet.where.not(id: id).where("name ILIKE ?", "%#{first_name}%")
60+
).random
5961
end
6062

6163
def tagline

config/database.yml

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,10 @@
1-
# PostgreSQL. Versions 9.3 and up are supported.
2-
#
3-
# Install the pg driver:
4-
# gem install pg
5-
# On macOS with Homebrew:
6-
# gem install pg -- --with-pg-config=/usr/local/bin/pg_config
7-
# On macOS 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.
13-
#
14-
# Configure Using Gemfile
15-
# gem 'pg'
16-
#
171
default: &default
182
adapter: postgresql
193
encoding: unicode
204
host: <%= ENV.fetch("DB_HOST") { "db" } %>
215
username: postgres
226
password: postgres
7+
238
# For details on connection pooling, see Rails configuration guide
249
# https://guides.rubyonrails.org/configuring.html#database-pooling
2510
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>

0 commit comments

Comments
 (0)