Building and Securing Rails apps: Deploying with Docker on EC2, SSL with Cloudflare, and Domain Integration

March 22, 2024 · 993 words · 5 min · rails

Building and Securing Rails apps Create a new rails app rails new blog_app -d postgresql --skip-test Remove windows platform from Gemfile gems. bug rails 7.1 vim config/environments/production.rb set force_ssl to false and assume_ssl to true Create the Dockerfile.production # Use a multi stage build for the builderFROM--platform=$BUILDPLATFORM ruby:3.1.2 as builder# Set production environmentARG BUILDPLATFORMENV NODE_ENV=production ENV RAILS_ENV=production RUN curl -fsSL https://deb.nodesource.com/setup_16.x | bash -RUN apt-get update -qq && apt-get install -y --no-install-recommends --auto-remove nodejs imagemagick libvipsRUN npm install --global yarnWORKDIR/usr/src/appRUN yarn install --frozen-lockfile --network-timeout 1000000 && yarn cache cleanCOPY Gemfile* .