Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade datapusher #28

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ENV CKAN_ENV docker
WORKDIR /opt/inventory-app

# Install required packages
RUN apt-get -q -y update
RUN apt-get -q -y update --fix-missing
RUN apt-get -q -y install \
curl \
build-essential \
Expand Down Expand Up @@ -49,7 +49,7 @@ RUN mkdir -p $CKAN_HOME && \
COPY requirements.txt /tmp/

# Install ckan dependencies
RUN $CKAN_HOME/bin/pip install -r /tmp/requirements.txt
RUN $CKAN_HOME/bin/pip --no-cache-dir install -r /tmp/requirements.txt

COPY entrypoint-docker.sh /
ENTRYPOINT ["/entrypoint-docker.sh"]
Expand Down
11 changes: 8 additions & 3 deletions config/production.ini
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,12 @@ ckan.redis.url = redis://redis:6379/0

## Site Settings

ckan.site_url = http://localhost:5000
ckan.site_url = http://localhost:5000/

# inside docker we need a custom URL
# https://github.com/ckan/ckan/pull/4879/files#diff-a6a8dc8b17704fdc5f98ec7b3dfe0045R1534
ckan.datapusher.callback_url_base = http://app:5000/

#ckan.use_pylons_response_cleanup_middleware = true

## Authorization Settings
Expand Down Expand Up @@ -102,7 +107,7 @@ solr_url = http://solr:8983/solr/inventory
# original plugins
# ckan.plugins = usmetadata datajson datastore datapusher stats text_view recline_view googleanalyticsbasic

ckan.plugins = googleanalyticsbasic datastore
ckan.plugins = googleanalyticsbasic datastore datapusher

# Define which views should be created by default
# (plugins must be loaded in ckan.plugins)
Expand Down Expand Up @@ -155,7 +160,7 @@ ckan.feeds.author_link =
# Make sure you have set up the DataStore

ckan.datapusher.formats = csv xls xlsx tsv application/csv application/vnd.ms-excel application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
ckan.datapusher.url = http://127.0.0.1:8800/
ckan.datapusher.url = http://datapusher:8800

# Resource Proxy settings
# Preview size limit, default: 1MB
Expand Down
39 changes: 39 additions & 0 deletions datapusher/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
FROM keitaro/base:0.4
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there no existing datapusher image? If we are forced to build our own, then we should build our own image from its own repository. We shouldn't be committing a datapusher Dockerfile here.

Copy link
Contributor Author

@avdata99 avdata99 Mar 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems you use a local datapusher in the inventory app for development. Also in datagov-deploy
I din't find a docker image in GSA's Docker hub.
This repo seems the best place to test the upgrade.
Does GSA have a repository for the datapusher image?
Maybe I missing something.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure but it seems in datagov-deploy you just run datapusher locally in the inventory machine.

Copy link
Contributor Author

@avdata99 avdata99 Mar 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you prefer @adborden we can start a new repo for GSA datapusher to work independently.
This is another option with a built image. It also works.
I also look in ckan-cloud-docker and we also build this image. I will wait for @akariv opinion.


MAINTAINER Keitaro Inc <info@keitaro.info>

ENV APP_DIR=/srv/app
ENV GIT_BRANCH 0.0.15
ENV GIT_URL https://github.com/ckan/datapusher.git
ENV JOB_CONFIG ${APP_DIR}/datapusher_settings.py

WORKDIR ${APP_DIR}

RUN apk add --no-cache python \
py-pip \
py-gunicorn \
libffi-dev \
libressl-dev \
libxslt && \
# Temporary packages to build CKAN requirements
apk add --no-cache --virtual .build-deps \
gcc \
git \
util-linux \
musl-dev \
python-dev \
libxml2-dev \
libxslt-dev

# Fetch datapusher and install
RUN mkdir ${APP_DIR}/src && cd ${APP_DIR}/src && \
git clone -b ${GIT_BRANCH} --depth=1 --single-branch ${GIT_URL} && \
cd datapusher && \
pip install -r requirements.txt && \
python setup.py develop

COPY setup ${APP_DIR}

EXPOSE 8800
# --reload restats gunicoir when code changes
CMD ["gunicorn", "--reload", "--bind=0.0.0.0:8800", "--log-file=-", "wsgi"]
32 changes: 32 additions & 0 deletions datapusher/setup/datapusher_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import uuid

DEBUG = True
TESTING = False
SECRET_KEY = str(uuid.uuid4())
USERNAME = str(uuid.uuid4())
PASSWORD = str(uuid.uuid4())

NAME = 'datapusher'

# database

SQLALCHEMY_DATABASE_URI = 'sqlite:////tmp/job_store.db'

# webserver host and port

HOST = '0.0.0.0'
PORT = 8800

# logging

#FROM_EMAIL = 'server-error@example.com'
#ADMINS = ['yourname@example.com'] # where to send emails

LOG_FILE = '/tmp/ckan_service.log'
STDERR = True

# cloud settings
MAX_CONTENT_LENGTH = 73400320

# Allow no SSL locally
SSL_VERIFY = False
9 changes: 9 additions & 0 deletions datapusher/setup/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import os
import sys

import ckanserviceprovider.web as web
web.init()

from datapusher import jobs

application = web.app
11 changes: 11 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ services:
command: /opt/inventory-app/start.sh
depends_on:
- datastore
- datapusher
- db
- solr
environment:
Expand All @@ -28,6 +29,16 @@ services:
volumes:
- ./datastore/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d

datapusher:
container_name: datapusher-inventory
build:
context: datapusher/
ports:
- "8800:8800"
# activate if you need to debug datapusher
# volumes:
# - /home/user/my_code/datapusher:/srv/app/src/datapusher

db:
image: datagov/catalog-db:inventory2_8
environment:
Expand Down
5 changes: 4 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
-e 'git+https://github.com/ckan/ckan.git@ckan-2.8.3#egg=ckan'
# -e 'git+https://github.com/ckan/ckan.git@ckan-2.8.3#egg=ckan'

# datapusher hotfix. CKAN has an error
-e git+https://github.com/avdata99/ckan@my_2.8.3#egg=ckan
-e git+https://github.com/GSA/ckanext-googleanalyticsbasic#egg=ckanext-googleanalyticsbasic

#
Expand Down