{"id":19817012,"url":"https://github.com/geoadmin/service-icons","last_synced_at":"2025-05-01T10:33:26.506Z","repository":{"id":38193329,"uuid":"279530403","full_name":"geoadmin/service-icons","owner":"geoadmin","description":"Microservice to change the color of png/jpeg icons. Managed by geoadmin/infra-terraform-github-bgdi","archived":false,"fork":false,"pushed_at":"2024-02-02T10:48:21.000Z","size":1099,"stargazers_count":2,"open_issues_count":6,"forks_count":2,"subscribers_count":15,"default_branch":"develop","last_synced_at":"2024-04-16T02:00:13.549Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/geoadmin.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":"2020-07-14T08:41:31.000Z","updated_at":"2024-05-03T10:38:59.256Z","dependencies_parsed_at":"2024-05-03T10:48:58.066Z","dependency_job_id":null,"html_url":"https://github.com/geoadmin/service-icons","commit_stats":null,"previous_names":[],"tags_count":53,"template":false,"template_full_name":"geoadmin/template-service-flask","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geoadmin%2Fservice-icons","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geoadmin%2Fservice-icons/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geoadmin%2Fservice-icons/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geoadmin%2Fservice-icons/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/geoadmin","download_url":"https://codeload.github.com/geoadmin/service-icons/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224253452,"owners_count":17280934,"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":[],"created_at":"2024-11-12T10:11:27.431Z","updated_at":"2025-05-01T10:33:26.500Z","avatar_url":"https://github.com/geoadmin.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# service-icons\n\n| Branch  | Status                                                                                                                                                                                                                                                                                                                      |\n| ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| develop | ![Build Status](https://codebuild.eu-central-1.amazonaws.com/badges?uuid=eyJlbmNyeXB0ZWREYXRhIjoiRmo5bFozbUlSKzdZQ2xIQ1JYL1lDKzBJM2hNS2FBZkNVeFo1WS82ZnNrL2hjVHRqTTJzYmJWRGxaRGdTeFRmWFFDYlNIeU5sa3FDVVVIMjlBMHFtL1BZPSIsIml2UGFyYW1ldGVyU3BlYyI6ImdSMlBoSEJZYlBVYW9UVVIiLCJtYXRlcmlhbFNldFNlcmlhbCI6MX0%3D\u0026branch=develop) |\n| master  | ![Build Status](https://codebuild.eu-central-1.amazonaws.com/badges?uuid=eyJlbmNyeXB0ZWREYXRhIjoiRmo5bFozbUlSKzdZQ2xIQ1JYL1lDKzBJM2hNS2FBZkNVeFo1WS82ZnNrL2hjVHRqTTJzYmJWRGxaRGdTeFRmWFFDYlNIeU5sa3FDVVVIMjlBMHFtL1BZPSIsIml2UGFyYW1ldGVyU3BlYyI6ImdSMlBoSEJZYlBVYW9UVVIiLCJtYXRlcmlhbFNldFNlcmlhbCI6MX0%3D\u0026branch=master)  |\n\n## Table of content\n\n- [Table of content](#table-of-content)\n- [Description](#description)\n- [Dependencies](#dependencies)\n- [Service API](#service-api)\n- [Versioning](#versioning)\n- [Local Development](#local-development)\n  - [Make Dependencies](#make-dependencies)\n  - [Setting up to work](#setting-up-to-work)\n  - [Linting and formatting your work](#linting-and-formatting-your-work)\n  - [Test your work](#test-your-work)\n- [Docker](#docker)\n- [Maintenance](#maintenance)\n  - [Convert Symbols from svg to png](#convert-symbols-from-svg-to-png)\n- [Deployment](#deployment)\n  - [Deployment configuration](#deployment-configuration)\n\n## Description\n\nA simple REST microservice meant to take a symbol (defined by a filename), to colorized it with a color defined by r, g and b values and to return the colorized symbol.\n\n## Dependencies\n\nThis service doesn't have any external dependencies\n\n## Service API\n\nThe service has the following endpoints:\n\n- `GET /checker`\n- `GET /sets`\n- `GET /sets/\u003cicon_set_name\u003e`\n- `GET /sets/\u003cicon_set_name\u003e/icons`\n- `GET /sets/\u003cicon_set_name\u003e/icons/\u003cicon_name\u003e`\n- `GET /sets/\u003cicon_set_name\u003e/icons/\u003cicon_name\u003e.png`\n- `GET /sets/\u003cicon_set_name\u003e/icons/\u003cicon_name\u003e-\u003cred\u003e,\u003cgreen\u003e,\u003cblue\u003e.png`\n- `GET /sets/\u003cicon_set_name\u003e/icons/\u003cicon_name\u003e@\u003cscale\u003e.png`\n- `GET /sets/\u003cicon_set_name\u003e/icons/\u003cicon_name\u003e@\u003cscale\u003e-\u003cred\u003e,\u003cgreen\u003e,\u003cblue\u003e.png`\n\nA detailed descriptions of the endpoints can be found in the [OpenAPI Spec](https://github.com/geoadmin/doc-api-specs) repository.\n\n## Versioning\n\nThis service uses [SemVer](https://semver.org/) as versioning scheme. The versioning is automatically handled by `.github/workflows/main.yml` file.\n\nSee also [Git Flow - Versioning](https://github.com/geoadmin/doc-guidelines/blob/master/GIT_FLOW.md#versioning) for more information on the versioning guidelines.\n\n## Local Development\n\n### Make Dependencies\n\nThe **Make** targets assume you have **python3.12**, **pipenv**, **bash**, **curl**, **tar**, **docker** and **docker-compose** installed.\n\n### Setting up to work\n\nFirst, you'll need to clone the repo\n\n```bash\ngit clone git@github.com:geoadmin/service-icons\n```\n\nThen, you can run the setup target to ensure you have everything needed to develop, test and serve locally\n\n```bash\nmake dev\n```\n\nThat's it, you're ready to work.\n\n### Linting and formatting your work\n\nIn order to have a consistent code style the code should be formatted using `yapf`. Also to avoid syntax errors and non\npythonic idioms code, the project uses the `pylint` linter. Both formatting and linter can be manually run using the\nfollowing command:\n\n```bash\nmake format-lint\n```\n\n**Formatting and linting should be at best integrated inside the IDE, for this look at\n[Integrate yapf and pylint into IDE](https://github.com/geoadmin/doc-guidelines/blob/master/PYTHON.md#yapf-and-pylint-ide-integration)**\n\n### Test your work\n\nTesting if what you developed work is made simple. You have four targets at your disposal. **test, serve, gunicornserve, dockerrun**\n\n```bash\nmake test\n```\n\nThis command run the integration and unit tests.\n\n```bash\nmake serve\n```\n\nThis will serve the application through Flask without any wsgi in front.\n\n```bash\nmake gunicornserve\n```\n\nThis will serve the application with the Gunicorn layer in front of the application\n\n```bash\nmake dockerrun\n```\n\nThis will serve the application with the wsgi server, inside a container.\n\nHere below are simple examples of how to test the service after serving on localhost:5000:\n\n```bash\ncurl -H \"Origin: www.example.com\" http://localhost:5000/sets/default/icons\ncurl -H \"Origin: www.example.com\" http://localhost:5000/sets/default/icons/001-marker@2x-255,133,133.png --output out.png\n```\n\n*NOTE: if you serve using gunicorn or docker, you need to add the route prefix `/api/icons`*\n\n## Docker\n\nThe service is encapsulated in a Docker image. Images are pushed on the `swisstopo-bgdi-builder` account of [AWS ECR](https://eu-central-1.console.aws.amazon.com/ecr/repositories?region=eu-central-1) registry. From each github PR that is merged into develop branch, one Docker image is built and pushed with the following tags:\n\n- `develop.latest`\n- `CURRENT_VERSION-beta.INCREMENTAL_NUMBER`\n\nFrom each github PR that is merged into master, one Docker image is built and pushed with the following tag:\n\n- `VERSION`\n\nEach image contains the following metadata:\n\n- author\n- git.branch\n- git.hash\n- git.dirty\n- version\n\nThese metadata can be seen directly on the dockerhub registry in the image layers or can be read with the following command\n\n```bash\n# NOTE: jq is only used for pretty printing the json output,\n# you can install it with `apt install jq` or simply enter the command without it\ndocker image inspect --format='{{json .Config.Labels}}' 974517877189.dkr.ecr.eu-central-1.amazonaws.com/service-name:develop.latest | jq\n```\n\nYou can also check these metadata on a running container as follows\n\n```bash\ndocker ps --format=\"table {{.ID}}\\t{{.Image}}\\t{{.Labels}}\"\n```\n\n## Maintenance\n\n### Convert Symbols from svg to png\n\nSometimes it may happen, that we get a new set of icons. In general these icons have to be quadratic in a resolution of 48px x 48px in the format .png. Neverthanless there is a script to convert .svg images towards .png images. This script is located in the folder `scripts/svg2png.py`. There is a help provided\n\n```bash\npipenv run python scripts/svg2png.py --help\n```\n\nHere is an example of such a convertion\n\n```bash\npipenv run python scripts/svg2png.py --help\n```pipenv run python scripts/svg2png.py -I ./tmp/new-icons -O ./static/images/babs2 -W 48 -H 48\n```\n\n## Deployment\n\n### Deployment configuration\n\nThe service is configured by Environment Variable:\n\n| Env         | Default               | Description                |\n| ----------- | --------------------- | -------------------------- |\n| LOGGING_CFG | `logging-cfg-local.yml` | Logging configuration file |\n| CACHE_CONTROL | `public, max-age=86400` | Cache Control header value of the `GET /*` endpoints |\n| CACHE_CONTROL_4XX | `public, max-age=3600` | Cache Control header for 4XX responses |\n| FORWARED_ALLOW_IPS | `*` | Sets the gunicorn `forwarded_allow_ips`. See [Gunicorn Doc](https://docs.gunicorn.org/en/stable/settings.html#forwarded-allow-ips). This setting is required in order to `secure_scheme_headers` to work. |\n| FORWARDED_PROTO_HEADER_NAME | `X-Forwarded-Proto` | Sets gunicorn `secure_scheme_headers` parameter to `{${FORWARDED_PROTO_HEADER_NAME}: 'https'}`. This settings is required in order to generate correct URLs in the service responses. See [Gunicorn Doc](https://docs.gunicorn.org/en/stable/settings.html#secure-scheme-headers). |\n| SCRIPT_NAME | `''` | If the service is behind a reverse proxy and not served at the root, the route prefix must be set in `SCRIPT_NAME`. |\n| WSGI_TIMEOUT | `5` | WSGI timeout. |\n| GUNICORN_TMPFS_DIR | `None` |The working directory for the gunicorn workers. |\n| WSGI_WORKERS | `2` | The number of workers per CPU. | \n| UNLISTED_ICON_SETS | | Comma separated list of icon set to un-list. Those sets won't be listed in the /sets endpoint.  |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeoadmin%2Fservice-icons","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeoadmin%2Fservice-icons","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeoadmin%2Fservice-icons/lists"}