Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
ltshb committed Jun 28, 2021
2 parents d479468 + 81ae1ad commit 679b6dd
Show file tree
Hide file tree
Showing 37 changed files with 1,376 additions and 1,544 deletions.
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.volumes
*/logs
*/logs
/scripts/xxxxxxl_asset_file.zip
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ nose2-junit.xml
.env.*local
.volumes
**/logs
/scripts/xxxxxxl_asset_file.zip

# Node modules
node_modules/*
44 changes: 39 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,12 @@ GIT_TAG := `git describe --tags || echo "no version info"`
AUTHOR := $(USER)

# Docker variables
DOCKER_IMG_LOCAL_TAG = swisstopo/$(SERVICE_NAME):$(USER).$(GIT_TAG)
DOCKER_IMG_LOCAL_TAG_DEV = swisstopo/$(SERVICE_NAME):$(USER).$(GIT_TAG)-dev
DOCKER_REGISTRY = 974517877189.dkr.ecr.eu-central-1.amazonaws.com
DOCKER_IMG_LOCAL_TAG = $(DOCKER_REGISTRY)/$(SERVICE_NAME):$(USER).$(GIT_TAG)
DOCKER_IMG_LOCAL_TAG_DEV = $(DOCKER_REGISTRY)/$(SERVICE_NAME):$(USER).$(GIT_TAG)-dev

# AWS variables
AWS_DEFAULT_REGION = eu-central-1

all: help

Expand All @@ -62,13 +66,20 @@ help:
@echo "- ci Create the python virtual environment and install requirements based on the Pipfile.lock"
@echo -e " \033[1mFORMATING, LINTING AND TESTING TOOLS TARGETS\033[0m "
@echo "- format Format the python source code"
@echo "- ci-check-format Format the python source code and check if any files has changed. This is meant to be used by the CI."
@echo "- lint Lint the python source code"
@echo "- test Run the tests"
@echo -e " \033[1mSPEC TARGETS\033[0m "
@echo "- lint-specs Lint the openapi specs (openapi.yaml and openapitransactional.yaml)"
@echo "- build-specs Build the openapi specs (openapi.yaml and openapitransactional.yaml)"
@echo "- serve-specs Serve openapi specs (openapi.yaml and openapitransactional.yaml)"
@echo -e " \033[1mLOCAL SERVER TARGETS\033[0m "
@echo "- serve Run the project using the django debug server. Port can be set by Env variable HTTP_PORT i(default: 8000)"
@echo "- gunicornserve Run the project using the gunicorn WSGI server. Port can be set by Env variable HTTP_PORT (default: 8000)"
@echo -e " \033[1mDOCKER TARGETS\033[0m "
@echo "- dockerlogin Login to the AWS ECR registery for pulling/pushing docker images"
@echo "- dockerbuild-(debug|prod) Build the project locally (with tag := $(DOCKER_IMG_LOCAL_TAG))"
@echo "- dockerpush-(debug|prod) Build and push the project localy (with tag := $(DOCKER_IMG_LOCAL_TAG))"
@echo "- dockerrun Run the test container with default manage.py command 'runserver'. Note: ENV is populated from '.env.local'"
@echo " Other cmds can be invoked with 'make dockerrun CMD'."
@echo -e " \e[1mNote:\e[0m This will connect to your host Postgres DB. If you wanna test with a containerized DB, run 'docker-compose up'"
Expand Down Expand Up @@ -124,6 +135,14 @@ format:
$(YAPF) -p -i --style .style.yapf $(PYTHON_FILES)
$(ISORT) $(PYTHON_FILES)

.PHONY: ci-check-format
ci-check-format: format
@if [[ -n `git status --porcelain --untracked-files=no` ]]; then \
>&2 echo "ERROR: the following files are not formatted correctly"; \
>&2 echo "'git status --porcelain' reported changes in those files after a 'make format' :"; \
>&2 git status --porcelain --untracked-files=no; \
exit 1; \
fi

# make sure that the code conforms to the style guide. Note that
# - the DJANGO_SETTINGS module must be made available to pylint
Expand Down Expand Up @@ -153,6 +172,10 @@ build-specs:
cd spec && make build-specs


.PHONY: lint-specs
lint-specs:
cd spec && make lint-specs

###################
# Serve targets. Using these will run the application on your local machine. You can either serve with a wsgi front (like it would be within the container), or without.

Expand All @@ -164,15 +187,19 @@ serve:
gunicornserve:
$(PYTHON) $(APP_SRC_DIR)/wsgi.py

.PHONY: serve-spec
serve-spec:
cd spec && make serve-spec
.PHONY: serve-specs
serve-specs:
cd spec && make serve-specs

###################
# Docker related functions.
# Note: the timestamp magic is ommitted here on purpose, we rely on docker's
# change detection mgmt

.PHONY: dockerlogin
dockerlogin:
aws --profile swisstopo-bgdi-builder ecr get-login-password --region $(AWS_DEFAULT_REGION) | docker login --username AWS --password-stdin $(DOCKER_REGISTRY)

.PHONY: dockerbuild-debug
dockerbuild-debug:
docker build \
Expand All @@ -196,6 +223,13 @@ dockerrun: dockerbuild-debug
@echo "starting docker debug container with populating ENV from .env.local"
docker run -it --rm --env-file .env.local --net=host $(DOCKER_IMG_LOCAL_TAG_DEV) ./manage.py runserver

.PHONY: dockerpush-debug
dockerpush-debug: dockerbuild-debug
docker push $(DOCKER_IMG_LOCAL_TAG_DEV)

.PHONY: dockerpush-prod
dockerpush-prod: dockerbuild-prod
docker push $(DOCKER_IMG_LOCAL_TAG)

###################
# clean targets
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

- [Table of Content](#table-of-content)
- [Summary of the project](#summary-of-the-project)
- [SPEC](#spec)
- [Local development](#local-development)
- [Dependencies](#dependencies)
- [Python3.7](#python37)
Expand Down Expand Up @@ -36,6 +37,10 @@

`service-stac` provides and manages access to packaged geospatial data and their metadata. It implements and extends the **STAC API** specification version 0.9.0 [radiantearth/stac-spec/tree/v0.9.0/api-spec](https://github.com/radiantearth/stac-spec/tree/v0.9.0/api-spec). Currently the **STAC API** has been split from the main **STAC SPEC** repository into [radiantearth/stac-api-spec](https://github.com/radiantearth/stac-api-spec), which is under active development until the release 1.0-beta.


## SPEC

See [SPEC](./spec/README.md)
## Local development

### Dependencies
Expand Down
73 changes: 0 additions & 73 deletions app/config/logging-cfg-dev.yml

This file was deleted.

75 changes: 0 additions & 75 deletions app/config/logging-cfg-prod.yml

This file was deleted.

6 changes: 5 additions & 1 deletion app/middleware/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ def __call__(self, request):
"request.query": request.GET.urlencode(RequestResponseLoggingMiddleware.url_safe)
}

if request.method.upper() in ["PATCH", "POST", "PUT"]:
if request.method.upper() in [
"PATCH", "POST", "PUT"
] and request.content_type == "application/json" and not request.path.startswith(
'/api/stac/admin'
):
extra["request.payload"] = str(request.body[:200])

logger.info(
Expand Down
Loading

0 comments on commit 679b6dd

Please sign in to comment.