Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
microstudi committed Jul 2, 2024
0 parents commit 3f206ec
Show file tree
Hide file tree
Showing 835 changed files with 182,090 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# See https://git-scm.com/docs/gitattributes for more about git attribute files.

# Mark the database schema as having been generated.
db/schema.rb linguist-generated

# Mark the yarn lockfile as having been generated.
yarn.lock linguist-generated

# Mark any vendored files as having been vendored.
vendor/* linguist-vendored
78 changes: 78 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Test

on:
push:
branches:
- main
- staging
pull_request:

env:
RUBY_VERSION: 3.1.1
NODE_VERSION: 18.17.1

jobs:
test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:11
ports:
- 5432:5432
env:
RAILS_ENV: test
DATABASE_USERNAME: postgres
DATABASE_PASSWORD: postgres
POSTGRES_HOST_AUTH_METHOD: trust
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1

- uses: nanasess/setup-chromedriver@v2
with:
chromedriver-version: 119.0.6045.105

- name: List Chrome
run: apt list --installed | grep chrome

- name: Remove Chrome
run: sudo apt remove google-chrome-stable

- uses: browser-actions/setup-chrome@v1
with:
chrome-version: 119.0.6045.105

- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ env.RUBY_VERSION }}
bundler-cache: true

- run: bundle exec rubocop -P
name: Lint Ruby files

- name: Setup & create Database
run: |
bundle exec rails db:create db:schema:load
env:
RAILS_ENV: test
DATABASE_USERNAME: postgres
DATABASE_PASSWORD: postgres

- name: Precompile assets
run: |
npm ci
bundle exec rake assets:precompile
env:
RAILS_ENV: production
DB_ADAPTER: nulldb
SECRET_KEY_BASE: 1234567890

- name: Run RSpec
run: SIMPLECOV=1 CODECOV=1 bundle exec rspec
env:
RAILS_ENV: test
DATABASE_USERNAME: postgres
DATABASE_PASSWORD: postgres
52 changes: 52 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile '~/.gitignore_global'

# Ignore bundler config.
/.bundle

# Ignore the default SQLite database.
/db/*.sqlite3
/db/*.sqlite3-*

# Ignore all logfiles and tempfiles.
/log/*
/tmp/*
!/log/.keep
!/tmp/.keep

# Ignore pidfiles, but keep the directory.
/tmp/pids/*
!/tmp/pids/
!/tmp/pids/.keep

# Ignore uploaded files in development.
/storage/*
!/storage/.keep

/public/assets
.byebug_history

# Ignore master key for decrypting credentials and more.
/config/master.key

# Ignore env configuration files
.env
.envrc
.rbenv-vars

# Ignore the files and folders generated through Webpack
/public/decidim-packs
/public/packs-test
/public/sw.js
/public/sw.js.map

# Ignore node modules
/node_modules


# Ignore Tailwind configuration
tailwind.config.js
coverage
1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18.17.1
4 changes: 4 additions & 0 deletions .rspec-failures
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
example_id | status | run_time |
----------------------------------- | ------ | --------------- |
./spec/system/homepage_spec.rb[1:1] | passed | 0.74741 seconds |
./spec/system/homepage_spec.rb[1:2] | passed | 2.22 seconds |
7 changes: 7 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
inherit_gem:
decidim-dev: rubocop-decidim.yml

AllCops:
Exclude:
- 'db/**/*.rb'
- 'vendor/**/*'
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.1.1
127 changes: 127 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
FROM ruby:3.1 AS builder

RUN apt-get update && apt-get upgrade -y && apt-get install -y ca-certificates curl gnupg && \
mkdir -p /etc/apt/keyrings && \
curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \
curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
apt-get update && apt-get install -y nodejs yarn \
build-essential \
postgresql-client \
p7zip-full \
libpq-dev && \
apt-get clean

# throw errors if Gemfile has been modified since Gemfile.lock
RUN bundle config --global frozen 1

WORKDIR /app

# Copy package dependencies files only to ensure maximum cache hit
COPY ./package-lock.json /app/package-lock.json
COPY ./package.json /app/package.json
COPY ./Gemfile /app/Gemfile
COPY ./Gemfile.lock /app/Gemfile.lock

RUN gem update --system --source http://rubygems.org/ && \
gem install bundler:$(grep -A 1 'BUNDLED WITH' Gemfile.lock | tail -n 1 | xargs) && \
bundle config --local without 'development test' && \
bundle install -j4 --retry 3 && \
# Remove unneeded gems
bundle clean --force && \
# Remove unneeded files from installed gems (cache, *.o, *.c)
rm -rf /usr/local/bundle/cache && \
find /usr/local/bundle/ -name "*.c" -delete && \
find /usr/local/bundle/ -name "*.o" -delete && \
find /usr/local/bundle/ -name ".git" -exec rm -rf {} + && \
find /usr/local/bundle/ -name ".github" -exec rm -rf {} + && \
# whkhtmltopdf has binaries for all platforms, we don't need them once uncompressed
rm -rf /usr/local/bundle/gems/wkhtmltopdf-binary-*/bin/*.gz && \
# fix possible 7zip problems by manually adding the 7z.so libray
ln -sf /usr/lib/p7zip/7z.so /usr/local/bundle/gems/seven_zip_ruby-1.3.0/lib/seven_zip_ruby/7z.so && \
rm -f /usr/local/bundle/gems/seven_zip_ruby-1.3.0/lib/seven_zip_ruby/*.dll && \
# Remove additional unneded decidim files
find /usr/local/bundle/ -name "decidim_app-design" -exec rm -rf {} + && \
find /usr/local/bundle/ -name "spec" -exec rm -rf {} +

RUN npm ci

# copy the rest of files
COPY ./app /app/app
COPY ./bin /app/bin
COPY ./config /app/config
COPY ./db /app/db
COPY ./lib /app/lib
COPY ./packages /app/packages
COPY ./public/*.* /app/public/
COPY ./config.ru /app/config.ru
COPY ./Rakefile /app/Rakefile
COPY ./babel.config.json /app/babel.config.json
COPY ./postcss.config.js /app/postcss.config.js

# Compile assets with Webpacker or Sprockets
#
# Notes:
# 1. Executing "assets:precompile" runs "webpacker:compile", too
# 2. For an app using encrypted credentials, Rails raises a `MissingKeyError`
# if the master key is missing. Because on CI there is no master key,
# we hide the credentials while compiling assets (by renaming them before and after)
#
RUN mv config/credentials.yml.enc config/credentials.yml.enc.bak 2>/dev/null || true
RUN mv config/credentials config/credentials.bak 2>/dev/null || true

RUN RAILS_ENV=production \
SECRET_KEY_BASE=dummy \
RAILS_MASTER_KEY=0b809804a9de874fb0627b6cf5b6cada \
DB_ADAPTER=nulldb \
bin/rails assets:precompile

RUN mv config/credentials.yml.enc.bak config/credentials.yml.enc 2>/dev/null || true
RUN mv config/credentials.bak config/credentials 2>/dev/null || true

RUN rm -rf node_modules tmp/cache vendor/bundle test spec app/packs .git

# This image is for production env only
FROM ruby:3.1-slim AS final

RUN apt-get update && apt-get upgrade -y && apt-get install -y ca-certificates curl gnupg && \
apt-get install -y postgresql-client \
imagemagick \
curl \
p7zip-full \
supervisor && \
apt-get clean

EXPOSE 3000

ENV RAILS_LOG_TO_STDOUT true
ENV RAILS_SERVE_STATIC_FILES true
ENV RAILS_ENV production

ARG RUN_RAILS
ARG RUN_SIDEKIQ
ARG COMMIT_SHA
ARG COMMIT_TIME
ARG COMMIT_VERSION

ENV COMMIT_SHA ${COMMIT_SHA}
ENV COMMIT_TIME ${COMMIT_TIME}
ENV COMMIT_VERSION ${COMMIT_VERSION}

# Add user
RUN addgroup --system --gid 1000 app && \
adduser --system --uid 1000 --home /app --group app

WORKDIR /app
COPY ./entrypoint.sh /app/entrypoint.sh
COPY ./supervisord.conf /etc/supervisord.conf
COPY --from=builder --chown=app:app /usr/local/bundle/ /usr/local/bundle/
COPY --from=builder --chown=app:app /app /app

USER app
HEALTHCHECK --interval=1m --timeout=5s --start-period=30s \
CMD (curl -sSH "Content-Type: application/json" -d '{"query": "{ decidim { version } }"}' http://localhost:3000/api) || exit 1


ENTRYPOINT ["/app/entrypoint.sh"]
CMD ["/usr/bin/supervisord"]
46 changes: 46 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# frozen_string_literal: true

source "http://rubygems.org"

ruby RUBY_VERSION

DECIDIM_VERSION = { github: "decidim/decidim", branch: "release/0.28-stable"}.freeze

gem "decidim", DECIDIM_VERSION
gem "decidim-conferences", DECIDIM_VERSION
# gem "decidim-design", DECIDIM_VERSION
# gem "decidim-elections", DECIDIM_VERSION
# gem "decidim-initiatives", DECIDIM_VERSION
gem "decidim-templates", DECIDIM_VERSION

gem "decidim-decidim_awesome", github: "decidim-ice/decidim-module-decidim_awesome", branch: "develop"

gem "bootsnap", "~> 1.3"

gem "puma", ">= 6.3.1"

gem "wicked_pdf", "~> 2.1"

group :development, :test do
gem "byebug", "~> 11.0", platform: :mri

gem "brakeman", "~> 5.4"
gem "decidim-dev", DECIDIM_VERSION
gem "net-imap", "~> 0.2.3"
gem "net-pop", "~> 0.1.1"
gem "net-smtp", "~> 0.3.1"
end

group :development do
gem "letter_opener_web", "~> 2.0"
gem "listen", "~> 3.1"
gem "spring", "~> 2.0"
gem "spring-watcher-listen", "~> 2.0"
gem "web-console", "~> 4.2"
end

group :production do
gem "azure-storage-blob", require: false
gem "sidekiq"
gem "sidekiq-cron"
end
Loading

0 comments on commit 3f206ec

Please sign in to comment.