{"id":18445906,"url":"https://github.com/voronenko/container-image-boilerplate","last_synced_at":"2025-04-15T01:49:48.517Z","repository":{"id":145344995,"uuid":"104213394","full_name":"Voronenko/container-image-boilerplate","owner":"Voronenko","description":"Boilerplate for compiling custom docker image with ansible-container \u0026 docker","archived":false,"fork":false,"pushed_at":"2017-09-20T17:58:56.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-15T01:49:40.221Z","etag":null,"topics":["ansible-container","docker","oops-to-devops"],"latest_commit_sha":null,"homepage":null,"language":"Makefile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Voronenko.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-09-20T12:36:30.000Z","updated_at":"2017-09-23T12:00:32.000Z","dependencies_parsed_at":"2023-07-03T09:17:19.780Z","dependency_job_id":null,"html_url":"https://github.com/Voronenko/container-image-boilerplate","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Voronenko%2Fcontainer-image-boilerplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Voronenko%2Fcontainer-image-boilerplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Voronenko%2Fcontainer-image-boilerplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Voronenko%2Fcontainer-image-boilerplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Voronenko","download_url":"https://codeload.github.com/Voronenko/container-image-boilerplate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248991539,"owners_count":21194894,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansible-container","docker","oops-to-devops"],"created_at":"2024-11-06T07:07:51.234Z","updated_at":"2025-04-15T01:49:48.500Z","avatar_url":"https://github.com/Voronenko.png","language":"Makefile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# boilerplate repo\n\nCheck for usage details:\n   \n* https://github.com/softasap/sa-container-bootstrap\n   \n* https://github.com/Voronenko/devops-docker-baseimage-demo\n\n\n## Image building boilerplate with ansible-container\n\n### Folders and files organization\n\nYou can launch building process using any tool you like.  From my experience - I've come so far with the following approach: https://github.com/Voronenko/container-image-boilerplate\n\n`requirements.txt` - defines any specific py tools \u0026 libs you want to use together with ansible-container.\n`.projmodules` - list of dependencies (roles, deployables, etc) needed to compile base image. Format similar to gitmodules, but without direct links to commit. Example:\n\n```\n\n[submodule \"roles/sa-nginx-container\"]\n        path = roles/softasap.sa-nginx-container\n        url = https://github.com/softasap/sa-nginx-container.git\n[submodule \"roles/sa-uwsgi-container\"]\n        path = roles/softasap.sa-uwsgi-container\n        url = https://github.com/softasap/sa-uwsgi-container.git\n[submodule \"roles/sa-include\"]\n        path = roles/softasap.sa-include\n        url = https://github.com/softasap/sa-include.git\n[submodule \"deployables/application\"]\n        path = deployables/application\n        url = https://github.com/voronenko-p/django-sample.git\n\n```\n\n`init.sh` \u0026\u0026 `init_quick.sh` - resolve external dependencies under specified locations (roles under roles, deployables under deployables, etc)\n\n`ansible.cfg` - by default empty, but you can adjust parameters for your build process according to documentation.\n\n`version.txt` - information file gitflow based releasing (x.y.z)\n\n`image.txt` - additional information about image constructed for tagging and pushing parts.\n\n`Makefile` \u0026\u0026 `docker-helper.sh` - orchestration utilities, discussed in the next chapter.\n\n`docker-compose.yml` - usually I also provide docker-compose configuration, so the image can be immediately tried.\n\n`container.yml` - definition of the image you are going to build\n\nAnd, of course, `.gitignore` - we definitely do not want to commit external resources. `p-env` - virtual environment created during the build, `ansible-deployment` - transient output produced by ansible-container itself.\n```\nroles/*\nansible-deployment/*\np-env/*\ndeployables/*\n*.retry\n```\n\n### Build process orchestration\n\nMakefile implements following phases: `initialize`\n\n#### clean\n\nResets project to initial state by removing all build directories and artifacts\n\n```\nclean:\n        @rm -rf .Python p-env roles ansible-deployment\n```\n\n\n#### Initialize \nParses .projmodules and checks out necessary roles and deployables\n```\ninitialize:\n        @init_quick.sh\n```\n\n#### p-env/bin/ansible-container\nInternal task - creates and initializes virtual environment with ansible-container under p-env/ directory.\n\n```\np-env/bin/ansible-container: p-env/bin/pip\n        @touch $@\n\np-env/bin/pip: p-env/bin/python\n        p-env/bin/pip install -r requirements.txt\n\np-env/bin/python:\n        virtualenv -p $(python) --no-site-packages p-env\n        @touch $@\n```\n\n#### build\nExecutes ansible-container for container.yml, providing path to roles. Project name influences how produced image will be named.\n\n```\nbuild:  p-env/bin/ansible-container\n        @p-env/bin/ansible-container --debug --project-name $(ROLE_NAME) build --roles-path ./roles/ -- -vvv\n        @echo \"Application docker image was build\"\n```\n\n#### run and stop\nPotentially, ansible-container allows immediatelly to run and stop images in a way like docker-compose does. From my experience, that is not always working,\n+ container.yml is based on 2nd version of the docker-compose spec, while I usually need at least 3.1 in production. Anyway steps are provided - they might work in your case. I usually end with the separate docker-compose.yml v3.1+ in the directory.\n\n```\nrun:  p-env/bin/ansible-container\n        @echo p-env/bin/ansible-container --debug --project-name $(ROLE_NAME) run --roles-path ./roles/ -- -vvv\n        @p-env/bin/ansible-container --debug --project-name $(ROLE_NAME) run --roles-path ./roles/ -- -vvv\n        @echo \"Application environment was started\"\n\nstop:   p-env/bin/ansible-container\n        @echo p-env/bin/ansible-container --debug --project-name $(ROLE_NAME) stop\n        @p-env/bin/ansible-container --debug --project-name $(ROLE_NAME) stop\n        @echo \"Application environment was stopped\"\n```\n\n#### tag and push\nUsually as a result of successful build, you want to push artifact to some registry.\nThis highly depends on your project, and you most likely adjust it for your needs.\n\nProviding example: properly tags api and nginx images built and pushes them to docker hub.\n```\ntag:\n        @docker tag $(ROLE_NAME)-api:latest softasap/sa-container-box-examples:$(ROLE_NAME).api.$(ROLE_VERSION)\n        @docker tag $(ROLE_NAME)-api:latest softasap/sa-container-box-examples:$(ROLE_NAME).api.latest\n        @docker tag $(ROLE_NAME)-nginx:latest softasap/sa-container-box-examples:$(ROLE_NAME).nginx.$(ROLE_VERSION)\n        @docker tag $(ROLE_NAME)-nginx:latest softasap/sa-container-box-examples:$(ROLE_NAME).nginx.latest\n\npush:\n        @docker push softasap/sa-container-box-examples:$(ROLE_NAME).api.$(ROLE_VERSION)\n        @docker push softasap/sa-container-box-examples:$(ROLE_NAME).api.latest\n        @docker push softasap/sa-container-box-examples:$(ROLE_NAME).nginx.$(ROLE_VERSION)\n        @docker push softasap/sa-container-box-examples:$(ROLE_NAME).nginx.latest\n\n\n```\n\n#### compose helpers\n\nLaunching, stoppling and dismounting docker-compose managed containers.\n\n```\ncompose-up:\n        @docker-compose up --no-recreate\n\ncompose-stop:\n        @docker-compose stop\n\ncompose-down: compose-stop\n        @docker-compose rm --force\n```        \n\nThat's all.  Back to primary target.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvoronenko%2Fcontainer-image-boilerplate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvoronenko%2Fcontainer-image-boilerplate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvoronenko%2Fcontainer-image-boilerplate/lists"}