Skip to content

Commit

Permalink
bump: Bump remaining files
Browse files Browse the repository at this point in the history
  • Loading branch information
AyakorK committed Jan 19, 2024
1 parent 9f4e277 commit 8036655
Show file tree
Hide file tree
Showing 10 changed files with 929 additions and 383 deletions.
23 changes: 15 additions & 8 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
tmp
log
.circleci
.bundle
.ruby-version
.tool-versions
.overloads
.git
.gitignore
node_modules
public/uploads
deploy
.idea
.github
.rubocop*
.erb-lint.yml
.env-example
.env
.dockerignore
Procfile
tmp
log
docs
node_modules
public/uploads
storage
vendor
public/packs-test
deploy
spec
.idea
.github
README.md
Dockerfile
docker-compose.prod.yml
docker-compose.yml
OVERLOADS.md
Makefile
Makefile
29 changes: 26 additions & 3 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,22 @@ jobs:
with:
ruby_version: ${{ env.RUBY_VERSION }}
node_version: ${{ env.NODE_VERSION }}
zeitwerk:
name: Check for Zeitwerk errors
runs-on: ubuntu-latest
if: "!startsWith(github.head_ref, 'chore/l10n')"
timeout-minutes: 60
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ env.RUBY_VERSION }}
bundler-cache: true
- name: Check for Zeitwerk errors
run: |
bundle exec rails zeitwerk:check
tests:
strategy:
fail-fast: false
Expand Down Expand Up @@ -89,6 +105,8 @@ jobs:
- run: mkdir -p ./spec/tmp/screenshots
name: Create the screenshots folder
- uses: nanasess/setup-chromedriver@v2
with:
chromedriver-version: 119.0.6045.105
- run: bundle exec rake "test:run[exclude, spec/system/**/*_spec.rb, ${{ matrix.slice }}]"
name: RSpec
- run: ./.github/upload_coverage.sh decidim-app $GITHUB_EVENT_PATH
Expand All @@ -105,6 +123,7 @@ jobs:
path: ./tmp/assets_manifest.json
system_tests:
strategy:
fail-fast: false
matrix:
slice: [ "0-4", "1-4", "2-4", "3-4" ]
name: System tests
Expand Down Expand Up @@ -154,6 +173,8 @@ jobs:
- run: mkdir -p ./spec/tmp/screenshots
name: Create the screenshots folder
- uses: nanasess/setup-chromedriver@v2
with:
chromedriver-version: 119.0.6045.105
- run: bundle exec rake "test:run[include, spec/system/**/*_spec.rb, ${{ matrix.slice }}]"
name: RSpec
- run: ./.github/upload_coverage.sh decidim-app $GITHUB_EVENT_PATH
Expand Down Expand Up @@ -197,10 +218,12 @@ jobs:
database_username: ${{ env.DATABASE_USERNAME }}
database_password: ${{ env.DATABASE_PASSWORD }}
database_host: ${{ env.DATABASE_HOST }}
# We don't want to upload the image to the registry if the build fails, but we don't care when on a PR for speed reasons
push: ${{ github.ref != 'refs/heads/develop' || github.ref != 'refs/heads/master' }}
build_and_push_image_dev:
name: Build and push image to Registry
if: "github.ref == 'refs/heads/develop'"
needs: [lint, tests, system_tests, test_build]
name: Build and push image to Registry
needs: [ lint, zeitwerk, tests, system_tests, test_build ]
runs-on: ubuntu-latest
steps:
- uses: OpenSourcePolitics/build-and-push-images-action@master
Expand All @@ -209,7 +232,7 @@ jobs:
namespace: ${{ vars.REGISTRY_NAMESPACE }}
password: ${{ secrets.TOKEN }}
image_name: ${{ vars.IMAGE_NAME }}
tag: "develop"
tag: ${{ github.ref }}
generate_release:
name: Generate release
needs: [lint, tests, system_tests, test_build]
Expand Down
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
15.14.0
16.9.1
55 changes: 37 additions & 18 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,37 +1,56 @@
FROM ruby:2.7.5
FROM ruby:3.0.6-slim as builder

ENV RAILS_ENV=production \
SECRET_KEY_BASE=dummy

WORKDIR /app

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

COPY Gemfile* ./
RUN bundle config set --local without 'development test' && bundle install
RUN bundle config set --local without 'development test' && \
bundle install -j"$(nproc)"

COPY package* ./
COPY yarn.lock .
COPY packages packages
RUN yarn install
RUN yarn install --frozen-lockfile

COPY . .

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

# Configure endpoint.
COPY ./entrypoint.sh /usr/bin/
RUN chmod +x /usr/bin/entrypoint.sh
ENTRYPOINT ["entrypoint.sh"]
EXPOSE 3000
RUN rm -rf node_modules tmp/cache vendor/bundle spec \
&& rm -rf /usr/local/bundle/cache/*.gem \
&& find /usr/local/bundle/gems/ -name "*.c" -delete \
&& find /usr/local/bundle/gems/ -name "*.o" -delete \
&& find /usr/local/bundle/gems/ -type d -name "spec" -prune -exec rm -rf {} \; \
&& rm -rf log/*.log

FROM ruby:3.0.6-slim as runner

ENV RAILS_ENV=production \
SECRET_KEY_BASE=dummy \
RAILS_LOG_TO_STDOUT=true

RUN apt update && \
apt install -y postgresql-client imagemagick libproj-dev proj-bin libjemalloc2 && \
gem install bundler:2.4.9

CMD ["bundle", "exec", "rails", "server", "-b", "0.0.0.0"]
WORKDIR /app

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

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

EXPOSE 3000
CMD ["bundle", "exec", "rails", "server", "-b", "0.0.0.0"]
56 changes: 56 additions & 0 deletions Dockerfile.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Builder Stage
FROM ruby:3.0.6-slim as builder

ENV RAILS_ENV=production \
SECRET_KEY_BASE=dummy

WORKDIR /app

RUN apt-get update -q && \
apt-get install -yq libpq-dev curl git libicu-dev build-essential openssl && \
curl https://deb.nodesource.com/setup_16.x | bash && \
apt-get install -y nodejs && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
npm install --global yarn && \
gem install bundler:2.4.9

COPY Gemfile Gemfile.lock ./
RUN bundle config set --local without 'development test' && \
bundle install -j"$(nproc)"

COPY package.json yarn.lock ./
COPY packages packages
RUN yarn install --frozen-lock

COPY . .

RUN bundle exec bootsnap precompile --gemfile app/ lib/ config/ bin/ db/ && \
bundle exec rails deface:precompile && \
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:3.0.6-slim 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 /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"]
95 changes: 24 additions & 71 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,83 +1,36 @@
#### 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

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

# Stop and delete commands
stop:
docker-compose down
delete:
@make stop
docker volume prune
logs:
docker-compose -f docker-compose.local.yml logs app
19 changes: 7 additions & 12 deletions babel.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"presets": [
[
"@babel/preset-env", {
"forceAllTransforms": true,
"useBuiltIns": "entry",
"corejs": 3,
"modules": false
}
"forceAllTransforms": true,
"useBuiltIns": "entry",
"corejs": 3,
"modules": false
}
],
["@babel/preset-react"]
],
Expand All @@ -20,11 +20,6 @@
"corejs": false
}
],
[
"@babel/plugin-transform-regenerator",
{
"async": false
}
]
["@babel/plugin-transform-regenerator", { "async": false }]
]
}
}
Loading

0 comments on commit 8036655

Please sign in to comment.