diff --git a/apps/cic-cache/.dockerignore b/apps/cic-cache/.dockerignore new file mode 100644 index 00000000..a58c5dc8 --- /dev/null +++ b/apps/cic-cache/.dockerignore @@ -0,0 +1,4 @@ +.git +.cache +.dot +**/doc \ No newline at end of file diff --git a/apps/cic-cache/.gitlab-ci.yml b/apps/cic-cache/.gitlab-ci.yml index ce16d38b..8cbce963 100644 --- a/apps/cic-cache/.gitlab-ci.yml +++ b/apps/cic-cache/.gitlab-ci.yml @@ -1,8 +1,8 @@ .cic_cache_variables: variables: APP_NAME: cic-cache - DOCKERFILE_PATH: $APP_NAME/docker/Dockerfile - CONTEXT: apps + DOCKERFILE_PATH: docker/Dockerfile + CONTEXT: apps/$APP_NAME build-mr-cic-cache: extends: diff --git a/apps/cic-cache/docker/Dockerfile b/apps/cic-cache/docker/Dockerfile index c4c783dd..2aa7e311 100644 --- a/apps/cic-cache/docker/Dockerfile +++ b/apps/cic-cache/docker/Dockerfile @@ -1,52 +1,38 @@ -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 pip install $pip_extra_index_url_flag cic-base[full_graph]==0.1.2b9 -#COPY --from=0 /usr/local/share/cic/solidity/ /usr/local/share/cic/solidity/ +COPY requirements.txt . +#RUN pip install $pip_extra_index_url_flag -r test_requirements.txt +#RUN pip install $pip_extra_index_url_flag . +#RUN pip install .[server] -WORKDIR /usr/src/cic-cache +ARG EXTRA_INDEX_URL="https://pip.grassrootseconomics.net:8433" +ARG GITLAB_PYTHON_REGISTRY="https://gitlab.com/api/v4/projects/27624814/packages/pypi/simple" +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 -ARG pip_extra_index_url_flag='--index https://pypi.org/simple --extra-index-url https://pip.grassrootseconomics.net:8433' -ARG root_requirement_file='requirements.txt' +COPY . . -#RUN apk update && \ -# apk add gcc musl-dev gnupg libpq -#RUN apk add postgresql-dev -#RUN apk add linux-headers -#RUN apk add libffi-dev -RUN apt-get update && \ - apt install -y gcc gnupg libpq-dev wget make g++ gnupg bash procps git - -# Copy shared requirements from top of mono-repo -RUN echo "copying root req file ${root_requirement_file}" -RUN pip install $pip_extra_index_url_flag cic-base[full_graph]==0.1.2b9 - -COPY cic-cache/requirements.txt ./ -COPY cic-cache/setup.cfg \ - cic-cache/setup.py \ - ./ -COPY cic-cache/cic_cache/ ./cic_cache/ -COPY cic-cache/scripts/ ./scripts/ -COPY cic-cache/test_requirements.txt ./ -RUN pip install $pip_extra_index_url_flag -r test_requirements.txt -RUN pip install $pip_extra_index_url_flag . -RUN pip install .[server] - -COPY cic-cache/tests/ ./tests/ -#COPY db/ cic-cache/db -#RUN apk add postgresql-client +RUN python setup.py install # 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-cache/config/ /usr/local/etc/cic-cache/ +COPY config/ /usr/local/etc/cic-cache/ # for db migrations RUN git clone https://github.com/vishnubob/wait-for-it.git /usr/local/bin/wait-for-it/ -COPY cic-cache/cic_cache/db/migrations/ /usr/local/share/cic-cache/alembic/ +COPY cic_cache/db/migrations/ /usr/local/share/cic-cache/alembic/ -COPY cic-cache/docker/start_tracker.sh ./start_tracker.sh -COPY cic-cache/docker/db.sh ./db.sh +COPY /docker/start_tracker.sh ./start_tracker.sh +COPY /docker/db.sh ./db.sh RUN chmod 755 ./*.sh # Tracker # ENTRYPOINT ["/usr/local/bin/cic-cache-tracker", "-vv"] # Server # ENTRYPOINT [ "/usr/local/bin/uwsgi", "--wsgi-file", "/usr/local/lib/python3.8/site-packages/cic_cache/runnable/server.py", "--http", ":80", "--pyargv", "-vv" ] +ENTRYPOINT [] diff --git a/docker-compose.yml b/docker-compose.yml index 18728027..cacb0d2f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -125,8 +125,8 @@ services: cic-cache-tracker: build: - context: apps - dockerfile: cic-cache/docker/Dockerfile + context: apps/cic-cache + dockerfile: docker/Dockerfile environment: CIC_REGISTRY_ADDRESS: $CIC_REGISTRY_ADDRESS # supplied at contract-config after contract provisioning ETH_PROVIDER: ${ETH_PROVIDER:-http://eth:8545} @@ -161,8 +161,8 @@ services: cic-cache-tasker: build: - context: apps - dockerfile: cic-cache/docker/Dockerfile + context: apps/cic-cache + dockerfile: docker/Dockerfile environment: CIC_REGISTRY_ADDRESS: $CIC_REGISTRY_ADDRESS # supplied at contract-config after contract provisioning ETH_PROVIDER: ${ETH_PROVIDER:-http://eth:8545} @@ -197,9 +197,9 @@ services: - contract-config:/tmp/cic/config/:ro cic-cache-server: - build: - context: apps - dockerfile: cic-cache/docker/Dockerfile + build: + context: apps/cic-cache + dockerfile: docker/Dockerfile environment: DATABASE_USER: ${DATABASE_USER:-grassroots} DATABASE_HOST: ${DATABASE_HOST:-postgres}