cic ussd refactor

This commit is contained in:
Blair Vanderlugt 2021-07-07 16:00:11 -07:00
parent 1bfc736513
commit 319e587f29
5 changed files with 54 additions and 49 deletions

View File

@ -14,10 +14,10 @@ build-mr-cic-cache:
- apps/cic-cache/**/*
when: always
test-mr-cic-eth:
test-mr-cic-cache:
stage: test
extends:
- .cic_eth_variables
- .cic_cache_variables
cache:
key:
files:
@ -32,7 +32,7 @@ test-mr-cic-eth:
--extra-index-url https://gitlab.com/api/v4/projects/27624814/packages/pypi/simple
-r test_requirements.txt
- export PYTHONPATH=. && pytest -x --cov=cic_cache --cov-fail-under=90 --cov-report term-missing tests
needs: ["build-mr-cic-eth"]
needs: ["build-mr-cic-cache"]
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
changes:

View File

@ -0,0 +1,4 @@
.git
.cache
.dot
**/doc

View File

@ -1,8 +1,8 @@
.cic_ussd_variables:
variables:
APP_NAME: cic-ussd
DOCKERFILE_PATH: $APP_NAME/docker/Dockerfile
CONTEXT: apps/
DOCKERFILE_PATH: docker/Dockerfile
CONTEXT: apps/$APP_NAME
build-mr-cic-ussd:
extends:
@ -14,6 +14,31 @@ build-mr-cic-ussd:
- apps/cic-ussd/**/*
when: always
test-mr-cic-ussd:
stage: test
extends:
- .cic_ussd_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_eth --cov-fail-under=90 --cov-report term-missing tests
needs: ["build-mr-cic-ussd"]
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
changes:
- apps/cic-eth/**/*
when: always
build-push-cic-ussd:
extends:
- .py_build_push

View File

@ -1,14 +1,6 @@
# FROM python:3.8.5-alpine
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
# set working directory
WORKDIR /usr/src
# add args for installing from self-hosted packages
ARG pip_extra_index_url_flag='--extra-index-url https://pip.grassrootseconomics.net:8433'
RUN apt-get update && \
apt install -y gcc gnupg libpq-dev wget make g++ gnupg bash procps git
# create secrets directory
RUN mkdir -vp pgp/keys
@ -17,39 +9,23 @@ RUN mkdir -vp pgp/keys
RUN mkdir -vp cic-ussd
RUN mkdir -vp data
COPY cic-ussd/setup.cfg \
cic-ussd/setup.py \
cic-ussd/
COPY requirements.txt .
COPY cic-ussd/requirements.txt \
cic-ussd/test_requirements.txt \
cic-ussd/
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
# install requirements
RUN cd cic-ussd && \
pip install -r requirements.txt $pip_extra_index_url_flag
COPY . .
RUN python setup.py install
# copy all necessary files
COPY cic-ussd/cic_ussd/ cic-ussd/cic_ussd/
COPY cic-ussd/cic_ussd/db/ussd_menu.json data/
COPY cic-ussd/scripts/ cic-ussd/scripts/
COPY cic-ussd/states/ cic-ussd/states/
COPY cic-ussd/transitions/ cic-ussd/transitions/
COPY cic-ussd/var/ cic-ussd/var/
COPY cic-ussd/docker/db.sh \
cic-ussd/docker/start_cic_user_tasker.sh \
cic-ussd/docker/start_cic_user_ussd_server.sh\
cic-ussd/docker/start_cic_user_server.sh\
/root/
COPY cic_ussd/db/ussd_menu.json data/
COPY docker/*.sh .
RUN chmod +x /root/*.sh
RUN cd cic-ussd && \
pip install $pip_extra_index_url_flag .
# copy config and migration files to definitive file so they can be referenced in path definitions for running scripts
COPY cic-ussd/.config/ /usr/local/etc/cic-ussd/
COPY cic-ussd/cic_ussd/db/migrations/ /usr/local/share/cic-ussd/alembic
COPY .config/ /usr/local/etc/cic-ussd/
COPY cic_ussd/db/migrations/ /usr/local/share/cic-ussd/alembic
WORKDIR /root
ENTRYPOINT []

View File

@ -464,8 +464,8 @@ services:
cic-user-ussd-server:
build:
context: apps/
dockerfile: cic-ussd/docker/Dockerfile
context: apps/cic-ussd
dockerfile: docker/Dockerfile
environment:
DATABASE_USER: grassroots
DATABASE_HOST: postgres
@ -493,8 +493,8 @@ services:
cic-user-server:
build:
context: apps
dockerfile: cic-ussd/docker/Dockerfile
context: apps/cic-ussd
dockerfile: docker/Dockerfile
environment:
DATABASE_USER: grassroots
DATABASE_HOST: postgres
@ -515,8 +515,8 @@ services:
cic-user-tasker:
build:
context: apps
dockerfile: cic-ussd/docker/Dockerfile
context: apps/cic-ussd/
dockerfile: docker/Dockerfile
environment:
DATABASE_USER: grassroots
DATABASE_HOST: postgres