Skip to content

Commit 5ad5f35

Browse files
authored
Merge pull request #17 from MoveFrequently/miguelff/batch-4
Several features and fixes
2 parents 80b63fd + 616cdee commit 5ad5f35

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1011
-37
lines changed

.dockerignore

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77
# Ignore bundler config.
88
/.bundle
99

10-
# Ignore all environment files (except templates).
10+
# Ignore all environment files.
1111
/.env*
12-
!/.env*.erb
1312

1413
# Ignore all default key files.
1514
/config/master.key
@@ -40,6 +39,10 @@
4039
# Ignore CI service files.
4140
/.github
4241

42+
# Ignore Kamal files.
43+
/config/deploy*.yml
44+
/.kamal
45+
4346
# Ignore development files
4447
/.devcontainer
4548

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ jobs:
2929
- name: Checkout code
3030
uses: actions/checkout@v4
3131

32+
- name: Install libvips
33+
run: sudo apt-get update && sudo apt-get install --no-install-recommends -y libvips
34+
3235
- name: Set up Ruby
3336
uses: ruby/setup-ruby@v1
3437
with:

Dockerfile

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,37 @@
1-
# syntax = docker/dockerfile:1
2-
3-
# This Dockerfile is designed for production, not development. Use with Kamal or build'n'run by hand:
4-
# docker build -t my-app .
5-
# docker run -d -p 80:80 -p 443:443 --name my-app -e RAILS_MASTER_KEY=<value from config/master.key> my-app
1+
# syntax=docker/dockerfile:1
2+
# check=error=true
63

74
# Make sure RUBY_VERSION matches the Ruby version in .ruby-version
85
ARG RUBY_VERSION=3.3.5
9-
FROM docker.io/library/ruby:$RUBY_VERSION-slim AS base
6+
FROM ruby:$RUBY_VERSION-slim AS base
7+
8+
LABEL fly_launch_runtime="rails"
109

1110
# Rails app lives here
1211
WORKDIR /rails
1312

13+
# Update gems and bundler
14+
RUN gem update --system --no-document && \
15+
gem install -N bundler
16+
1417
# Install base packages
1518
RUN apt-get update -qq && \
16-
apt-get install --no-install-recommends -y curl libjemalloc2 libvips sqlite3 && \
19+
apt-get install --no-install-recommends -y curl libjemalloc2 sqlite3 libvips-dev && \
1720
rm -rf /var/lib/apt/lists /var/cache/apt/archives
1821

1922
# Set production environment
20-
ENV RAILS_ENV="production" \
21-
BUNDLE_DEPLOYMENT="1" \
23+
ENV BUNDLE_DEPLOYMENT="1" \
2224
BUNDLE_PATH="/usr/local/bundle" \
23-
BUNDLE_WITHOUT="development"
25+
BUNDLE_WITHOUT="development:test" \
26+
RAILS_ENV="production"
27+
2428

2529
# Throw-away build stage to reduce size of final image
2630
FROM base AS build
2731

2832
# Install packages needed to build gems
2933
RUN apt-get update -qq && \
30-
apt-get install --no-install-recommends -y build-essential git pkg-config && \
34+
apt-get install --no-install-recommends -y build-essential git libyaml-dev pkg-config && \
3135
rm -rf /var/lib/apt/lists /var/cache/apt/archives
3236

3337
# Install application gems
@@ -46,24 +50,28 @@ RUN bundle exec bootsnap precompile app/ lib/
4650
RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile
4751

4852

49-
50-
5153
# Final stage for app image
5254
FROM base
5355

56+
5457
# Copy built artifacts: gems, application
5558
COPY --from=build "${BUNDLE_PATH}" "${BUNDLE_PATH}"
5659
COPY --from=build /rails /rails
5760

5861
# Run and own only the runtime files as a non-root user for security
5962
RUN groupadd --system --gid 1000 rails && \
6063
useradd rails --uid 1000 --gid 1000 --create-home --shell /bin/bash && \
61-
chown -R rails:rails db log storage tmp
64+
mkdir /data && \
65+
chown -R 1000:1000 db log storage tmp /data
6266
USER 1000:1000
6367

68+
# Deployment options
69+
ENV DATABASE_URL="sqlite3:///data/production.sqlite3"
70+
6471
# Entrypoint prepares the database.
6572
ENTRYPOINT ["/rails/bin/docker-entrypoint"]
6673

6774
# Start the server by default, this can be overwritten at runtime
6875
EXPOSE 3000
76+
VOLUME /data
6977
CMD ["./bin/rails", "server"]

Gemfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ gem "httpx", "~> 1.3"
5353
gem "ostruct"
5454

5555
# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
56-
# gem "image_processing", "~> 1.2"
56+
gem "image_processing", "~> 1.2"
5757

5858
group :development, :test do
5959
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
@@ -95,3 +95,6 @@ gem "redis", "~> 5.3"
9595

9696
gem "sentry-ruby"
9797
gem "sentry-rails"
98+
99+
gem "aws-sdk-s3", "~> 1.177", require: false
100+
gem "ruby-vips"

Gemfile.lock

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,22 @@ GEM
103103
addressable (2.8.7)
104104
public_suffix (>= 2.0.2, < 7.0)
105105
ast (2.4.2)
106+
aws-eventstream (1.3.0)
107+
aws-partitions (1.1037.0)
108+
aws-sdk-core (3.215.1)
109+
aws-eventstream (~> 1, >= 1.3.0)
110+
aws-partitions (~> 1, >= 1.992.0)
111+
aws-sigv4 (~> 1.9)
112+
jmespath (~> 1, >= 1.6.1)
113+
aws-sdk-kms (1.96.0)
114+
aws-sdk-core (~> 3, >= 3.210.0)
115+
aws-sigv4 (~> 1.5)
116+
aws-sdk-s3 (1.177.0)
117+
aws-sdk-core (~> 3, >= 3.210.0)
118+
aws-sdk-kms (~> 1)
119+
aws-sigv4 (~> 1.5)
120+
aws-sigv4 (1.11.0)
121+
aws-eventstream (~> 1, >= 1.0.2)
106122
baran (0.1.12)
107123
base64 (0.2.0)
108124
benchmark (0.4.0)
@@ -180,6 +196,14 @@ GEM
180196
multipart-post (~> 2.0)
181197
faraday-net_http (3.4.0)
182198
net-http (>= 0.5.0)
199+
ffi (1.17.1-aarch64-linux-gnu)
200+
ffi (1.17.1-aarch64-linux-musl)
201+
ffi (1.17.1-arm-linux-gnu)
202+
ffi (1.17.1-arm-linux-musl)
203+
ffi (1.17.1-arm64-darwin)
204+
ffi (1.17.1-x86_64-darwin)
205+
ffi (1.17.1-x86_64-linux-gnu)
206+
ffi (1.17.1-x86_64-linux-musl)
183207
globalid (1.2.1)
184208
activesupport (>= 6.1)
185209
hashdiff (1.1.2)
@@ -189,6 +213,9 @@ GEM
189213
http-2 (>= 1.0.0)
190214
i18n (1.14.6)
191215
concurrent-ruby (~> 1.0)
216+
image_processing (1.13.0)
217+
mini_magick (>= 4.9.5, < 5)
218+
ruby-vips (>= 2.0.17, < 3)
192219
importmap-rails (2.1.0)
193220
actionpack (>= 6.0.0)
194221
activesupport (>= 6.0.0)
@@ -200,6 +227,7 @@ GEM
200227
jbuilder (2.13.0)
201228
actionview (>= 5.0.0)
202229
activesupport (>= 5.0.0)
230+
jmespath (1.6.2)
203231
json (2.9.1)
204232
json-schema (4.3.1)
205233
addressable (>= 2.8)
@@ -223,6 +251,7 @@ GEM
223251
marcel (1.0.4)
224252
matrix (0.4.2)
225253
method_source (1.1.0)
254+
mini_magick (4.13.2)
226255
mini_mime (1.1.5)
227256
minitest (5.25.4)
228257
minitest-snapshots (1.1.2)
@@ -332,6 +361,9 @@ GEM
332361
faraday (>= 1)
333362
faraday-multipart (>= 1)
334363
ruby-progressbar (1.13.0)
364+
ruby-vips (2.2.2)
365+
ffi (~> 1.12)
366+
logger
335367
rubyzip (2.4.1)
336368
securerandom (0.4.1)
337369
selenium-webdriver (4.27.0)
@@ -418,6 +450,7 @@ PLATFORMS
418450

419451
DEPENDENCIES
420452
addressable
453+
aws-sdk-s3 (~> 1.177)
421454
bootsnap
422455
brakeman
423456
capybara
@@ -430,6 +463,7 @@ DEPENDENCIES
430463
faraday-follow_redirects
431464
hashie (~> 5.0)
432465
httpx (~> 1.3)
466+
image_processing (~> 1.2)
433467
importmap-rails
434468
jbuilder
435469
langchainrb (~> 0.19.1)
@@ -441,6 +475,7 @@ DEPENDENCIES
441475
redis (~> 5.3)
442476
rubocop-rails-omakase
443477
ruby-openai (~> 7.3)
478+
ruby-vips
444479
selenium-webdriver
445480
sentry-rails
446481
sentry-ruby

0 commit comments

Comments
 (0)