diff --git a/apps/cic-notify/.gitlab-ci.yml b/apps/cic-notify/.gitlab-ci.yml index 5f29fa0f..a414b9bf 100644 --- a/apps/cic-notify/.gitlab-ci.yml +++ b/apps/cic-notify/.gitlab-ci.yml @@ -1,8 +1,8 @@ .cic_notify_variables: variables: APP_NAME: cic-notify - DOCKERFILE_PATH: $APP_NAME/docker/Dockerfile - CONTEXT: apps/ + DOCKERFILE_PATH: docker/Dockerfile_ci + CONTEXT: apps/$APP_NAME build-mr-cic-notify: extends: @@ -14,6 +14,31 @@ build-mr-cic-notify: - apps/cic-notify/**/* when: always +test-mr-cic-notify: + stage: test + extends: + - .cic_notify_variables + cache: + key: + files: + - test_requirements.txt + paths: + - /root/.cache/pip + image: $MR_IMAGE_TAG + script: + - cd apps/$APP_NAME/ + - > + pip install --extra-index-url https://pip.grassrootseconomics.net:8433 + --extra-index-url https://gitlab.com/api/v4/projects/27624814/packages/pypi/simple + -r test_requirements.txt + - export PYTHONPATH=. && pytest -x --cov=cic_notify --cov-fail-under=90 --cov-report term-missing tests + needs: ["build-mr-cic-notify"] + rules: + - if: $CI_PIPELINE_SOURCE == "merge_request_event" + changes: + - apps/cic-eth/**/* + when: always + build-push-cic-notify: extends: - .py_build_push diff --git a/apps/cic-notify/docker/Dockerfile b/apps/cic-notify/docker/Dockerfile index ea00a238..36b09e18 100644 --- a/apps/cic-notify/docker/Dockerfile +++ b/apps/cic-notify/docker/Dockerfile @@ -1,38 +1,30 @@ -FROM python:3.8.6-slim-buster +# syntax = docker/dockerfile:1.2 +FROM registry.gitlab.com/grassrootseconomics/cic-base-images:python-3.8.6-dev-55da5f4e as dev -RUN apt-get update && \ - apt install -y gcc gnupg libpq-dev wget make g++ gnupg bash procps +#RUN pip install $pip_extra_index_url_flag cic-base[full_graph]==0.1.2a62 -WORKDIR /usr/src/cic-notify +ARG EXTRA_INDEX_URL="https://pip.grassrootseconomics.net:8433" +ARG GITLAB_PYTHON_REGISTRY="https://gitlab.com/api/v4/projects/27624814/packages/pypi/simple" +COPY requirements.txt . -ARG pip_extra_index_url_flag='--index https://pypi.org/simple --extra-index-url https://pip.grassrootseconomics.net:8433' -RUN pip install $pip_extra_index_url_flag cic-base[full_graph]==0.1.2a62 +RUN --mount=type=cache,mode=0755,target=/root/.cache/pip \ + pip install --index-url https://pypi.org/simple \ + --extra-index-url $GITLAB_PYTHON_REGISTRY --extra-index-url $EXTRA_INDEX_URL \ + -r requirements.txt -COPY cic-notify/setup.cfg \ - cic-notify/setup.py \ - ./ +COPY . . -COPY cic-notify/cic_notify/ ./cic_notify/ +RUN python setup.py install -COPY cic-notify/requirements.txt \ - cic-notify/test_requirements.txt \ - ./ - -COPY cic-notify/scripts/ scripts/ +# TODO please review..can this go into requirements? RUN pip install $pip_extra_index_url_flag .[africastalking,notifylog] -COPY cic-notify/tests/ tests/ -COPY cic-notify/docker/db.sh \ - cic-notify/docker/start_tasker.sh \ - /root/ - -#RUN apk add postgresql-client -#RUN apk add bash +COPY docker/*.sh . # ini files in config directory defines the configurable parameters for the application # they can all be overridden by environment variables # to generate a list of environment variables from configuration, use: confini-dump -z (executable provided by confini package) -COPY cic-notify/.config/ /usr/local/etc/cic-notify/ -COPY cic-notify/cic_notify/db/migrations/ /usr/local/share/cic-notify/alembic/ +COPY .config/ /usr/local/etc/cic-notify/ +COPY cic_notify/db/migrations/ /usr/local/share/cic-notify/alembic/ -WORKDIR /root +ENTRYPOINT [] diff --git a/apps/cic-notify/docker/Dockerfile_ci b/apps/cic-notify/docker/Dockerfile_ci new file mode 100644 index 00000000..5c14c05d --- /dev/null +++ b/apps/cic-notify/docker/Dockerfile_ci @@ -0,0 +1,29 @@ +# syntax = docker/dockerfile:1.2 +FROM registry.gitlab.com/grassrootseconomics/cic-base-images:python-3.8.6-dev-55da5f4e as dev + +#RUN pip install $pip_extra_index_url_flag cic-base[full_graph]==0.1.2a62 + +ARG EXTRA_INDEX_URL="https://pip.grassrootseconomics.net:8433" +ARG GITLAB_PYTHON_REGISTRY="https://gitlab.com/api/v4/projects/27624814/packages/pypi/simple" +COPY requirements.txt . + +RUN pip install --index-url https://pypi.org/simple \ + --extra-index-url $GITLAB_PYTHON_REGISTRY --extra-index-url $EXTRA_INDEX_URL \ + -r requirements.txt + +COPY . . + +RUN python setup.py install + +# TODO please review..can this go into requirements? +RUN pip install $pip_extra_index_url_flag .[africastalking,notifylog] + +COPY docker/*.sh . + +# ini files in config directory defines the configurable parameters for the application +# they can all be overridden by environment variables +# to generate a list of environment variables from configuration, use: confini-dump -z (executable provided by confini package) +COPY .config/ /usr/local/etc/cic-notify/ +COPY cic_notify/db/migrations/ /usr/local/share/cic-notify/alembic/ + +ENTRYPOINT [] diff --git a/docker-compose.yml b/docker-compose.yml index b8ed2162..d66e2a83 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -403,8 +403,8 @@ services: cic-notify-tasker: build: - context: apps/ - dockerfile: cic-notify/docker/Dockerfile + context: apps/cic-notify + dockerfile: docker/Dockerfile environment: DATABASE_USER: ${DATABASE_USER:-grassroots} DATABASE_HOST: ${DATABASE_HOST:-postgres}