diff --git a/.github/workflows/deploy_fly.yml b/.github/workflows/deploy_fly.yml index d8b681a..ef28a9f 100644 --- a/.github/workflows/deploy_fly.yml +++ b/.github/workflows/deploy_fly.yml @@ -4,17 +4,27 @@ on: branches: - main - develop + - chore/30-setup-cicd jobs: deploy: name: Deploy app runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - + - uses: superfly/flyctl-actions/setup-flyctl@master - name: Build Docker image run: bin/docker-prepare && docker compose build - - - uses: superfly/flyctl-actions/setup-flyctl@master - run: flyctl deploy env: FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} + DOCKER_REGISTRY_HOST: ${{ vars.DOCKER_REGISTRY_HOST }} + DOCKER_REGISTRY_USERNAME: ${{ github.repository_owner }} + DOCKER_REGISTRY_TOKEN: ${{ secrets.GITHUB_TOKEN }} + DOCKER_IMAGE: ${{ vars.DOCKER_IMAGE }} + BRANCH_TAG: ${{ vars.BRANCH_TAG }} + PORT: ${{ vars.PORT }} + BUILD_ENV: 'production' + NODE_ENV: 'production' + RUBY_ENV: 'production' + DEPLOYED_HOST: '.fly.dev' + RAILS_SERVE_STATIC_FILES: true diff --git a/.github/workflows/test_production_build.yml b/.github/workflows/test_production_build.yml index a28249d..a90ea61 100644 --- a/.github/workflows/test_production_build.yml +++ b/.github/workflows/test_production_build.yml @@ -10,7 +10,7 @@ on: env: DOCKER_REGISTRY_HOST: ${{ secrets.DOCKER_REGISTRY_HOST }} DOCKER_IMAGE: ${{ github.repository }} - PORT: ${{secrets.PORT}} + PORT: ${{vars.PORT}} concurrency: group: ${{ github.workflow }}-${{ github.ref }} diff --git a/config/environments/development.rb b/config/environments/development.rb index 3e23e5f..aa0affa 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -33,6 +33,9 @@ config.cache_store = :null_store end + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = true + # Store uploaded files on the local file system (see config/storage.yml for options). config.active_storage.service = :local diff --git a/config/environments/production.rb b/config/environments/production.rb index 7aa4ce2..e1cac0c 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -13,7 +13,7 @@ config.eager_load = true # Full error reports are disabled and caching is turned on. - config.consider_all_requests_local = false + config.consider_all_requests_local = true config.action_controller.perform_caching = true # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] @@ -28,7 +28,7 @@ # config.assets.css_compressor = :sass # Do not fallback to assets pipeline if a precompiled asset is missed. - config.assets.compile = false + config.assets.compile = true # Enable serving of images, stylesheets, and JavaScripts from an asset server. # config.asset_host = "http://assets.example.com" @@ -98,5 +98,6 @@ # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false - config.hosts << ENV['DEPLOYED_HOST'] + config.hosts << '.fly.io' + config.host_authorization = { exclude: ->(_) { true } } end diff --git a/fly.toml b/fly.toml index 26b93ee..bd2ff1c 100644 --- a/fly.toml +++ b/fly.toml @@ -1,4 +1,4 @@ -# fly.toml app configuration file generated for google-scrapper-ruby on 2023-05-18T11:25:54+07:00 +# fly.toml app configuration file generated for google-scrapper-ruby-prod on 2023-06-16T16:27:15+07:00 # # See https://fly.io/docs/reference/configuration/ for information about how to use this file. # @@ -7,16 +7,28 @@ app = "google-scrapper-ruby" primary_region = "sin" console_command = "/rails/bin/rails console" +[env] + RAILS_ENV = "production" + MAILER_DEFAULT_HOST = "localhost" + MAILER_DEFAULT_PORT = "25" + MAILER_SENDER = "Test " + AVAILABLE_LOCALES = "en" + DEFAULT_LOCALE = "en" + FALLBACK_LOCALES = "en" + RAILS_LOG_TO_STDOUT = true + DEPLOYED_HOST = '.fly.dev' + RAILS_SERVE_STATIC_FILES = true + [http_service] - internal_port = 3000 + internal_port = 80 force_https = true auto_stop_machines = true auto_start_machines = true - min_machines_running = 0 + min_machines_running = 1 [checks] [checks.status] - port = 3000 + port = 80 type = "http" interval = "10s" timeout = "2s" @@ -24,11 +36,3 @@ console_command = "/rails/bin/rails console" method = "GET" path = "/health_check" protocol = "http" - -[env] - DEPLOYED_HOST = "google-scrapper-ruby.fly.dev" - PORT = 3000 - ASSET_HOST = "" - BUILD_ENV = "production" - NODE_ENV = "production" - RUBY_ENV = "production"