https://github.com/mongodb/sonar
https://github.com/mongodb/sonar
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/mongodb/sonar
- Owner: mongodb
- License: apache-2.0
- Created: 2021-06-02T16:13:23.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-07-12T14:47:27.000Z (10 months ago)
- Last Synced: 2025-01-29T09:43:43.613Z (3 months ago)
- Language: Python
- Size: 104 KB
- Stars: 2
- Watchers: 11
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Project Status
Note: This repository is currently not under active development. While the code and documentation remain accessible for reference and educational purposes, there will be no regular updates, bug fixes, or feature additions in the foreseeable future.
If you encounter issues or have questions, you are welcome to open an issue or a pull request. However, please be aware that responses and reviews may be significantly delayed.
Thank you for your understanding and interest in this project.
# Sonar 🐳
Work with multiple Docker images easily.
**Sonar is currently Work in Progress!**
## What is Sonar
Sonar is a tool that allows you to easily produce, template, build and publish
Dockerfiles and Docker images. It uses a declarative, multi-stage approach to
build Docker images.## Quick start
Sonar can be used as a Python module or as a standalone program. Sonar will look
for an `inventory.yaml` file in your local directory that should contain a
collection of images to build and stages for each one of those images. A
different inventory file can be specified using `--inventory `.Sonar comes with an inventory file to be able to build itself, and to run its
unit tests. This [simple.yaml](inventories/simple.yaml) is:``` yaml
vars:
# start a local registry with:
# docker run -d -p 5000:5000 --restart=always --name registry registry:2
registry: localhost:5000images:
- name: sonar-test-runnervars:
context: .# First stage builds a Docker image. The resulting image will be
# pushed to the registry in the `output` section.
stages:
- name: build-sonar-tester-image
task_type: docker_builddockerfile: docker/Dockerfile
output:
- registry: $(inputs.params.registry)/sonar-tester-image
tag: $(inputs.params.version_id)# Second stage pushes the previously built image into a new
# registry.
- name: tag-image
task_type: tag_imagesource:
registry: $(stages['build-sonar-tester-image'].output[0].registry)
tag: $(stages['build-sonar-tester-image'].output[0].tag)destination:
- registry: $(inputs.params.registry)/sonar-tester-image
tag: latest
```To execute this inventory file, you can do:
```
$ python sonar.py --image sonar-test-runner --inventory inventories/simple.yaml[build-sonar-tester-image/docker_build] stage-started build-sonar-tester-image: 1/2
[build-sonar-tester-image/docker_build] docker-image-push: localhost:5000/sonar-tester-image:8945563b-248e-4c03-bb0a-6cc15cff1a6e
[tag-image/tag_image] stage-started tag-image: 2/2
[tag-image/tag_image] docker-image-push: localhost:5000/sonar-tester-image:latest
```At the end of this phase, you'll have a Docker image tagged as
`localhost:5000/sonar-tester-image:latest` that you will be able to run with:```
$ docker run localhost:5000/sonar-tester-image:latest
============================= test session starts ==============================
platform linux -- Python 3.9.4, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
rootdir: /src
collected 38 itemstest/test_build.py ... [ 7%]
test/test_context.py ......x..... [ 39%]
test/test_sign_image.py .. [ 44%]
test/test_sonar.py ........ [ 65%]
test/test_tag_image.py . [ 68%]
test/test_tags.py ........... [ 97%]
test/test_template.py . [100%]======================== 37 passed, 1 xfailed in 0.52s =========================
```## Legal
Sonar is released under the terms of the [Apache2 license](./LICENSE).