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

March 22, 2024 · 1032 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 builder FROM --platform=$BUILDPLATFORM ruby:3.1.2 as builder # Set production environment ARG BUILDPLATFORM ENV 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 libvips RUN npm install --global yarn WORKDIR /usr/src/app RUN yarn install --frozen-lockfile --network-timeout 1000000 && yarn cache clean COPY Gemfile* .