Skip to content

Commit 956c288

Browse files
committed
creating API with rails version 8
0 parents  commit 956c288

File tree

1,507 files changed

+1540
-0
lines changed

Some content is hidden

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

1,507 files changed

+1540
-0
lines changed

Dockerfile

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# syntax = docker/dockerfile:1
2+
3+
# Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile
4+
ARG RUBY_VERSION=3.2.2
5+
FROM registry.docker.com/library/ruby:$RUBY_VERSION-slim as base
6+
7+
# Rails app lives here
8+
WORKDIR /rails
9+
10+
# Set production environment
11+
ENV RAILS_ENV="production" \
12+
BUNDLE_DEPLOYMENT="1" \
13+
BUNDLE_PATH="/usr/local/bundle" \
14+
BUNDLE_WITHOUT="development"
15+
16+
17+
# Throw-away build stage to reduce size of final image
18+
FROM base as build
19+
20+
# Install packages needed to build gems
21+
RUN apt-get update -qq && \
22+
apt-get install --no-install-recommends -y build-essential git libpq-dev libvips pkg-config
23+
24+
# Install application gems
25+
COPY Gemfile Gemfile.lock ./
26+
RUN bundle install && \
27+
rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git && \
28+
bundle exec bootsnap precompile --gemfile
29+
30+
# Copy application code
31+
COPY . .
32+
33+
# Precompile bootsnap code for faster boot times
34+
RUN bundle exec bootsnap precompile app/ lib/
35+
36+
# Precompiling assets for production without requiring secret RAILS_MASTER_KEY
37+
RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile
38+
39+
40+
# Final stage for app image
41+
FROM base
42+
43+
# Install packages needed for deployment
44+
RUN apt-get update -qq && \
45+
apt-get install --no-install-recommends -y curl libvips postgresql-client && \
46+
rm -rf /var/lib/apt/lists /var/cache/apt/archives
47+
48+
# Copy built artifacts: gems, application
49+
COPY --from=build /usr/local/bundle /usr/local/bundle
50+
COPY --from=build /rails /rails
51+
52+
# Run and own only the runtime files as a non-root user for security
53+
RUN useradd rails --create-home --shell /bin/bash && \
54+
chown -R rails:rails db log storage tmp
55+
USER rails:rails
56+
57+
# Entrypoint prepares the database.
58+
ENTRYPOINT ["/rails/bin/docker-entrypoint"]
59+
60+
# Start the server by default, this can be overwritten at runtime
61+
EXPOSE 3000
62+
CMD ["./bin/rails", "server"]

Gemfile

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
source "https://rubygems.org"
2+
3+
ruby "3.2.2"
4+
5+
# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
6+
gem "rails", "~> 7.1.3", ">= 7.1.3.2"
7+
8+
# The original asset pipeline for Rails [https://github.com/rails/sprockets-rails]
9+
gem "sprockets-rails"
10+
11+
# Use postgresql as the database for Active Record
12+
gem "pg", "~> 1.1"
13+
14+
# Use the Puma web server [https://github.com/puma/puma]
15+
gem "puma", ">= 5.0"
16+
17+
# Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails]
18+
gem "importmap-rails"
19+
20+
# Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev]
21+
gem "turbo-rails"
22+
23+
# Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev]
24+
gem "stimulus-rails"
25+
26+
# Use Tailwind CSS [https://github.com/rails/tailwindcss-rails]
27+
gem "tailwindcss-rails"
28+
29+
# Build JSON APIs with ease [https://github.com/rails/jbuilder]
30+
gem "jbuilder"
31+
32+
# Use Redis adapter to run Action Cable in production
33+
# gem "redis", ">= 4.0.1"
34+
35+
# Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis]
36+
# gem "kredis"
37+
38+
# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]
39+
# gem "bcrypt", "~> 3.1.7"
40+
41+
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
42+
gem "tzinfo-data", platforms: %i[ windows jruby ]
43+
44+
# Reduces boot times through caching; required in config/boot.rb
45+
gem "bootsnap", require: false
46+
47+
# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
48+
# gem "image_processing", "~> 1.2"
49+
50+
group :development, :test do
51+
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
52+
gem "debug", platforms: %i[ mri windows ]
53+
end
54+
55+
group :development do
56+
# Use console on exceptions pages [https://github.com/rails/web-console]
57+
gem "web-console"
58+
59+
# Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler]
60+
# gem "rack-mini-profiler"
61+
62+
# Speed up commands on slow machines / big apps [https://github.com/rails/spring]
63+
# gem "spring"
64+
end
65+

0 commit comments

Comments
 (0)