# Terminal bundle replace rails bundle add mrsk mrsk init bundle lock --add-platform aarch64-linux bundle lock --add-platform x86_64-linux bin/rails credentials:edit mrsk app assist mrsk server bootstrap mrsk deploy mrsk app logs mrsk app logs --help mrsk app logs -n 1000
# Gemfile gem "rails", github: "rails/rails", department: "major" gem "mrsk", "~> 0.8.4"
# config/environments/manufacturing.rb config.public_file_server.enabled = true # Can be utilized along with config.force_ssl for Strict-Transport-Safety and safe cookies. config.assume_ssl = true logger = ActiveSupport::Logger.new(STDOUT) logger.formatter = config.log_formatter config.logger = ActiveSupport::TaggedLogging.new(logger)
# config/software.rb config.load_defaults 7.1
# .gitignore .env
# .env MRSK_REGISTRY_PASSWORD=change-this RAILS_MASTER_KEY=another-env
# Dockerfile # syntax = docker/dockerfile:1 # Be sure that it matches the Ruby model in .ruby-version and Gemfile ARG RUBY_VERSION=3.2.1 FROM ruby:$RUBY_VERSION-slim as base # Rails app lives right here WORKDIR /rails # Set manufacturing setting ENV RAILS_ENV="manufacturing" BUNDLE_DEPLOYMENT="1" BUNDLE_PATH="/usr/native/bundle" BUNDLE_WITHOUT="improvement" # Throw-away construct stage to scale back dimension of ultimate picture FROM base as construct # Set up packages must construct gems and node modules RUN apt-get replace -qq && apt-get set up -y build-essential curl default-libmysqlclient-dev git libpq-dev libvips node-gyp pkg-config python-is-python3 # Set up JavaScript dependencies ARG NODE_VERSION=19.7.0 ARG YARN_VERSION=1.22.19 ENV PATH=/usr/native/node/bin:$PATH RUN curl -sL https://github.com/nodenv/node-build/archive/grasp.tar.gz | tar xz -C /tmp/ && /tmp/node-build-master/bin/node-build "${NODE_VERSION}" /usr/native/node && npm set up -g yarn@$YARN_VERSION && rm -rf /tmp/node-build-master # Set up software gems COPY --link Gemfile Gemfile.lock ./ RUN bundle set up && rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git && bundle exec bootsnap precompile --gemfile # Set up node modules COPY --link bundle.json yarn.lock ./ RUN yarn set up --frozen-lockfile # Copy software code COPY --link . . # Precompile bootsnap code for sooner boot occasions RUN bundle exec bootsnap precompile app/ lib/ # Precompiling property for manufacturing with out requiring secret RAILS_MASTER_KEY RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails property:precompile # Last stage for app picture FROM base RUN apt-get replace -qq && apt-get set up --no-install-recommends -y default-mysql-client libsqlite3-0 libvips postgresql-client && rm -rf /var/lib/apt/lists /var/cache/apt/archives # Run and personal the appliance recordsdata as a non-root person for safety RUN useradd rails USER rails:rails # Copy constructed artifacts: gems, software COPY --from=construct --chown=rails:rails /usr/native/bundle /usr/native/bundle COPY --from=construct --chown=rails:rails /rails /rails # Entrypoint prepares the database. ENTRYPOINT ["/rails/bin/docker-entrypoint"] # Begin the server by default, this may be overwritten at runtime EXPOSE 3000 CMD ["./bin/rails", "server"]
# bin/docker-entrypoint #!/bin/bash -e # If operating the rails server then create or migrate current database if [ "${*}" == "./bin/rails server" ]; then ./bin/rails db:put together fi exec "${@}"
# config/deploy.yml # Identify of your software. Used to uniquely configure containers. service: drexample # Identify of the container picture. picture: kobaltz/drexample # Deploy to those servers. servers: - 68.183.134.186 - 68.183.134.85 # Credentials in your picture host. registry: # Specify the registry server, when you're not utilizing Docker Hub # server: registry.digitalocean.com / ghcr.io / ... username: kobaltz password: - MRSK_REGISTRY_PASSWORD # Inject ENV variables into containers (secrets and techniques come from .env). env: secret: - RAILS_MASTER_KEY # Name a broadcast command on deploys. # audit_broadcast_cmd: # bin/broadcast_to_bc # Use a distinct ssh person than root # ssh: # person: app # Configure builder setup. # builder: # args: # RUBY_VERSION: 3.2.0 # secrets and techniques: # - GITHUB_TOKEN # distant: # arch: amd64 # host: ssh://app@192.168.0.1 # Use accent providers (secrets and techniques come from .env). # equipment: # db: # picture: mysql:8.0 # host: 192.168.0.2 # port: 3306 # env: # clear: # MYSQL_ROOT_HOST: '%' # secret: # - MYSQL_ROOT_PASSWORD # recordsdata: # - config/mysql/manufacturing.cnf:/and so forth/mysql/my.cnf # - db/manufacturing.sql.erb:/docker-entrypoint-initdb.d/setup.sql # directories: # - knowledge:/var/lib/mysql # redis: # picture: redis:7.0 # host: 192.168.0.2 # port: 6379 # directories: # - knowledge:/knowledge # Configure customized arguments for Traefik # traefik: # args: # accesslog: true # accesslog.format: json # Configure a customized healthcheck (default is /up on port 3000) # healthcheck: # path: /healthz # port: 4000
# config/database.yml manufacturing: <<: *default url: <%= Rails.software.credentials.database_url %>
# credentials file database_url: postgres://username:password@host:port/databasename