From 287786f30ab050c9fd32ade9d4e31f8795e4bd16 Mon Sep 17 00:00:00 2001 From: ayuki_j <19406594+ayuki-joto@users.noreply.github.com> Date: Mon, 5 Aug 2024 16:10:14 +0900 Subject: [PATCH 1/7] fix: local docker postgres --- docker-compose.yml | 6 +++--- docker/postgres/Dockerfile | 15 +++++++++++++++ docker/postgres/initdb-pg_bigm.sql | 1 + 3 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 docker/postgres/Dockerfile create mode 100644 docker/postgres/initdb-pg_bigm.sql diff --git a/docker-compose.yml b/docker-compose.yml index 46ecc81da..9b729b69f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,3 @@ -version: "3.8" - x-custom: app: - &rails_env "development" @@ -45,7 +43,9 @@ services: links: - pg pg: - image: postgres:12 + image: postgres + build: + context: docker/postgres/. volumes: - pg-data:/var/lib/postgresql/data environment: diff --git a/docker/postgres/Dockerfile b/docker/postgres/Dockerfile new file mode 100644 index 000000000..07c326a03 --- /dev/null +++ b/docker/postgres/Dockerfile @@ -0,0 +1,15 @@ +FROM postgres:12 + +RUN apt update +RUN apt install -y postgresql-server-dev-12 make gcc curl libicu-dev + +RUN cd /tmp && \ + curl -L -O https://github.com/pgbigm/pg_bigm/archive/refs/tags/v1.2-20240606.tar.gz && \ + tar zxf v1.2-20240606.tar.gz && \ + cd pg_bigm-1.2-20240606 && \ + make USE_PGXS=1 && \ + make USE_PGXS=1 install && \ + rm -rf /tmp/pg_bigm-1.2-20240606 /tmp/v1.2-20240606.tar.gz + +RUN mkdir -p /docker-entrypoint-initdb.d +COPY ./initdb-pg_bigm.sql /docker-entrypoint-initdb.d/10_pg_bigm.sql diff --git a/docker/postgres/initdb-pg_bigm.sql b/docker/postgres/initdb-pg_bigm.sql new file mode 100644 index 000000000..7aac902db --- /dev/null +++ b/docker/postgres/initdb-pg_bigm.sql @@ -0,0 +1 @@ +CREATE EXTENSION IF NOT EXISTS pg_bigm; \ No newline at end of file From 3b7e8d8847b59a027630d82fb7e1487d1aafa9ea Mon Sep 17 00:00:00 2001 From: takahashim Date: Mon, 5 Aug 2024 18:03:55 +0900 Subject: [PATCH 2/7] Use postgresql image in ghcr.io/codeforjapan --- docker-compose.yml | 4 +--- docker/postgres/Dockerfile | 15 --------------- docker/postgres/initdb-pg_bigm.sql | 1 - 3 files changed, 1 insertion(+), 19 deletions(-) delete mode 100644 docker/postgres/Dockerfile delete mode 100644 docker/postgres/initdb-pg_bigm.sql diff --git a/docker-compose.yml b/docker-compose.yml index 9b729b69f..5cf53ae1a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -43,9 +43,7 @@ services: links: - pg pg: - image: postgres - build: - context: docker/postgres/. + image: "ghcr.io/codeforjapan/postgresql_bigm:12-latest" volumes: - pg-data:/var/lib/postgresql/data environment: diff --git a/docker/postgres/Dockerfile b/docker/postgres/Dockerfile deleted file mode 100644 index 07c326a03..000000000 --- a/docker/postgres/Dockerfile +++ /dev/null @@ -1,15 +0,0 @@ -FROM postgres:12 - -RUN apt update -RUN apt install -y postgresql-server-dev-12 make gcc curl libicu-dev - -RUN cd /tmp && \ - curl -L -O https://github.com/pgbigm/pg_bigm/archive/refs/tags/v1.2-20240606.tar.gz && \ - tar zxf v1.2-20240606.tar.gz && \ - cd pg_bigm-1.2-20240606 && \ - make USE_PGXS=1 && \ - make USE_PGXS=1 install && \ - rm -rf /tmp/pg_bigm-1.2-20240606 /tmp/v1.2-20240606.tar.gz - -RUN mkdir -p /docker-entrypoint-initdb.d -COPY ./initdb-pg_bigm.sql /docker-entrypoint-initdb.d/10_pg_bigm.sql diff --git a/docker/postgres/initdb-pg_bigm.sql b/docker/postgres/initdb-pg_bigm.sql deleted file mode 100644 index 7aac902db..000000000 --- a/docker/postgres/initdb-pg_bigm.sql +++ /dev/null @@ -1 +0,0 @@ -CREATE EXTENSION IF NOT EXISTS pg_bigm; \ No newline at end of file From 863bcb756cf9cc4ad9139b84662df8efeb69b28e Mon Sep 17 00:00:00 2001 From: takahashim Date: Mon, 5 Aug 2024 20:26:09 +0900 Subject: [PATCH 3/7] fix: use `decidim_sanitize_admin` instead of `decidim_escape_translated` --- .../accountability/results/_timeline.html.erb | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 app/views/decidim/accountability/results/_timeline.html.erb diff --git a/app/views/decidim/accountability/results/_timeline.html.erb b/app/views/decidim/accountability/results/_timeline.html.erb new file mode 100644 index 000000000..8f31f24ed --- /dev/null +++ b/app/views/decidim/accountability/results/_timeline.html.erb @@ -0,0 +1,30 @@ +
+
+

<%= t(".title") %>

+
    + <% result.timeline_entries.each_with_index do |timeline_entry, i| %> +
  1. +
    + <%= i + 1 %> +
    +
    +
    + + <%= l timeline_entry.entry_date, format: :decidim_short %> + +

    + <%= translated_attribute timeline_entry.title %> +

    + + <% if translated_attribute(timeline_entry.description).present? %> +
    + <%= decidim_sanitize_admin translated_attribute(timeline_entry.description) %> +
    + <% end %> +
    +
    +
  2. + <% end %> +
+
+
From a97e0ed328246933bb8e98f863d350b1bc7e1959 Mon Sep 17 00:00:00 2001 From: takahashim Date: Tue, 6 Aug 2024 00:01:01 +0900 Subject: [PATCH 4/7] fix: Use Redis with docker compose --- docker-compose.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 9b729b69f..df566abe4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,7 @@ x-custom: app: - &rails_env "development" + - &redis_cache_url "${REDIS_CACHE_URL:-redis://redis:6379/0}" postgres: - &postgres_user "${DATABASE_USERNAME:-postgres}" - &postgres_password "${DATABASE_PASSWORD:-password}" @@ -29,9 +30,9 @@ services: volumes: - .:/app - node_modules:/app/node_modules + - rails-tmp:/app/tmp # exclude volumes - /app/vendor - - /app/tmp - /app/log - /app/.git environment: @@ -40,8 +41,11 @@ services: DATABASE_USERNAME: *postgres_user DATABASE_PASSWORD: *postgres_password RAILS_ENV: *rails_env + REDIS_URL: *redis_cache_url + REDIS_CACHE_URL: *redis_cache_url links: - pg + - redis pg: image: postgres build: @@ -53,7 +57,15 @@ services: POSTGRES_PASSWORD: *postgres_password ports: - 5433:5432 + redis: + image: redis + ports: + - 6379:6379 + volumes: + - redis-data:/data volumes: node_modules: {} pg-data: {} + redis-data: {} + rails-tmp: {} From 7bed543754591f1fb5805f0aa5791a3b9c464a1a Mon Sep 17 00:00:00 2001 From: takahashim Date: Tue, 6 Aug 2024 00:26:30 +0900 Subject: [PATCH 5/7] Add cache on README --- docs/DEVELOPMENT.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/docs/DEVELOPMENT.md b/docs/DEVELOPMENT.md index a442cbd8e..09e95eef7 100644 --- a/docs/DEVELOPMENT.md +++ b/docs/DEVELOPMENT.md @@ -103,3 +103,19 @@ http://localhost:3000 にアクセス * サービス画面 (http://localhost:3000/users/sign_in?locale=ja) * admin@example.org (組織管理者) * user@example.org (通常ユーザ) + +## 5. キャッシュとRedisについて + +Railsのキャッシュはproduction環境ではRedis Cache Store(`ActiveSupport::Cache::RedisCacheStore`)を使うようになっています。 + +Redisの設定は環境変数 `REDIS_CACHE_URL` を使用しています。 + +development環境でのRailsの標準機能として、キャッシュのオン・オフをトグルで制御できます。オン・オフを切り替えたい場合、以下のコマンドを実行してください。 + +```console +# dockerを使っている場合 +docker compose run app rails dev:cache + +# localで動かしている場合 +bin/rails dev:cache +``` From b9af2e8f070446d855c0d9dc0e9e03a7c9b57616 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 6 Aug 2024 05:51:25 +0000 Subject: [PATCH 6/7] chore(main): release 1.2.4 --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 20043b246..59f52599a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Change Log +## [1.2.4](https://github.com/codeforjapan/decidim-cfj/compare/v1.2.3...v1.2.4) (2024-08-06) + + +### Bug Fixes + +* local docker postgres ([287786f](https://github.com/codeforjapan/decidim-cfj/commit/287786f30ab050c9fd32ade9d4e31f8795e4bd16)) +* use `decidim_sanitize_admin` instead of `decidim_escape_translated` ([863bcb7](https://github.com/codeforjapan/decidim-cfj/commit/863bcb756cf9cc4ad9139b84662df8efeb69b28e)) +* Use Redis with docker compose ([a97e0ed](https://github.com/codeforjapan/decidim-cfj/commit/a97e0ed328246933bb8e98f863d350b1bc7e1959)) + ## [1.2.3](https://github.com/codeforjapan/decidim-cfj/compare/v1.2.2...v1.2.3) (2024-07-30) From f185dc2251015efec0c0339a29e5842947318859 Mon Sep 17 00:00:00 2001 From: takahashim Date: Mon, 19 Aug 2024 18:05:23 +0900 Subject: [PATCH 7/7] Dockerfile: fix warning --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 7d8993d82..34c15b864 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:16.13.0-bullseye-slim as node +FROM node:16.13.0-bullseye-slim AS node FROM ruby:3.0.6-slim-bullseye