Skip to content

Commit

Permalink
release
Browse files Browse the repository at this point in the history
release: add wicked_pdf 2.6.3, allow admin to update a scope & bump to ruby 2.7.7
  • Loading branch information
Quentinchampenois authored Feb 2, 2024
2 parents eb5a520 + 1adf75c commit 56c8644
Show file tree
Hide file tree
Showing 12 changed files with 834 additions and 26,385 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ env:
CI: "true"
SIMPLECOV: "true"
RSPEC_FORMAT: "documentation"
RUBY_VERSION: 2.7.5
RUBY_VERSION: 2.7.7
RAILS_ENV: test
NODE_VERSION: 16.9.1
NODE_VERSION: 16.18.1
RUBYOPT: '-W:no-deprecated'
# Set locales available for i18n tasks
ENFORCED_LOCALES: "en,fr"
Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.7.5
2.7.7
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ruby:2.7.5
FROM ruby:2.7.7

ENV RAILS_ENV=production \
SECRET_KEY_BASE=dummy
Expand All @@ -12,11 +12,13 @@ RUN --mount=type=cache,target=/var/cache/apt \
apt update && \
npm install -g [email protected] && \
npm install --global yarn && \
apt install -y libicu-dev postgresql-client && \
apt install -y libicu-dev postgresql-client libproj-dev proj-bin && \
gem install bundler:2.2.17 && \
rm -rf /var/lib/apt/lists/*

COPY Gemfile* ./

RUN bundle config set build.rgeo-proj4 --with-proj-dir="/usr/bin/"
RUN bundle config set --local without 'development test' && bundle install

COPY package* ./
Expand Down
58 changes: 58 additions & 0 deletions Dockerfile.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
FROM ruby:2.7.7 as builder

ENV RAILS_ENV=production \
SECRET_KEY_BASE=dummy

WORKDIR /app

# Install NodeJS
RUN --mount=type=cache,target=/var/cache/apt \
curl https://deb.nodesource.com/setup_16.x | bash && \
apt install -y nodejs && \
apt update && \
npm install -g [email protected] && \
npm install --global yarn && \
apt install -y libicu-dev postgresql-client libproj-dev proj-bin && \
gem install bundler:2.4.21 && \
rm -rf /var/lib/apt/lists/*

COPY Gemfile* ./

RUN bundle config set build.rgeo-proj4 --with-proj-dir="/usr/bin/"
RUN bundle config set --local without 'development test' && bundle install

COPY package* ./
COPY yarn.lock .
COPY packages packages
RUN yarn install

COPY . .

RUN bundle exec bootsnap precompile --gemfile app/ lib/ config/ bin/ db/ && bundle exec rails assets:precompile

run mkdir certificate-https-local
RUN openssl req -new -newkey rsa:4096 -days 365 -nodes -x509 -subj "/C=FR/ST=France/L=Paris/O=decidim/CN=decidim.eu" -keyout ./certificate-https-local/key.pem -out ./certificate-https-local/cert.pem;

# Runner Stage
FROM ruby:2.7.7 as runner

ENV RAILS_ENV=production \
SECRET_KEY_BASE=dummy \
RAILS_LOG_TO_STDOUT=true \
LD_PRELOAD="libjemalloc.so.2" \
MALLOC_CONF="background_thread:true,metadata_thp:auto,dirty_decay_ms:5000,muzzy_decay_ms:5000,narenas:2"

WORKDIR /app

RUN apt-get update -q && \
apt-get install -yq postgresql-client imagemagick libproj-dev proj-bin libjemalloc2 && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
gem install bundler:2.4.9

COPY --from=builder /usr/local/bundle /usr/local/bundle
COPY --from=builder /usr/bin/proj /usr/bin
COPY --from=builder /app /app

EXPOSE 3000
CMD ["bundle", "exec", "rails", "server", "-b", "ssl://0.0.0.0:3000?key=/app/certificate-https-local/key.pem&cert=/app/certificate-https-local/cert.pem"]
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ gem "nokogiri", "1.13.4"
gem "puma", ">= 5.5.1"
gem "rack-attack", "~> 6.6"
gem "sys-filesystem"
gem "wicked_pdf", "~> 2.6.3"

group :development do
gem "letter_opener_web", "~> 1.3"
Expand Down
10 changes: 8 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,7 @@ GEM
mime-types-data (3.2023.1003)
mini_magick (4.12.0)
mini_mime (1.1.5)
mini_portile2 (2.8.5)
minitest (5.20.0)
mixlib-cli (2.1.8)
mixlib-config (3.0.27)
Expand All @@ -605,6 +606,9 @@ GEM
net-smtp (0.4.0)
net-protocol
nio4r (2.6.1)
nokogiri (1.13.4)
mini_portile2 (~> 2.8.0)
racc (~> 1.4)
nokogiri (1.13.4-arm64-darwin)
racc (~> 1.4)
nokogiri (1.13.4-x86_64-linux)
Expand Down Expand Up @@ -917,7 +921,7 @@ GEM
websocket-driver (0.7.6)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
wicked_pdf (2.7.0)
wicked_pdf (2.6.3)
activesupport
wisper (2.0.1)
wisper-rspec (1.1.0)
Expand All @@ -928,6 +932,7 @@ GEM

PLATFORMS
arm64-darwin-22
ruby
x86_64-linux

DEPENDENCIES
Expand Down Expand Up @@ -974,9 +979,10 @@ DEPENDENCIES
spring-watcher-listen (~> 2.0)
sys-filesystem
web-console (= 4.0.4)
wicked_pdf (~> 2.6.3)

RUBY VERSION
ruby 2.7.5p203
ruby 2.7.7p221

BUNDLED WITH
2.4.21
105 changes: 27 additions & 78 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,90 +1,39 @@
#### Decidim
local:
bundle exec rake db:drop db:setup

test_app:
bundle exec rake test:setup

#### Terraform | Scaleway provider
init-scw:
terraform -chdir=deploy/providers/scaleway init

plan-scw:
@make init-scw
terraform -chdir=deploy/providers/scaleway plan

deploy-scw:
@make init-scw
terraform -chdir=deploy/providers/scaleway apply

destroy-scw:
terraform -chdir=deploy/providers/scaleway destroy

### Docker usage
run: up
@make create-seeds

# Docker images commands
up:
docker-compose -f docker-compose.local.yml up --build -d
@make setup-database

REGISTRY := rg.fr-par.scw.cloud
NAMESPACE := decidim-app
VERSION := latest
IMAGE_NAME := decidim-app
TAG := $(REGISTRY)/$(NAMESPACE)/$(IMAGE_NAME):$(VERSION)
# Stops containers and remove volumes
teardown:
docker-compose -f docker-compose.local.yml down -v --rmi all

login:
docker login $(REGISTRY) -u nologin -p $(SCW_SECRET_TOKEN)
create-database:
docker-compose -f docker-compose.local.yml exec app /bin/bash -c 'DISABLE_DATABASE_ENVIRONMENT_CHECK=1 /usr/local/bundle/bin/bundle exec rake db:create'

build-classic:
docker build -t $(IMAGE_NAME):$(VERSION) .
build-scw:
docker build -t $(TAG) .
push:
@make build-scw
@make login
docker push $(TAG)
pull:
@make build-scw
docker pull $(TAG)
setup-database: create-database
docker-compose -f docker-compose.local.yml exec app /bin/bash -c 'DISABLE_DATABASE_ENVIRONMENT_CHECK=1 /usr/local/bundle/bin/bundle exec rake db:migrate'

# Bundle commands
create-database:
docker-compose run app bundle exec rails db:create
run-migrations:
docker-compose run app bundle exec rails db:migrate
# Create seeds
create-seeds:
docker-compose run app bundle exec rails db:seed
docker-compose -f docker-compose.local.yml exec app /bin/bash -c 'DISABLE_DATABASE_ENVIRONMENT_CHECK=1 /usr/local/bundle/bin/bundle exec rake db:schema:load db:seed'

# Database commands
# Restore dump
restore-dump:
bundle exec rake restore_dump
bundle exec rake restore_dump

# Start commands seperated by context
start:
docker-compose up
shell:
docker-compose -f docker-compose.local.yml exec app /bin/bash

start-dumped-decidim:
@make create-database
@make -i restore-dump
@make run-migrations
@make start
start-seeded-decidim:
@make create-database
@make run-migrations
@make create-seeds
@make start
start-clean-decidim:
@make create-database
@make run-migrations
@make start
restart:
docker-compose -f docker-compose.local.yml up -d

status:
docker-compose -f docker-compose.local.yml ps

# Utils commands
rails-console:
docker exec -it decidim-app_app_1 rails c
connect-app:
docker exec -it decidim-app_app_1 bash
logs:
docker-compose -f docker-compose.local.yml logs app

# Stop and delete commands
stop:
docker-compose down
delete:
@make stop
docker volume prune
rebuild:
docker-compose -f docker-compose.local.yml up --build -d
3 changes: 1 addition & 2 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
# require "action_text/engine"
require_relative "../lib/active_storage/downloadable"

# TODO : add missing dep to decidim-initiatives/lib/decidim/initiatives/engine.rb
# require "wicked_pdf"
require "wicked_pdf"

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Expand Down
87 changes: 87 additions & 0 deletions docker-compose.local.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
version: '3'
services:
database:
image: postgres
volumes:
- pg-data:/var/lib/postgresql/data
environment:
- POSTGRES_HOST_AUTH_METHOD=trust
memcached:
image: memcached
ports:
- "11211:11211"
redis:
image: redis
ports:
- "6379:6379"
volumes:
- redis-data:/var/lib/redis/data
sidekiq:
build:
context: .
dockerfile: Dockerfile.local
command: [ "bundle", "exec", "sidekiq", "-C", "config/sidekiq.yml" ]
environment:
- DATABASE_HOST=database
- DATABASE_USERNAME=postgres
- DECIDIM_HOST=localhost
- REDIS_URL=redis://redis:6379
- MEMCACHE_SERVERS=memcached:11211
- RAILS_SERVE_STATIC_FILES=true
- RAILS_LOG_TO_STDOUT=true
- ASSET_HOST=localhost:3000
- FORCE_SSL=1
- ENABLE_LETTER_OPENER=1
- SEED=true
- DEFACE_ENABLED=false
- QUESTION_CAPTCHA_HOST=
- ENABLE_RACK_ATTACK=0
- PUMA_MIN_THREADS=5
- PUMA_MAX_THREADS=5
- PUMA_WORKERS=4
- PUMA_PRELOAD_APP=true
- RAILS_SESSION_STORE=active_record
depends_on:
- app
volumes:
- shared-volume:/app
links:
- database
- redis
app:
build:
context: .
dockerfile: Dockerfile.local
environment:
- DATABASE_HOST=database
- DATABASE_USERNAME=postgres
- DECIDIM_HOST=localhost
- REDIS_URL=redis://redis:6379
- MEMCACHE_SERVERS=memcached:11211
- RAILS_SERVE_STATIC_FILES=true
- RAILS_LOG_TO_STDOUT=true
- ASSET_HOST=localhost:3000
- FORCE_SSL=1
- ENABLE_LETTER_OPENER=1
- SEED=true
- DEFACE_ENABLED=false
- QUESTION_CAPTCHA_HOST=
- ENABLE_RACK_ATTACK=0
- PUMA_MIN_THREADS=5
- PUMA_MAX_THREADS=5
- PUMA_WORKERS=4
- PUMA_PRELOAD_APP=true
- RAILS_SESSION_STORE=active_record
volumes:
- shared-volume:/app
ports:
- 3000:3000
depends_on:
- database
- redis
- memcached

volumes:
shared-volume: { }
pg-data: { }
redis-data: { }
Loading

0 comments on commit 56c8644

Please sign in to comment.