Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: chaskiq/chaskiq
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: main
Choose a base ref
...
head repository: amoniacou/chaskiq
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
Can’t automatically merge. Don’t worry, you can still create the pull request.

Commits on Jun 8, 2023

  1. speedup image build. Add support for running inside kubernetes. entry…

    …point to run it all time as user in openshift
    simonoff committed Jun 8, 2023
    Copy the full SHA
    4f8ba6e View commit details

Commits on Jun 23, 2023

  1. Merge pull request #1 from chaskiq/main

    Fix new editor empty (#955)
    simonoff authored Jun 23, 2023
    Copy the full SHA
    0ee856e View commit details

Commits on Jun 27, 2023

  1. Merge pull request #2 from chaskiq/main

    fix search predicate
    simonoff authored Jun 27, 2023
    Copy the full SHA
    1da42fd View commit details

Commits on Jul 31, 2023

  1. Merge pull request #3 from chaskiq/main

    dark mode on dropdown
    simonoff authored Jul 31, 2023
    Copy the full SHA
    349206e View commit details
  2. update deps

    simonoff committed Jul 31, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    c3eecff View commit details
  3. more kubernetes

    simonoff committed Jul 31, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    1bb254e View commit details
  4. only run docker build action

    simonoff committed Jul 31, 2023

    Unverified

    The signature in this commit could not be verified. Someone may be trying to trick you.
    Copy the full SHA
    b1670b0 View commit details
  5. set a version name

    simonoff committed Jul 31, 2023
    Copy the full SHA
    dd759db View commit details
  6. Copy the full SHA
    2f04ec8 View commit details
  7. optimize image size

    simonoff committed Jul 31, 2023
    Copy the full SHA
    f91382b View commit details
  8. also include

    simonoff committed Jul 31, 2023
    Copy the full SHA
    326c1ca View commit details

Commits on Aug 1, 2023

  1. Copy the full SHA
    5d8fbab View commit details

Commits on Aug 28, 2023

  1. Copy the full SHA
    5385e30 View commit details

Commits on Aug 29, 2023

  1. few backports from upstream

    simonoff committed Aug 29, 2023
    Copy the full SHA
    24d3ac3 View commit details
  2. update lockfile

    simonoff committed Aug 29, 2023
    Copy the full SHA
    032737c View commit details
  3. Merge pull request #4 from amoniacou/BP-1902-Chaskiq-setup

    [WIP] BP-1902 - Chaskiq setup
    simonoff authored Aug 29, 2023
    Copy the full SHA
    ec8103d View commit details

Commits on Sep 8, 2023

  1. fix uploaded links

    simonoff committed Sep 8, 2023
    Copy the full SHA
    20ec4af View commit details
  2. fix libvps

    simonoff committed Sep 8, 2023
    Copy the full SHA
    424603a View commit details

Commits on Nov 20, 2023

  1. fix ruby-vips. Upgrade rails

    simonoff committed Nov 20, 2023
    Copy the full SHA
    e8b91d6 View commit details
  2. Copy the full SHA
    237be95 View commit details
  3. fix crop

    simonoff committed Nov 20, 2023
    Copy the full SHA
    945e5c9 View commit details
  4. fix resize params

    simonoff committed Nov 20, 2023
    Copy the full SHA
    a04c3f5 View commit details
  5. Copy the full SHA
    1c15286 View commit details
  6. Copy the full SHA
    23513ab View commit details
Showing with 568 additions and 912 deletions.
  1. +0 −12 .docker-files/deps.sh
  2. +0 −13 .docker-files/node.sh
  3. +0 −10 .docker-files/pg.sh
  4. +1 −1 .dockerignore
  5. +0 −39 .github/workflows/anchore-analysis.yml
  6. +19 −18 .github/workflows/docker-image-ghcr.yml
  7. +0 −62 .github/workflows/dockerimage.yml
  8. +0 −44 .github/workflows/rubocop-analysis.yml
  9. +0 −82 .github/workflows/ruby.yml
  10. +1 −0 .gitignore
  11. +1 −1 .ruby-version
  12. +113 −66 Dockerfile
  13. +0 −53 Dockerfile.development
  14. +3 −10 Gemfile
  15. +298 −276 Gemfile.lock
  16. +14 −0 Rakefile
  17. +2 −0 app/channels/application_cable/connection.rb
  18. +1 −1 app/controllers/api/v1/direct_uploads_controller.rb
  19. +1 −1 app/graphql/mutations/predicates/search_predicate.rb
  20. +1 −1 app/graphql/types/app_type.rb
  21. +2 −5 app/graphql/types/article_settings_type.rb
  22. +2 −5 app/graphql/types/collection_type.rb
  23. +3 −5 app/graphql/types/public_app_type.rb
  24. +1 −1 app/javascript/src/pages/conversations/Editor.tsx
  25. +1 −1 app/models/app_user.rb
  26. +4 −3 app/models/article.rb
  27. +14 −1 app/services/origin_validator.rb
  28. +0 −18 bin/spring
  29. +9 −18 config/application.rb
  30. +0 −1 config/boot.rb
  31. +4 −11 config/database.yml
  32. +15 −46 config/environments/production.rb
  33. +4 −5 config/initializers/assets.rb
  34. +0 −34 config/initializers/new_framework_defaults_6_0.rb
  35. +2 −2 config/initializers/plans.rb
  36. +2 −2 config/initializers/redis.rb
  37. +2 −7 config/initializers/s3.rb
  38. +2 −2 config/initializers/searchkick.rb
  39. +6 −6 config/puma.rb
  40. +0 −8 config/spring.rb
  41. +2 −25 config/storage.yml
  42. +8 −16 docker-compose.yml
  43. +20 −0 docker-entrypoint.sh
  44. +10 −0 version.sh
12 changes: 0 additions & 12 deletions .docker-files/deps.sh

This file was deleted.

13 changes: 0 additions & 13 deletions .docker-files/node.sh

This file was deleted.

10 changes: 0 additions & 10 deletions .docker-files/pg.sh

This file was deleted.

2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -43,4 +43,4 @@ yarn-debug.log*

config/credentials/*.key
config/credentials/*.yml.enc

vendor/bundle
39 changes: 0 additions & 39 deletions .github/workflows/anchore-analysis.yml

This file was deleted.

37 changes: 19 additions & 18 deletions .github/workflows/docker-image-ghcr.yml
Original file line number Diff line number Diff line change
@@ -3,11 +3,9 @@ name: Create and publish a Docker image to ghcr.io
on:
push:
branches:
- master
- main
- stage
release:
types: [published]
types: [ published ]

env:
REGISTRY: ghcr.io
@@ -22,37 +20,40 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to the Container registry
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Collect version and tags
run: |
source ./version.sh
echo "app_version=$APP_VERSION" >> $GITHUB_ENV
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
images: ghcr.io/amoniacou/chaskiq
tags: |
type=raw,value=${{ env.app_version }}
type=ref,event=branch
type=ref,event=pr
type=sha
- name: Build and push Docker image
uses: docker/build-push-action@v2
uses: docker/build-push-action@v4
with:
context: .
build-args: |
"APP_ENV=production"
"NODE_ENV=production"
"RUBY_VERSION=3.2.0"
"PG_MAJOR=11"
"NODE_MAJOR=16"
"YARN_VERSION=1.13.0"
"BUNDLER_VERSION=2.3.26"
provenance: false
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
APP_VERSION=${{ env.app_version }}
62 changes: 0 additions & 62 deletions .github/workflows/dockerimage.yml

This file was deleted.

44 changes: 0 additions & 44 deletions .github/workflows/rubocop-analysis.yml

This file was deleted.

82 changes: 0 additions & 82 deletions .github/workflows/ruby.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -71,6 +71,7 @@ cypress/cypress-examples
cypress/videos
stats.json
.DS_Store
vendor/bundle
app/javascript/old-src
.envrc

2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.2.0
3.2.2
179 changes: 113 additions & 66 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,70 +1,117 @@
ARG RUBY_VERSION
FROM ruby:$RUBY_VERSION-slim-buster

ARG APP_ENV

ARG RUBY_VERSION=3.2.2
ARG APP_ROOT=/app
ARG PG_MAJOR=14
ARG NODE_MAJOR=18
ARG BUNDLER_VERSION=2.4.17
ARG YARN_VERSION=1.22.4
ARG SYSTEM_PACKAGES="curl gnupg lsb-release"
ARG BUILD_PACKAGES="build-essential libpq-dev libxml2-dev libxslt1-dev libc6-dev shared-mime-info zlib1g-dev nodejs libvips-dev"
ARG DEV_PACKAGES="git unzip"
ARG RUBY_PACKAGES="tzdata postgresql-client-$PG_MAJOR libjemalloc2 libyaml-0-2 libvips42"

FROM ruby:$RUBY_VERSION-slim-bookworm AS basic
ARG APP_ROOT
ARG BUILD_PACKAGES
ARG DEV_PACKAGES
ARG RUBY_PACKAGES
ARG SYSTEM_PACKAGES
ARG PG_MAJOR
ARG NODE_MAJOR
ARG BUNDLER_VERSION
ARG YARN_VERSION
ARG NODE_MAJOR
ENV LANG=C.UTF-8
ENV DEBIAN_FRONTEND noninteractive
ENV APP_ROOT=${APP_ROOT}
ENV PG_MAJOR=${PG_MAJOR}
ENV NODE_MAJOR=${NODE_MAJOR}
ENV YARN_VERSION=${YARN_VERSION}
ENV BUNDLER_VERSION=${BUNDLER_VERSION}
ENV SYSTEM_PACKAGES=${SYSTEM_PACKAGES}
ENV BUILD_PACKAGES=${BUILD_PACKAGES}
ENV DEV_PACKAGES=${DEV_PACKAGES}
ENV RUBY_PACKAGES=${RUBY_PACKAGES}
ENV HOME=${APP_ROOT}
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
COPY docker-entrypoint.sh /
RUN chmod a+x /docker-entrypoint.sh

# Copy Installers
RUN mkdir -p /docker-files
COPY .docker-files/ /docker-files
RUN chmod +x /docker-files/*.sh

# Install Dependencies
RUN /docker-files/deps.sh

# Install PostgreSQL
RUN /docker-files/pg.sh

# Install NodeJS, Yarn
RUN /docker-files/node.sh

# Configure bundler
ENV LANG=C.UTF-8 BUNDLE_JOBS=4 BUNDLE_RETRY=3

# Uncomment this line if you want to run binstubs without prefixing with `bin/` or `bundle exec`
# ENV PATH=/app/bin:$BUNDLE_BIN:$PATH

# Upgrade RubyGems and install required Bundler version
RUN gem update --system && \
gem install bundler:$BUNDLER_VERSION

# Change permissions for GEM_HOME
RUN chmod -R 777 $GEM_HOME

# Add docker user
RUN adduser --disabled-password --gecos "" docker && adduser docker staff

# Create and change app directory permissions
RUN mkdir /usr/src/app
RUN chown -R docker:docker /usr/src/app

# Bundler install gems
WORKDIR /tmp
COPY Gemfile Gemfile.lock /tmp/
RUN bundle install -j ${BUNDLE_JOBS} --retry ${BUNDLE_RETRY}
# Clean up APT when done
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
truncate -s 0 /var/log/*log

# Ensure setuid and setgid permissions are removed
RUN find / -perm /6000 -type f -exec chmod a-s {} \; || true

# Change user and set workdir
USER docker
WORKDIR /usr/src/app

# Copy app source into container
COPY --chown=docker:docker . /usr/src/app/

# Precompile assets - production only
# Clean up temp files and Yarn cache folder
RUN NODE_OPTIONS="--max-old-space-size=2048" \
RAILS_ENV=${APP_ENV} \
SECRET_KEY_BASE=`bin/rake secret` \
bundle exec rails assets:precompile --trace \
&& rm -rf /usr/src/app/node_modules /usr/src/app/tmp/cache/* /tmp/* \
&& yarn cache clean
ARG APP_ENV
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
--mount=type=tmpfs,target=/var/log \
--mount=type=tmpfs,target=/tmp \
set -x && apt-get update && apt-get install --no-install-recommends --yes ${SYSTEM_PACKAGES} \
&& curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | tee /etc/apt/trusted.gpg.d/apt.postgresql.org.gpg >/dev/null \
&& echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list \
&& sed -i "s/$(lsb_release -cs) main/$(lsb_release -cs) main contrib non-free/" /etc/apt/sources.list.d/debian.sources \
&& curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \
&& echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_${NODE_MAJOR}.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list \
&& apt-get update \
&& apt-get upgrade --yes \
&& apt-get install --no-install-recommends --yes ${RUBY_PACKAGES} ${DEV_PACKAGES} ${BUILD_PACKAGES} \
&& npm install -g yarn@$YARN_VERSION \
&& mkdir -p ${APP_ROOT} ${APP_ROOT}/vendor/bundle ${APP_ROOT}/.config ${APP_ROOT}/.bundle && adduser --system --gid 0 --uid 10001 --home ${APP_ROOT} appuser \
&& mkdir /tmp/bundle && chgrp -R 0 /tmp/bundle && chmod -R g=u /tmp/bundle \
&& chgrp -R 0 ${APP_ROOT} && chmod -R g=u ${APP_ROOT} && chmod g=u /etc/passwd

# Set a user to run
USER 10001
ENTRYPOINT ["/docker-entrypoint.sh"]
# set working folder
WORKDIR $APP_ROOT

FROM basic AS dev
ENV RAILS_ENV=development
ENV BUNDLE_PATH /app/vendor/bundle
EXPOSE 3000
USER 10001
COPY --chown=10001:0 . .

# BUILD FOR PROD
FROM basic AS build-env
ENV RAILS_ENV=production
ENV BUNDLE_RETRY=3
COPY --chown=10001:0 Gemfile Gemfile.lock ./
RUN --mount=type=cache,id=chasiq-dot-cache,sharing=locked,target=$APP_ROOT/.cache,uid=10001 \
--mount=type=cache,id=bundle-cache,sharing=locked,target=$APP_ROOT/.bundle/cache,uid=10001 \
set -x && bundle config --global frozen 1 \
&& bundle config set path /app/.cache/bundle \
&& bundle config set deployment "true" \
&& bundle config set without "test development" \
&& bundle install --retry $BUNDLE_RETRY \
# Remove unneeded files (cached *.gem, *.o, *.c)
&& rm -rf vendor/bundle && mkdir -p vendor \
&& cp -ar .cache/bundle vendor/ \
&& bundle config set path /app/vendor/bundle \
&& rm -rf vendor/bundle/ruby/*/cache \
&& find vendor/bundle/ruby/*/gems/ -name "*.c" -delete \
&& find vendor/bundle/ruby/*/gems/ -name "*.o" -delete \
&& find vendor/bundle/ruby/*/gems/ -name "*.a" -exec strip '{}' \; \
&& rm -rf vendor/bundle/ruby/*/gems/grpc-*/src/ruby/ext/grpc/objs
# cache node.js packages
COPY --chown=10001:0 package.json yarn.lock ./
COPY --chown=10001:0 app/javascript/packages ./app/javascript/packages
RUN --mount=type=cache,id=-yarn-cache,sharing=locked,target=/app/.yarn,uid=10001 \
--mount=type=cache,id=-dot-cache,sharing=locked,target=/app/.cache,uid=10001 \
--mount=type=tmpfs,target=/tmp \
set -x && yarn install --frozen-lockfile --non-interactive
COPY --chown=10001:0 . .
# compile assets
RUN --mount=type=cache,id=-assets-cache,sharing=locked,target=/app/tmp/cache,uid=10001 \
--mount=type=cache,id=-dot-cache,sharing=locked,target=/app/.cache,uid=10001 \
--mount=type=tmpfs,target=/tmp \
NODE_OPTIONS="--max-old-space-size=2048" \
SECRET_KEY_BASE=`bin/rake secret` \
bundle exec rails assets:precompile --trace \
&& rm -rf node_modules vendor/assets spec app/assets/builds app/javascript \
&& rm -rf vendor/bundle/ruby/*/gems/tailwindcss*/exe/*

# PRODUCTION BUILD
FROM basic AS production
COPY --chown=10001:0 --from=build-env $APP_ROOT $APP_ROOT
RUN set -x && rm -rf ./.* && bundle config set --local path './vendor/bundle' && bundle config set deployment "true" && bundle config set without "test development"
USER root
RUN set -x && DEBIAN_FRONTEND=noninteractive apt-get purge --auto-remove --yes ${SYSTEM_PACKAGES} && rm -rf /usr/include/* /var/lib/apt/* /var/cache/debconf
USER 10001
EXPOSE 3000
CMD ["bundle", "exec", "rails", "server", "-b", "0.0.0.0"]
53 changes: 0 additions & 53 deletions Dockerfile.development

This file was deleted.

13 changes: 3 additions & 10 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -3,16 +3,14 @@
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby "3.2.0"

# gem 'google-protobuf', git: 'https://github.com/google/protobuf'

gem "grpc", force_ruby_platform: true
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem "anycable-rails"
gem "pg"
gem "rails", "7.0.5.1" # , github: "rails/rails",
gem "uri", "0.10.0.1"
gem "rails", "~> 7.0.6" # , github: "rails/rails",
gem "uri", "~> 0.10.3"

# Use sqlite3 as the database for Active Record
# gem "sqlite3", group: "test"
@@ -66,8 +64,7 @@ gem "ransack"

gem "searchkick"

# gem "elasticsearch", "7.12" # select one
gem "opensearch-ruby" # select one
gem "elasticsearch", "~> 8.9.0" # select one

gem "browser", "~> 2.5"
gem "geocoder", "~> 1.6"
@@ -129,8 +126,6 @@ gem "globalize", github: "globalize/globalize"

# To use Stripe, also include:
gem "stripe", "~> 6.0"
# Reduces boot times through caching; required in config/boot.rb
gem "bootsnap", ">= 1.1.0", require: false

gem "dotenv-rails", groups: %i[development test]

@@ -148,8 +143,6 @@ group :development do
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
gem "listen", ">= 3.0.5", "< 3.2"
gem "web-console", ">= 3.3.0"
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem "spring"
end

group :test do
574 changes: 298 additions & 276 deletions Gemfile.lock

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -22,6 +22,20 @@ namespace :assets do
end
end

namespace :javascript do
desc "Build your JavaScript bundle"
task :only_build do
unless system "yarn build"
raise "jsbundling-rails: Command build failed, ensure yarn is installed and `yarn build` runs without errors"
end
end
end

if Rake::Task.task_defined?("assets:precompile")
Rake::Task["javascript:build"].clear
Rake::Task["assets:precompile"].enhance(["javascript:only_build"])
end

# Run yarn i18n:export prior to assets precompilation, so i18n json are available for use.
# Rake::Task['assets:precompile'].enhance [ 'locales:build' ]
# Rake::Task["assets:precompile"].enhance ["assets:clear_all"]
2 changes: 2 additions & 0 deletions app/channels/application_cable/connection.rb
Original file line number Diff line number Diff line change
@@ -38,6 +38,8 @@ def access_token
def get_session_data
params = request.query_parameters

return nil if app.blank?

OriginValidator.new(
app: app.domain_url,
host: env["HTTP_ORIGIN"]
2 changes: 1 addition & 1 deletion app/controllers/api/v1/direct_uploads_controller.rb
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ def create

def direct_upload_json(blob)
blob.as_json(root: false, methods: :signed_id)
.merge(service_url: rails_blob_path(blob))
.merge(service_url: rails_blob_url(blob))
.merge(direct_upload: {
url: blob.service_url_for_direct_upload,
headers: blob.service_headers_for_direct_upload
2 changes: 1 addition & 1 deletion app/graphql/mutations/predicates/search_predicate.rb
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ class Predicates::SearchPredicate < Mutations::BaseMutation
end

def app_users(app, per, page)
@app_users = if Chaskiq::Config.get("SEARCHKICK_ENABLED") == "true" && app.searchkick_enabled?
@app_users = if Chaskiq::Config.get("SEARCHKICK_ENABLED").present? && app.searchkick_enabled?
@segment.es_search(page, per).includes(taggings: :tag)
else
@segment.execute_query
2 changes: 1 addition & 1 deletion app/graphql/types/app_type.rb
Original file line number Diff line number Diff line change
@@ -522,7 +522,7 @@ def article(id:, lang:)
end

def contact_search(term:)
if Chaskiq::Config.get("SEARCHKICK_ENABLED") == "true" && object.searchkick_enabled?
if Chaskiq::Config.get("SEARCHKICK_ENABLED").present? && object.searchkick_enabled?
AppUser.search(
term,
fields: %i[name last_name first_name email phone],
7 changes: 2 additions & 5 deletions app/graphql/types/article_settings_type.rb
Original file line number Diff line number Diff line change
@@ -42,11 +42,8 @@ def header_image

def header_image_large
options = {
resize: "1280x600^",
gravity: "center",
crop: "1280x600+0+0",
strip: true,
quality: "86"
resize_to_limit: [1280, 600],
saver: { strip: true, quality: 86 }
}

return "" if object.header_image_blob.blank?
7 changes: 2 additions & 5 deletions app/graphql/types/collection_type.rb
Original file line number Diff line number Diff line change
@@ -14,11 +14,8 @@ class CollectionType < Types::BaseObject
field :icon, String, null: true
def icon
options = {
resize: "200x200^",
gravity: "center",
# crop: '200x200+0+0',
strip: true,
quality: "86"
resize_to_limit: [200, 200],
saver: { strip: true, quality: 86 }
}

return "" if object.icon_blob.blank?
8 changes: 3 additions & 5 deletions app/graphql/types/public_app_type.rb
Original file line number Diff line number Diff line change
@@ -112,11 +112,9 @@ def logo
field :logo_large, String, null: true
def logo_large
options = {
resize: "1280x600^",
gravity: "center",
crop: "1280x600+0+0",
strip: true,
quality: "86"
resize_to_limit: [1280, 600],
crop: [0, 0, 1280, 600],
saver: { strip: true, quality: 86 }
}

return "" if object.logo_blob.blank?
2 changes: 1 addition & 1 deletion app/javascript/src/pages/conversations/Editor.tsx
Original file line number Diff line number Diff line change
@@ -237,7 +237,7 @@ function EEDropdown({ items, selectedItem, setSelectedItem }) {
<li
key={`channel-item-${o.name}`}
onClick={() => selectItem(o)}
className="cursor-default select-none px-4 py-2 hover:text-white hover:bg-black"
className="cursor-pointer select-none px-4 py-2 hover:text-white hover:bg-gray-400 dark:hover:text-black dark:hover:bg-gray-600 dark:text-white"
role="option"
tabIndex={-1}
>
2 changes: 1 addition & 1 deletion app/models/app_user.rb
Original file line number Diff line number Diff line change
@@ -431,6 +431,6 @@ def self.properties_for_index
end

def should_index?
Chaskiq::Config.get("SEARCHKICK_ENABLED") == "true" && app.searchkick_enabled?
Chaskiq::Config.get("SEARCHKICK_ENABLED").present? && app.searchkick_enabled?
end
end
7 changes: 4 additions & 3 deletions app/models/article.rb
Original file line number Diff line number Diff line change
@@ -21,14 +21,15 @@ class Article < ApplicationRecord

include PgSearch::Model
pg_search_scope :search,
# against: [:title, :description]
# against: %i[title description],
# ignoring: :accents,
# using: [:trigram],
using: {
tsearch: { prefix: true }
tsearch: { prefix: true, dictionary: "english" }
},
associated_against: {
translations: %i[title description]
translations: %i[title description],
article_content: %i[html_content]
}

has_one :article_content, dependent: :destroy_async
15 changes: 14 additions & 1 deletion app/services/origin_validator.rb
Original file line number Diff line number Diff line change
@@ -30,11 +30,24 @@ def validate_domain(domain)
host
)

env_domain_without_subdomain = Addressable::URI.parse(without_subdomain(env_domain))

app_domain = Addressable::URI.parse(domain)

# for now we will check for domain
return false if app_domain.normalized_site != env_domain.normalized_site
if app_domain.normalized_site != env_domain.normalized_site ||
app_domain.normalized_site != env_domain_without_subdomain.normalized_site
return false
end

true
end

def without_subdomain(env_domain)
subdomains = env_domain.host.split('.')
subdomains.shift
modified_url = "#{env_domain.scheme}://#{subdomains.join('.')}#{env_domain.path}"

modified_url
end
end
18 changes: 0 additions & 18 deletions bin/spring

This file was deleted.

27 changes: 9 additions & 18 deletions config/application.rb
Original file line number Diff line number Diff line change
@@ -6,22 +6,20 @@
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)

require 'URLcrypt'
require_relative 'middleware/maintenance_mode'
require "URLcrypt"
require_relative "middleware/maintenance_mode"

Dotenv::Railtie.load if defined?(Dotenv::Railtie)

module Chaskiq

module Config

def self.get(name)
# config[name] || ENV[name.upcase]
Rails.application.credentials.config.fetch(
name.downcase.to_sym, ENV[name.to_s.upcase]
name.downcase.to_sym, ENV.fetch(name.to_s.upcase, nil)
)
end

def self.fetch(name, fallback)
Rails.application.credentials.config.fetch(
name.downcase.to_sym, ENV.fetch(name.to_s.upcase, fallback)
@@ -30,10 +28,9 @@ def self.fetch(name, fallback)
end
end


class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 6.1
config.load_defaults 7.0

# Configuration for the application, engines, and railties goes here.
#
@@ -43,10 +40,7 @@ class Application < Rails::Application
# config.time_zone = "Central Time (US & Canada)"
# config.eager_load_paths << Rails.root.join("extras")


config.load_defaults '6.0'

config.encoding = 'utf-8'
config.encoding = "utf-8"

config.assets.css_compressor = nil

@@ -75,18 +69,15 @@ class Application < Rails::Application
end
end

if Chaskiq::Config::get("MAINTENANCE_MODE") == "true"
config.middleware.insert_before Rack::Sendfile, Middleware::MaintenanceMode
end
config.middleware.insert_before Rack::Sendfile, Middleware::MaintenanceMode if Chaskiq::Config.get("MAINTENANCE_MODE") == "true"

URLcrypt.key = [Chaskiq::Config.get('SECRET_KEY_BASE')].pack('H*')
ENV['urlcrypt_key'] = [Chaskiq::Config.get("SECRET_KEY_BASE")].pack("H*") if ENV.fetch('SECRET_KEY_BASE', nil)

locales = %w[af sq ar eu bg be ca hr cs da nl en eo et fo fi fr gl de el iw hu is ga it ja ko lv lt mk mt no pl pt ro ru gd sr sr sk sl es sv tr uk zh-CN]
config.available_locales = locales
I18n.available_locales = locales
config.i18n.default_locale = :en

config.action_dispatch.tld_length = Chaskiq::Config.fetch('TLD_LENGTH', 1)&.to_i

config.action_dispatch.tld_length = Chaskiq::Config.fetch("TLD_LENGTH", 1)&.to_i
end
end
1 change: 0 additions & 1 deletion config/boot.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)

require "bundler/setup" # Set up gems listed in the Gemfile.
require "bootsnap/setup" # Speed up boot time by caching expensive operations.
15 changes: 4 additions & 11 deletions config/database.yml
Original file line number Diff line number Diff line change
@@ -50,16 +50,9 @@ staging:
url: <%= Chaskiq::Config.get('DATABASE_URL') %>

production:
<<: *default
database: <%= ENV.fetch('POSTGRES_DATABASE', 'chaskiq_production') %>
username: <%= ENV.fetch('POSTGRES_USERNAME', 'chaskiq_prod') %>
password: <%= ENV.fetch('POSTGRES_PASSWORD', 'chaskiq_prod') %>
prepared_statements: false
adapter: postgresql
encoding: unicode
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 15 } %>
url: <%= ENV['DATABASE_URL'] %>
prepared_statements: false
min_messages: warning
host_names:
### Don't include the port number here. Change the "port" site setting instead, at /admin/site_settings.
### If you change this setting you will need to
### - restart sidekiq if you change this setting
### - rebake all to posts using: `RAILS_ENV=production bundle exec rake posts:rebake`
- "localhost"
61 changes: 15 additions & 46 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
@@ -29,11 +29,10 @@

# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false
config.assets.enabled = false if ENV['ANYCABLE_DEPLOYMENT']
config.action_controller.asset_host = Chaskiq::Config.fetch('ASSET_HOST', Chaskiq::Config.get("HOST") )
config.assets.enabled = false if ENV["ANYCABLE_DEPLOYMENT"]
config.action_controller.asset_host = Chaskiq::Config.fetch("ASSET_HOST", Chaskiq::Config.get("HOST"))


config.action_controller.asset_host = Chaskiq::Config.fetch('ASSET_HOST', Chaskiq::Config.get("HOST") )
config.action_controller.asset_host = Chaskiq::Config.fetch("ASSET_HOST", Chaskiq::Config.get("HOST"))
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.asset_host = "http://assets.example.com"

@@ -42,16 +41,15 @@
# config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX

# Store uploaded files on the local file system (see config/storage.yml for options).
config.active_storage.service = ENV.fetch('ACTIVE_STORAGE_SERVICE', 'amazon').to_sym

Rails.application.routes.default_url_options = { host: Chaskiq::Config.get('HOST') }
config.action_controller.default_url_options = { host: Chaskiq::Config.get('HOST') }
config.action_mailer.default_url_options = { host: Chaskiq::Config.get('HOST') }
config.active_storage.service = ENV.fetch("ACTIVE_STORAGE_SERVICE", "amazon").to_sym

Rails.application.routes.default_url_options = { host: Chaskiq::Config.get("HOST") }
config.action_controller.default_url_options = { host: Chaskiq::Config.get("HOST") }
config.action_mailer.default_url_options = { host: Chaskiq::Config.get("HOST") }

# Mount Action Cable outside main process or domain.
# config.action_cable.mount_path = nil
config.action_cable.url = ENV['WS'] # Rails.application.credentials.ws
config.action_cable.url = ENV.fetch("WS", nil) # Rails.application.credentials.ws
# config.action_cable.allowed_request_origins = [ "http://example.com", /http:\/\/example.*/ ]

# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
@@ -62,7 +60,7 @@
config.log_level = :info

# Prepend all log lines with the following tags.
config.log_tags = [ :request_id ]
config.log_tags = [:request_id]

# Use a different cache store in production.
# config.cache_store = :mem_cache_store
@@ -86,48 +84,19 @@
config.active_support.report_deprecations = false

# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
config.log_formatter = Logger::Formatter.new

# Use a different logger for distributed setups.
# require "syslog/logger"
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new "app-name")

if ENV["RAILS_LOG_TO_STDOUT"].present?
logger = ActiveSupport::Logger.new(STDOUT)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
end
logger = ActiveSupport::Logger.new(STDOUT)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)

# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false


# config.active_record.dump_schema_after_migration = false
delivery_method = ENV.fetch('SMTP_DELIVERY_METHOD', 'ses')

if delivery_method.downcase == 'smtp'
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: ENV['SMTP_ADDRESS'],
user_name: ENV['SMTP_USERNAME'], # Your SMTP user here.
password: ENV['SMTP_PASSWORD'], # Your SMTP password here.
authentication: :login,
enable_starttls_auto: true
}
else
zone = ENV['AWS_S3_REGION']

creds = Aws::Credentials.new(
ENV['AWS_ACCESS_KEY_ID'],
ENV['AWS_SECRET_ACCESS_KEY']
)

Aws::Rails.add_action_mailer_delivery_method(
:ses,
credentials: creds,
region: zone
)

config.action_mailer.delivery_method = :ses
end
# we will use default client setting from kubernetes
config.action_mailer.delivery_method = :ses
end
9 changes: 4 additions & 5 deletions config/initializers/assets.rb
Original file line number Diff line number Diff line change
@@ -3,14 +3,13 @@
# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = "1.0"

Rails.application.config.assets.paths << Rails.root.join('node_modules')
Rails.application.config.assets.precompile += %w( tailwind.css )
Rails.application.config.assets.precompile += %w[tailwind.css]
Rails.application.config.assets.precompile += %w[campaign.css]
Rails.application.config.assets.precompile += %w( embed.js )
Rails.application.config.assets.precompile += %w( article.js )
Rails.application.config.assets.precompile += %w[embed.js]
Rails.application.config.assets.precompile += %w[article.js]
# Rails.application.config.assets.precompile += %w( application.js )

Rails.application.config.assets.paths << Rails.root.join('app', 'assets', 'fonts')
Rails.application.config.assets.paths << Rails.root.join("app/assets/fonts")

# Add additional assets to the asset load path.
# Rails.application.config.assets.paths << Emoji.images_path
34 changes: 0 additions & 34 deletions config/initializers/new_framework_defaults_6_0.rb

This file was deleted.

4 changes: 2 additions & 2 deletions config/initializers/plans.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
YAML_PLANS = YAML.load(
File.open(Rails.root.join('config/subscriptions.yml'))
File.open(Rails.root.join("config/subscriptions.yml"))
)
.with_indifferent_access
.dig('subscriptions', 'plans')
.dig("subscriptions", "plans")
4 changes: 2 additions & 2 deletions config/initializers/redis.rb
Original file line number Diff line number Diff line change
@@ -12,10 +12,10 @@
# you can set `Redis.exists_returns_integer = false`,
# but this option will be removed in 5.0. (gems/redis-namespace-1.6.0/lib/redis/namespace.rb:442:in `call_with_namespace')
Redis.exists_returns_integer = true
REDIS_URL = Chaskiq::Config.fetch('REDIS_URL', 'redis://localhost:6379/1')
REDIS_URL = Chaskiq::Config.fetch("REDIS_URL", "redis://localhost:6379/1")
# Redis.current = Redis.new(url: REDIS_URL)

require 'connection_pool'
require "connection_pool"
Redis::Objects.redis = ConnectionPool.new(size: 5, timeout: 5) do
Redis.new(url: REDIS_URL)
end
9 changes: 2 additions & 7 deletions config/initializers/s3.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
# frozen_string_literal: true

require 'aws-sdk-s3'

ENV['AWS_REGION'] = Chaskiq::Config.get('AWS_S3_REGION') || 'us-east-1'
require "aws-sdk-s3"

AWS_CLIENT = begin
if Rails.env.test?
nil
else
Aws::S3::Client.new(
access_key_id: Chaskiq::Config.get('AWS_ACCESS_KEY_ID'),
secret_access_key: Chaskiq::Config.get('AWS_SECRET_ACCESS_KEY')
)
Aws::S3::Client.new
end
rescue StandardError
nil
4 changes: 2 additions & 2 deletions config/initializers/searchkick.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
if Chaskiq::Config.get("SEARCHKICK_ENABLED") == "true"
if Chaskiq::Config.get("SEARCHKICK_ENABLED").present?
Searchkick.client_type = Chaskiq::Config.fetch("SEARCHKICK_CLIENT", "elasticsearch").to_sym
end
end
12 changes: 6 additions & 6 deletions config/puma.rb
Original file line number Diff line number Diff line change
@@ -6,17 +6,17 @@
# the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum; this matches the default thread size of Active Record.
#
max_threads_count = ENV.fetch('RAILS_MAX_THREADS') { 5 }
min_threads_count = ENV.fetch('RAILS_MIN_THREADS') { max_threads_count }
max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
threads min_threads_count, max_threads_count

# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
#
port ENV.fetch('PORT') { 3000 }
port ENV.fetch("PORT") { 3000 }

# Specifies the `environment` that Puma will run in.
#
environment ENV.fetch('RAILS_ENV') { 'development' }
environment ENV.fetch("RAILS_ENV") { "development" }

# Redirect all stdout/stderr
#
@@ -44,11 +44,11 @@
# before forking the application. This takes advantage of Copy On Write
# process behavior so workers use less memory.
#
# preload_app!
preload_app!

on_worker_boot do
ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
end

# Allow puma to be restarted by `rails restart` command.
plugin :tmp_restart
# plugin :tmp_restart
8 changes: 0 additions & 8 deletions config/spring.rb

This file was deleted.

27 changes: 2 additions & 25 deletions config/storage.yml
Original file line number Diff line number Diff line change
@@ -6,30 +6,7 @@ local:
service: Disk
root: <%= Chaskiq::Config.fetch("LOCAL_STORAGE_PATH", Rails.root.join("storage")) %>

# Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
amazon:
service: S3
access_key_id: <%= Chaskiq::Config.get('AWS_ACCESS_KEY_ID') %>
secret_access_key: <%= Chaskiq::Config.get('AWS_SECRET_ACCESS_KEY') %>
region: <%= Chaskiq::Config.get('AWS_S3_REGION') || 'us-east-1' %>
bucket: <%= Chaskiq::Config.get('AWS_S3_BUCKET') %>
# endpoint: <%= Chaskiq::Config.get('AWS_S3_ENDPOINT') %>
# force_path_style: true
# Remember not to checkin your GCS keyfile to a repository
# google:
# service: GCS
# project: your_project
# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %>
# bucket: your_own_bucket

# Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key)
# microsoft:
# service: AzureStorage
# storage_account_name: your_account_name
# storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %>
# container: your_container_name

# mirror:
# service: Mirror
# primary: local
# mirrors: [ amazon, google, microsoft ]
region: <%= Chaskiq::Config.get('AWS_REGION') || 'us-east-1' %>
bucket: <%= Chaskiq::Config.get('AWS_BUCKET') %>
24 changes: 8 additions & 16 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,19 @@
version: '2.4'
version: '3.5'

x-app:
&app
x-app: &app
build:
context: .
dockerfile: ./Dockerfile.development
args:
RUBY_VERSION: '3.2.0'
PG_MAJOR: '14'
NODE_MAJOR: '16'
YARN_VERSION: '1.13.0'
BUNDLER_VERSION: '2.3.26'
environment:
&env
dockerfile: ./Dockerfile
target: dev
environment: &env
NODE_ENV: development
RAILS_ENV: ${RAILS_ENV:-development}
ANYCABLE_DEBUG: ${DEBUG:-0}
ANYCABLE_RPC_HOST: 0.0.0.0:50051
image: chaskiq/chaskiq:1.1.0
tmpfs:
- /tmp

x-backend:
&backend
x-backend: &backend
<<: *app
stdin_open: true
tty: true
@@ -34,6 +25,7 @@ x-backend:
- packs:/app/public/packs
- .dockerdev/.psqlrc:/root/.psqlrc:ro
- .dockerdev/.bashrc:/root/.bashrc:ro
user: $UID
environment:
<<: *env
REDIS_URL: redis://redis:6379/
@@ -63,7 +55,7 @@ services:
anycable:
image: 'anycable/anycable-go:1.0-alpine'
ports:
- "8080:8080"
- '8080:8080'
environment:
PORT: 8080
ANYCABLE_HOST: 0.0.0.0
20 changes: 20 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
set -e

if ! whoami &> /dev/null; then
if [ -w /etc/passwd ]; then
echo "${USER_NAME:-appuser}:x:$(id -u):0:${USER_NAME:-appuser} user:${APP_ROOT}:/sbin/nologin" >> /etc/passwd
fi
fi

if [[ "$1" == "bundle" ]] || [[ "$1" == "yarn" ]] || [[ "$1" == "rails" ]]; then
exec "$@"
fi


if [ -f /tmp/puma.pid ]; then
echo "Cleanin server PID file"
rm /tmp/puma.pid
fi

exec "$@"
10 changes: 10 additions & 0 deletions version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh
export BASE_VERSION=1.0.0
CURRENT_VERSION=$BASE_VERSION
if [[ "${GITHUB_HEAD_REF}" != "" ]]; then
TASK_ID=$(echo ${GITHUB_HEAD_REF#refs/heads/} | tr '[:upper:]' '[:lower:]' | sed -E 's/^.*(amo-[0-9]+).*$/\1/g' | sed 's/-//g')
CURRENT_VERSION="$BASE_VERSION-${TASK_ID}-${GITHUB_RUN_NUMBER}-${GITHUB_RUN_ATTEMPT}"
export APP_VERSION=$CURRENT_VERSION
else
export APP_VERSION=$(echo $(git describe --exact-match --tags HEAD 2>/dev/null || echo "${CURRENT_VERSION}-$(git ls-files app lib config db config.ru public Dockerfile docker-entrypoint.sh yarn.lock Gemfile.lock | xargs sha256sum | sha256sum | cut -c 1-6 -)") | sed -e "s/^v//")
fi