Skip to content

Commit

Permalink
WIP: Container image cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
hennevogel committed Mar 14, 2022
1 parent 6723565 commit bad9d30
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 56 deletions.
100 changes: 52 additions & 48 deletions .circleci/conditional_config.yml
Expand Up @@ -17,7 +17,7 @@ parameters:
type: boolean
default: false

run-root-rubocop:
run-dist-linter:
type: boolean
default: false

Expand All @@ -39,23 +39,42 @@ images:

- &backend registry.opensuse.org/obs/server/unstable/containers/containers/openbuildservice/backend:latest

- &frontend_backend
image: registry.opensuse.org/obs/server/unstable/containers/containers/openbuildservice/frontend-backend:latest
- &frontend_minitest
image: registry.opensuse.org/obs/server/unstable/containers/ruby31/containers/openbuildservice/frontend-minitest:latest
<<: *common_frontend_config
environment:
EAGER_LOAD: 1

- &frontend_base
image: registry.opensuse.org/obs/server/unstable/containers/containers/openbuildservice/frontend-base:latest
image: registry.opensuse.org/obs/server/unstable/containers/ruby31/containers/openbuildservice/frontend-base:latest
<<: *common_frontend_config

- &frontend_base_ci
image: registry.opensuse.org/obs/server/unstable/containers/containers/openbuildservice/frontend-base-ci:latest
- &frontend_features
image: registry.opensuse.org/obs/server/unstable/containers/ruby31/containers/openbuildservice/frontend-features:latest
aliases:
- &restore_bundler_cache
restore_cache:
name: Restoring Bundle Cache
key: bundle-{{ checksum "src/api/Gemfile.lock" }}

- &install_dependencies
name: install dependencies
command: |
cd ./src/api && bundle install --jobs=4 --retry=3
cd ./src/api
bundle config build.ffi --enable-system-libffi
bundle config build.nokogiri --use-system-libraries
bundle config build.sassc --disable-march-tune-native
bundle config build.nio4r --with-cflags='-Wno-return-type'
bundle config set --local path 'vendor/bundle'
bundle install --jobs=4 --retry=3 --local
- &save_bundler_cache
save_cache:
name: Saving Bundle Cache
key: bundle-{{ checksum "src/api/Gemfile.lock" }}
paths:
- "src/api/vendor/bundle"

- &wait_for_database
name: Wait for DB
command: mysqladmin ping -h db
Expand Down Expand Up @@ -103,11 +122,13 @@ aliases:
- &restore_rubocop_cache
restore_cache:
key: circlev2-{{ .Branch }}-{{ checksum "./src/api/Gemfile.lock" }}
name: Restoring Rubocop Cache
key: rubocop-{{ .Branch }}-{{ checksum "./src/api/Gemfile.lock" }}

- &save_rubocop_cache
save_cache:
key: circlev2-{{ .Branch }}-{{ checksum "./src/api/Gemfile.lock" }}
name: Saving Rubocop Cache
key: rubocop-{{ .Branch }}-{{ checksum "./src/api/Gemfile.lock" }}
paths:
- src/api/tmp/rubocop_cache_root_dir
- src/api/tmp/rubocop_cache_rails_dir
Expand All @@ -121,15 +142,21 @@ jobs:
- run: echo "run-backend-tests is << pipeline.parameters.run-backend-tests >>"
- run: echo "run-javascripts-linter is << pipeline.parameters.run-javascripts-linter >>"
- run: echo "run-migrations-tests is << pipeline.parameters.run-migrations-tests >>"
- run: echo "run-root-rubocop is << pipeline.parameters.run-root-rubocop >>"
- run: echo "run-dist-linter is << pipeline.parameters.run-dist-linter >>"
- run: echo "run-haml-linter is << pipeline.parameters.run-haml-linter >>"

linters:
docker:
- <<: *frontend_base_ci
- <<: *frontend_base
steps:
- attach_workspace:
at: .
- run:
name: Run rubocop
command: |
cd src/api;
bundle exec rake dev:lint:rubocop:all
- *save_rubocop_cache
- when:
condition: << pipeline.parameters.run-javascripts-linter >>
steps:
Expand All @@ -140,25 +167,15 @@ jobs:
name: Run jshint
command: cd src/api && jshint app/assets/javascripts
- when:
condition: << pipeline.parameters.run-root-rubocop >>
condition: << pipeline.parameters.run-dist-linter >>
steps:
- *restore_rubocop_cache
- run:
name: Run rubocop on root
command: |
cd src/api
bundle exec rake dev:lint:rubocop:root
- *save_rubocop_cache
- run:
name: Run dist linters
command: |
ls -l
make -C dist scripts_linters
- when:
condition: << pipeline.parameters.run-haml-linter >>
steps:
- run: *install_dependencies
- run:
name: Run HAML linter
command: |
Expand All @@ -171,24 +188,18 @@ jobs:
name: Run Documentation linter
command: |
cd src/api
find public/apidocs-new -name '*.yaml' | xargs -P8 -I % ruby -e "require 'yaml'; YAML.load_file '%'"
checkout_code:
docker:
- <<: *frontend_base_ci
- <<: *frontend_base
steps:
- checkout
- *restore_bundler_cache
- *restore_rubocop_cache
- run: *install_dependencies
- *save_bundler_cache
- run: *install_circle_cli
- *restore_rubocop_cache
- run:
name: Run src/api rubocop
command: |
cd src/api;
bundle exec rake dev:lint:rubocop:rails
- run: rm -rf src/api/tmp/rubocop*
- *save_rubocop_cache
- run:
name: Setup application
command: cd src/api; bundle exec rake dev:prepare assets:precompile RAILS_ENV=test FORCE_EXAMPLE_FILES=1
Expand All @@ -205,7 +216,6 @@ jobs:
steps:
- attach_workspace:
at: .
- run: *install_dependencies
- run: *wait_for_database
- run: *create_test_db
- run: mkdir /home/frontend/rspec
Expand Down Expand Up @@ -240,12 +250,11 @@ jobs:
minitest:
parallelism: 2
docker:
- <<: *frontend_backend
- <<: *frontend_minitest
- <<: *mariadb
steps:
- attach_workspace:
at: .
- run: *install_dependencies
- run: *init_git_submodule
- run: *wait_for_database
- run: *bootstrap_old_test_suite
Expand Down Expand Up @@ -276,12 +285,11 @@ jobs:

migrations_tests:
docker:
- <<: *frontend_base_ci
- <<: *frontend_base
- <<: *mariadb
steps:
- attach_workspace:
at: .
- run: *install_dependencies
- run: *init_git_submodule
- run: *wait_for_database
- run:
Expand All @@ -293,14 +301,14 @@ jobs:
bundle exec rake db:migrate
bundle exec rake db:seed
bundle exec rake data:migrate
spider:
docker:
- <<: *frontend_backend
- <<: *frontend_minitest
- <<: *mariadb
steps:
- attach_workspace:
at: .
- run: *install_dependencies
- run: *init_git_submodule
- run: *wait_for_database
- run: *bootstrap_old_test_suite
Expand All @@ -324,12 +332,10 @@ jobs:

coverage:
docker:
- <<: *frontend_base_ci

- <<: *frontend_base
steps:
- attach_workspace:
at: .
- run: *install_dependencies
- run:
name: Merge and check coverage
command: |
Expand All @@ -346,12 +352,11 @@ jobs:
feature:
parallelism: 2
docker:
- <<: *frontend_base
- <<: *frontend_features
- <<: *mariadb
steps:
- attach_workspace:
at: .
- run: *install_dependencies
- run: *wait_for_database
- run: *create_test_db
- run: mkdir /home/frontend/feature
Expand Down Expand Up @@ -382,14 +387,13 @@ jobs:

next_rails-rspec:
docker:
- <<: *frontend_base
- <<: *frontend_features
- <<: *mariadb
environment:
BUNDLE_GEMFILE: Gemfile.next
steps:
- attach_workspace:
at: .
- run: *install_dependencies
- run: *init_git_submodule
- run: *create_test_db
- run: *wait_for_database
Expand All @@ -402,14 +406,13 @@ jobs:

next_rails-minitest:
docker:
- <<: *frontend_backend
- <<: *frontend_minitest
- <<: *mariadb
environment:
BUNDLE_GEMFILE: Gemfile.next
steps:
- attach_workspace:
at: .
- run: *install_dependencies
- run: *init_git_submodule
- run: *wait_for_database
- run: *bootstrap_old_test_suite
Expand All @@ -431,6 +434,7 @@ workflows:
- migrations_tests:
requires:
- checkout_code

backend_tests:
when: << pipeline.parameters.run-backend-tests >>
jobs:
Expand Down
2 changes: 1 addition & 1 deletion .circleci/config.yml
Expand Up @@ -15,7 +15,7 @@ workflows:
- path-filtering/filter:
name: Define dynamic CI pipeline
mapping: |
(dist|contrib)/.* run-root-rubocop true
dist/.* run-dist-linter true
src/backend/.* run-backend-tests true
src/api/app/(views|components)/.* run-haml-linter true
src/api/db/.* run-migrations-tests true
Expand Down
11 changes: 8 additions & 3 deletions src/api/docker-files/Dockerfile
Expand Up @@ -3,7 +3,7 @@
# contained rails app generating files in the git checkout with
# some strange user...

FROM registry.opensuse.org/obs/server/unstable/containers/containers/openbuildservice/frontend-base
FROM registry.opensuse.org/obs/server/unstable/containers/ruby31/containers/openbuildservice/frontend-features:latest
ARG CONTAINER_USERID

# for lint task
Expand All @@ -27,9 +27,14 @@ RUN chown -R frontend /obs/src/api
USER frontend
WORKDIR /obs/src/api

ENV BUNDLE_BUILD__SASSC=--disable-march-tune-native
# Configure our bundle
RUN bundle config build.ffi --enable-system-libffi; \
bundle config build.nokogiri --use-system-libraries; \
bundle config build.sassc --disable-march-tune-native; \
bundle config build.nio4r --with-cflags='-Wno-return-type'

# Refresh our bundle
RUN export NOKOGIRI_USE_SYSTEM_LIBRARIES=1; bundle install --jobs=3 --retry=3 || bundle install --jobs=3 --retry=3
RUN bundle install --jobs=3 --retry=3

# Run our command
CMD ["foreman", "start", "-f", "Procfile"]
14 changes: 10 additions & 4 deletions src/api/docker-files/Dockerfile.minitest
@@ -1,8 +1,8 @@
# This is just a thin layer on top of the frontend-backend container that makes
# This is just a thin layer on top of the frontend-minitest container that makes
# sure different users can run it without the contained rails app generating
# files in the git checkout with some strange user...

FROM registry.opensuse.org/obs/server/unstable/containers/containers/openbuildservice/frontend-backend
FROM registry.opensuse.org/obs/server/unstable/containers/containers/openbuildservice/frontend-minitest

# Configure our user
ARG CONTAINER_USERID
Expand All @@ -21,8 +21,14 @@ RUN chown -R frontend /obs/src/api
USER frontend
WORKDIR /obs/src/api

# Refresh our bundle
RUN export NOKOGIRI_USE_SYSTEM_LIBRARIES=1; bundle install --jobs=3 --retry=3 || bundle install --jobs=3 --retry=3
# Configure our bundle
RUN bundle config build.ffi --enable-system-libffi; \
bundle config build.nokogiri --use-system-libraries; \
bundle config build.sassc --disable-march-tune-native; \
bundle config build.nio4r --with-cflags='-Wno-return-type'

# Install our bundle
RUN bundle install --jobs=3 --retry=3

CMD ["/bin/bash", "-l"]

0 comments on commit bad9d30

Please sign in to comment.