Giter VIP home page Giter VIP logo

rails-on-ecs's Introduction

test lint build License: MIT

日本語 | Jpanese

rails-on-ecs

Example code for Ruby on Rails with AWS ECS.

Terraform Repository: reireias/rails-on-ecs-terraform

Tips

Image builds

GitHub Actions are used to build images.

You can use docker/build-push-action to describe image build and push in a concise way.

The implementation uses multi-stage build like the implementation in Dockerfile.

In addition to the final image, the builder stage also pushes the ECR, which can be used as a cache for the next build by specifying the --cache-from option.

      # cache-from is the image of the previous builder stage
      - name: Build and Push
        uses: docker/build-push-action@v2
        env:
          ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
        with:
          push: true
          cache-from: |{ steps.login-ecr.outputs.registry }} with: push: true
            type=registry,ref=${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:builder
          tags: |
            ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ github.sha }}
            ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:latest

      # Save the builder image for this time
      - name: Save builder cache
        uses: docker/build-push-action@v2
        env:
          ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
        with:
          target: builder
          push: true
          build-args: |
            BUILDKIT_INLINE_CACHE=1
          tags: |{ env.
            ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:builder

health check

You can use the okcomputer gem to set up health checks in a simple way.

By accessing /health_checks/all, you can also perform health checks on additional specified DBs, etc. This is very useful for checking communication and investigating failures.

Load from environment variables

The following are read from environment variables to avoid tight coupling with specific infrastructure.

  • Database connection information: DATABASE_URL.
  • Database connection information (read replica): READER_DATABASE_URL.

Also, RAILS_MASTER_KEY is set as an environment variable for secure management of confidential information.

rails-on-ecs's People

Contributors

reireias avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.