Skip to content

Commit

Permalink
Merge pull request #1 from GSA/feature/inventory
Browse files Browse the repository at this point in the history
Somewhat working version of a development environment for Inventory
  • Loading branch information
mogul authored Oct 28, 2019
2 parents 5c0c8d0 + 817602c commit 357442b
Show file tree
Hide file tree
Showing 15 changed files with 486 additions and 112 deletions.
7 changes: 7 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,10 @@ jobs:
- run:
name: Run tests
command: make test


workflows:
version: 2
commit:
jobs:
- build
8 changes: 5 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM ubuntu:14.04

ARG PYTHON_VERSION=2.7.15
ARG PYTHON_VERSION=2.7.10

ENV CKAN_HOME /usr/lib/ckan
ENV CKAN_CONFIG /etc/ckan/
Expand All @@ -11,12 +11,14 @@ WORKDIR /opt/inventory-app
# Install required packages
RUN apt-get -q -y update
RUN apt-get -q -y install \
curl \
build-essential \
git \
libbz2-dev \
libpq-dev \
libssl-dev \
libz-dev \
swig \
wget

# Download python
Expand All @@ -39,10 +41,10 @@ RUN /usr/local/bin/pip install -U pip && \
RUN mkdir -p $CKAN_HOME && \
virtualenv $CKAN_HOME --no-site-packages -p /usr/local/bin/python

COPY requirements-freeze.txt /tmp
COPY requirements.txt /tmp/

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

COPY entrypoint-docker.sh /
ENTRYPOINT ["/entrypoint-docker.sh"]
Expand Down
20 changes: 8 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
.PHONY: all build copy-src local requirements setup test update-dependencies
.PHONY: all build requirements setup test update-dependencies

CKAN_HOME := /usr/lib/ckan

all: build
all: up

build:
docker-compose build

local:
docker-compose -f docker-compose.yml -f docker-compose.local.yml up

requirements:
docker-compose run --rm -T app pip --quiet freeze > requirements-freeze.txt

update-dependencies:
docker-compose run --rm app ./install-dev.sh

copy-src:
docker cp inventory-app_app_1:$(CKAN_HOME)/src .

test:
docker-compose build

up:
docker-compose up

update-dependencies:
docker-compose run --rm app pip install -r requirements.txt
52 changes: 16 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# inventory-app

[![CircleCI](https://circleci.com/gh/GSA/inventory-app.svg?style=svg)](https://circleci.com/gh/GSA/inventory-app)

Is a [Docker](https://www.docker.com/)-based [CKAN](http://ckan.org) deployment. CKAN is used by Data.gov @ https://inventory.data.gov
# inventory-app

Is a [Docker](https://www.docker.com/)-based [CKAN](http://ckan.org) development environment for [inventory.data.gov](https://inventory.data.gov).

_Note: this is currently a work in progress. We're mainly using this to manage
the `requirements-freeze.txt` for production dependencies. Very little works beyond that.`_
the `requirements-freeze.txt` for production dependencies. Very little works beyond that._


## Development
Expand All @@ -20,54 +20,34 @@ the `requirements-freeze.txt` for production dependencies. Very little works bey

Build and bring up the containers.

$ docker-compose up


### Docker-compose commands

To enter into the container in interactive mode as root:

$ docker-compose run app /bin/bash
$ make up

To run a one off command inside the container:

$ docker-compose run app {{command}}


### Source Code Folder (**src**)

**Note:** follow these steps only if your src folder is empty or you need the latest code
Create an admin user. You'll be prompted for a password.

1. Start the app, from root folder.
$ docker-compose run --rm app paster --plugin=ckan sysadmin add admin -c /etc/ckan/production.ini

$ docker-compose up
Open CKAN to verify it's working

1. Copy app source files to your local src folder.
$ open http://localhost:5000

$ make copy-src

1. Stop the app: `docker-compose down`
### Docker-compose commands

To enter into the container in interactive mode as root:

### Workflow
$ docker-compose run app bash

1. Start the app in local mode.
To run a one off command inside the container:

$ make local
$ docker-compose run app <command>

1. Make changes to the source code in `src`.
1. Commit the changes, and push extensions to GitHub.
1. (optional) Pull in the latest dependencies, including nested dependencies.
Update dependencies.

$ make update-dependencies

1. Update the pinned requirements in `requirements-freeze.txt`.
Update lock file for dependencies.

$ make requirements

see: https://blog.engineyard.com/2014/composer-its-all-about-the-lock-file
the same concepts apply to pip.


### Tests

Expand Down
213 changes: 213 additions & 0 deletions config/production.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
#
# CKAN - Pylons configuration
#
# These are some of the configuration options available for your CKAN
# instance. Check the documentation in 'doc/configuration.rst' or at the
# following URL for a description of what they do and the full list of
# available options:
#
# http://docs.ckan.org/en/latest/maintaining/configuration.html
#
# The %(here)s variable will be replaced with the parent directory of this file
#

[DEFAULT]

# WARNING: *THIS SETTING MUST BE SET TO FALSE ON A PRODUCTION ENVIRONMENT*
debug = false

[server:main]
use = egg:Paste#http
host = 0.0.0.0
port = 5000

[app:main]
use = egg:ckan
full_stack = true
cache_dir = /tmp/%(ckan.site_id)s/
beaker.session.key = ckan

# This is the secret token that the beaker library uses to hash the cookie sent
# to the client. `paster make-config` generates a unique value for this each
# time it generates a config file.
beaker.session.secret = EqF8Z9z+c6lsEKHJzGJygghqz

# `paster make-config` generates a unique value for this each time it generates
# a config file.
app_instance_uuid = 054d2b22-a3b9-4698-853d-63bbd151ecc1

# repoze.who config
who.config_file = %(here)s/who.ini
who.log_level = warning
who.log_file = %(cache_dir)s/who_log.ini
# Session timeout (user logged out after period of inactivity, in seconds).
# Inactive by default, so the session doesn't expire.
# who.timeout = 86400

## Database Settings
sqlalchemy.url = postgresql://ckan:pass@db/ckan

ckan.datastore.write_url = postgresql://datastore:pass@datastore/datastore
ckan.datastore.read_url = postgresql://datastore_ro:pass@datastore/datastore

# PostgreSQL' full-text search parameters
ckan.datastore.default_fts_lang = english
ckan.datastore.default_fts_index_method = gist

## Site Settings

ckan.site_url = http://localhost:5000
#ckan.use_pylons_response_cleanup_middleware = true

## Authorization Settings

ckan.auth.anon_create_dataset = false
ckan.auth.create_unowned_dataset = false
ckan.auth.create_dataset_if_not_in_organization = false
ckan.auth.user_create_groups = false
ckan.auth.user_create_organizations = false
ckan.auth.user_delete_groups = true
ckan.auth.user_delete_organizations = true
ckan.auth.create_user_via_api = false
ckan.auth.create_user_via_web = true
ckan.auth.roles_that_cascade_to_sub_groups = admin


## Search Settings

ckan.site_id = inventory
solr_url = http://solr:8983/solr/inventory

#ckan.simple_search = 1


## CORS Settings

# If cors.origin_allow_all is true, all origins are allowed.
# If false, the cors.origin_whitelist is used.
# ckan.cors.origin_allow_all = true
# cors.origin_whitelist is a space separated list of allowed domains.
# ckan.cors.origin_whitelist = http://example1.com http://example2.com


## Plugins Settings

# Note: Add ``datastore`` to enable the CKAN DataStore
# Add ``datapusher`` to enable DataPusher
# Add ``resource_proxy`` to enable resorce proxying and get around the
# same origin policy
ckan.plugins = usmetadata datajson datastore datapusher stats text_view recline_view googleanalyticsbasic


# Define which views should be created by default
# (plugins must be loaded in ckan.plugins)
ckan.views.default_views = recline_view text_view image_view webpage_view recline_grid_view



## Front-End Settings
ckan.site_title = CKAN
ckan.site_logo = /base/images/ckan-logo.png
ckan.site_description =
ckan.favicon = /images/icons/ckan.ico
ckan.gravatar_default = identicon
ckan.preview.direct = png jpg gif
ckan.preview.loadable = html htm rdf+xml owl+xml xml n3 n-triples turtle plain atom csv tsv rss txt json
ckan.display_timezone = server

# package_hide_extras = for_search_index_only
#package_edit_return_url = http://another.frontend/dataset/<NAME>
#package_new_return_url = http://another.frontend/dataset/<NAME>
#ckan.recaptcha.version = 1
#ckan.recaptcha.publickey =
#ckan.recaptcha.privatekey =
#licenses_group_url = http://licenses.opendefinition.org/licenses/groups/ckan.json
# ckan.template_footer_end =


## Internationalisation Settings
ckan.locale_default = en
ckan.locale_order = en pt_BR ja it cs_CZ ca es fr el sv sr sr@latin no sk fi ru de pl nl bg ko_KR hu sa sl lv
ckan.locales_offered =
ckan.locales_filtered_out = en_GB

## Feeds Settings

ckan.feeds.authority_name =
ckan.feeds.date =
ckan.feeds.author_name =
ckan.feeds.author_link =

## Storage Settings

#ckan.storage_path = /var/lib/ckan
#ckan.max_resource_size = 10
#ckan.max_image_size = 2

## Datapusher settings

# 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/

# Resource Proxy settings
# Preview size limit, default: 1MB
#ckan.resource_proxy.max_file_size = 1048576
# Size of chunks to read/write.
#ckan.resource_proxy.chunk_size = 4096

## Activity Streams Settings

#ckan.activity_streams_enabled = true
#ckan.activity_list_limit = 31
#ckan.activity_streams_email_notifications = true
#ckan.email_notifications_since = 2 days
ckan.hide_activity_from_users = %(ckan.site_id)s


## Email settings

#email_to = [email protected]
#error_email_from = paste@localhost
#smtp.server = localhost
#smtp.starttls = False
#smtp.user = [email protected]
#smtp.password = your_password
#smtp.mail_from =


## Logging configuration
[loggers]
keys = root, ckan, ckanext

[handlers]
keys = console

[formatters]
keys = generic

[logger_root]
level = WARNING
handlers = console

[logger_ckan]
level = INFO
handlers = console
qualname = ckan
propagate = 0

[logger_ckanext]
level = DEBUG
handlers = console
qualname = ckanext
propagate = 0

[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
formatter = generic

[formatter_generic]
format = %(asctime)s %(levelname)-5.5s [%(name)s] %(message)s
Loading

0 comments on commit 357442b

Please sign in to comment.