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
Docker BugFix #3346
Docker BugFix #3346
Changes from 13 commits
f0a1b7d
c2094e6
59e04d6
43f90c3
2a949a4
2c22fd3
6adc42a
9fecc96
56e7beb
a2dd96d
196b3f5
f9dcda0
0466e5e
d802264
f9a152c
bb7dc7a
794fa5c
794b687
8ba3375
c741569
b05c43a
8b427fe
01a2526
3fea23e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,44 @@ | ||
FROM phusion/baseimage:0.9.15 | ||
MAINTAINER Open Knowledge | ||
# docker build . -t ckan && docker run -d -p 80:5000 --link db:db --link redis:redis --link solr:solr ckan | ||
|
||
# Disable SSH | ||
RUN rm -rf /etc/service/sshd /etc/my_init.d/00_regen_ssh_host_keys.sh | ||
FROM debian:jessie | ||
MAINTAINER Open Knowledge | ||
|
||
ENV HOME /root | ||
ENV CKAN_HOME /usr/lib/ckan/default | ||
ENV CKAN_CONFIG /etc/ckan/default | ||
ENV CKAN_DATA /var/lib/ckan | ||
|
||
# Install required packages | ||
RUN apt-get -q -y update && \ | ||
DEBIAN_FRONTEND=noninteractive apt-get -q -y install \ | ||
python-minimal \ | ||
python-dev \ | ||
RUN apt-get -q -y update && apt-get -q -y upgrade && DEBIAN_FRONTEND=noninteractive apt-get -q -y install \ | ||
python-dev \ | ||
python-pip \ | ||
python-virtualenv \ | ||
libevent-dev \ | ||
libpq-dev \ | ||
nginx-light \ | ||
apache2 \ | ||
libapache2-mod-wsgi \ | ||
postfix \ | ||
build-essential && \ | ||
apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# Install CKAN | ||
RUN virtualenv $CKAN_HOME | ||
git-core \ | ||
&& apt-get -q clean | ||
|
||
# SetUp Virtual Environment CKAN | ||
RUN mkdir -p $CKAN_HOME $CKAN_CONFIG $CKAN_DATA | ||
RUN chown www-data:www-data $CKAN_DATA | ||
RUN virtualenv $CKAN_HOME | ||
RUN ln -s $CKAN_HOME/bin/pip /usr/local/bin/ckan-pip | ||
RUN ln -s $CKAN_HOME/bin/paster /usr/local/bin/ckan-paster | ||
|
||
# SetUp Requirements | ||
ADD ./requirements.txt $CKAN_HOME/src/ckan/requirements.txt | ||
RUN $CKAN_HOME/bin/pip install -r $CKAN_HOME/src/ckan/requirements.txt | ||
RUN ckan-pip install --upgrade -r $CKAN_HOME/src/ckan/requirements.txt | ||
|
||
# SetUp CKAN | ||
ADD . $CKAN_HOME/src/ckan/ | ||
RUN $CKAN_HOME/bin/pip install -e $CKAN_HOME/src/ckan/ | ||
RUN ckan-pip install -e $CKAN_HOME/src/ckan/ | ||
RUN ln -s $CKAN_HOME/src/ckan/ckan/config/who.ini $CKAN_CONFIG/who.ini | ||
ADD ./contrib/docker/apache.wsgi $CKAN_CONFIG/apache.wsgi | ||
|
||
# Configure apache | ||
ADD ./contrib/docker/apache.conf /etc/apache2/sites-available/ckan_default.conf | ||
RUN echo "Listen 8080" > /etc/apache2/ports.conf | ||
RUN a2ensite ckan_default | ||
RUN a2dissite 000-default | ||
|
||
# Configure nginx | ||
ADD ./contrib/docker/nginx.conf /etc/nginx/nginx.conf | ||
RUN mkdir /var/cache/nginx | ||
|
||
# Configure postfix | ||
ADD ./contrib/docker/main.cf /etc/postfix/main.cf | ||
|
||
# Configure runit | ||
ADD ./contrib/docker/my_init.d /etc/my_init.d | ||
ADD ./contrib/docker/svc /etc/service | ||
CMD ["/sbin/my_init"] | ||
# SetUp EntryPoint | ||
COPY ./contrib/docker/ckan-entrypoint.sh / | ||
RUN chmod +x /ckan-entrypoint.sh | ||
ENTRYPOINT ["/ckan-entrypoint.sh"] | ||
|
||
# Volumes | ||
VOLUME ["/etc/ckan/default"] | ||
VOLUME ["/var/lib/ckan"] | ||
EXPOSE 80 | ||
EXPOSE 5000 | ||
|
||
RUN rm -rf /tmp/* /var/tmp/* | ||
CMD ["ckan-paster","serve","/etc/ckan/default/ckan.ini"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
#!/bin/sh | ||
set -eu | ||
|
||
# URL for the primary database, in the format expected by sqlalchemy (required | ||
# unless linked to a container called 'db') | ||
: ${DATABASE_URL:=} | ||
# URL for solr (required unless linked to a container called 'solr') | ||
: ${SOLR_URL:=} | ||
# URL for redis (required unless linked to a container called 'redis') | ||
: ${REDIS_URL:=} | ||
# Email to which errors should be sent (optional, default: none) | ||
: ${ERROR_EMAIL:=} | ||
|
||
CONFIG="${CKAN_CONFIG}/ckan.ini" | ||
|
||
abort () { | ||
echo "$@" >&2 | ||
exit 1 | ||
} | ||
|
||
write_config () { | ||
ckan-paster make-config ckan "$CONFIG" | ||
|
||
ckan-paster --plugin=ckan config-tool "$CONFIG" -e \ | ||
"sqlalchemy.url = ${DATABASE_URL}" \ | ||
"solr_url = ${SOLR_URL}" \ | ||
"ckan.redis.url = ${REDIS_URL}" \ | ||
"ckan.storage_path = /var/lib/ckan" \ | ||
"email_to = disabled@example.com" \ | ||
"error_email_from = ckan@$(hostname -f)" \ | ||
"ckan.site_url = http://localhost:5000" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it be easier to use the environment variables for these config options instead? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, i miss the ckan.storage_path. Thanks @wardi Should I add also the other params as environment variables? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please just add the ones you need, making arbitrary config options override-able from environment vars makes me nervous. |
||
|
||
if [ -n "$ERROR_EMAIL" ]; then | ||
sed -i -e "s&^#email_to.*&email_to = ${ERROR_EMAIL}&" "$CONFIG" | ||
fi | ||
} | ||
|
||
link_postgres_url () { | ||
local user=$DB_ENV_POSTGRES_USER | ||
local pass=$DB_ENV_POSTGRES_PASSWORD | ||
local db=$DB_ENV_POSTGRES_DB | ||
local host=$DB_PORT_5432_TCP_ADDR | ||
local port=$DB_PORT_5432_TCP_PORT | ||
echo "postgresql://${user}:${pass}@${host}:${port}/${db}" | ||
} | ||
|
||
link_solr_url () { | ||
local host=$SOLR_PORT_8983_TCP_ADDR | ||
local port=$SOLR_PORT_8983_TCP_PORT | ||
echo "http://${host}:${port}/solr/ckan" | ||
} | ||
|
||
link_redis_url () { | ||
local host=$REDIS_PORT_6379_TCP_ADDR | ||
local port=$REDIS_PORT_6379_TCP_PORT | ||
echo "redis://${host}:${port}/1" | ||
} | ||
|
||
# If we don't already have a config file, bootstrap | ||
if [ ! -e "$CONFIG" ]; then | ||
|
||
if [ -z "$DATABASE_URL" ]; then | ||
if ! DATABASE_URL=$(link_postgres_url); then | ||
abort "ERROR: no DATABASE_URL specified and linked container called 'db' was not found" | ||
fi | ||
fi | ||
|
||
if [ -z "$SOLR_URL" ]; then | ||
if ! SOLR_URL=$(link_solr_url); then | ||
abort "ERROR: no SOLR_URL specified and linked container called 'solr' was not found" | ||
fi | ||
fi | ||
|
||
if [ -z "$REDIS_URL" ]; then | ||
if ! REDIS_URL=$(link_redis_url); then | ||
abort "ERROR: no REDIS_URL specified and linked container called 'redis' was not found" | ||
fi | ||
fi | ||
|
||
write_config | ||
|
||
fi | ||
|
||
ckan-paster --plugin=ckan db init -c "${CKAN_CONFIG}/ckan.ini" | ||
|
||
exec "$@" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,28 @@ | ||
version: '2' | ||
services: | ||
ckan: | ||
container_name: ckan | ||
image: ckan/ckan:latest | ||
depends_on: | ||
# docker-compose build && docker-compose up | ||
ckan: | ||
container_name: ckan | ||
image: ckan/ckan:latest | ||
links: | ||
- db | ||
- solr | ||
links: | ||
- db | ||
- solr | ||
ports: | ||
- "80:80" | ||
db: | ||
container_name: db | ||
image: ckan/postgresql:latest | ||
solr: | ||
container_name: solr | ||
image: ckan/solr:latest | ||
- redis | ||
ports: | ||
- "80:5000" | ||
|
||
db: | ||
container_name: db | ||
image: ckan/postgresql:latest | ||
ports: | ||
- "5432:5432" | ||
|
||
solr: | ||
container_name: solr | ||
image: ckan/solr:latest | ||
ports: | ||
- "8983:8983" | ||
|
||
redis: | ||
container_name: redis | ||
image: redis:latest | ||
ports: | ||
- "6379:6379" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ RUN mkdir -p /opt/solr/server/solr/$SOLR_CORE/data | |
|
||
# Adding Files | ||
ADD ./solrconfig.xml \ | ||
https://raw.githubusercontent.com/ckan/ckan/dev-v2.6/ckan/config/solr/schema.xml \ | ||
https://raw.githubusercontent.com/ckan/ckan/master/ckan/config/solr/schema.xml \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume this will be need to be changed to the relevant tag as part of the release process? Also more generically I guess the release process will need to include a Docker step to build and tag the images and upload them to Docker Hub. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @amercader For now i don't know how to make the diference between the schemas. |
||
https://raw.githubusercontent.com/apache/lucene-solr/releases/lucene-solr/6.0.0/solr/server/solr/configsets/basic_configs/conf/currency.xml \ | ||
https://raw.githubusercontent.com/apache/lucene-solr/releases/lucene-solr/6.0.0/solr/server/solr/configsets/basic_configs/conf/synonyms.txt \ | ||
https://raw.githubusercontent.com/apache/lucene-solr/releases/lucene-solr/6.0.0/solr/server/solr/configsets/basic_configs/conf/stopwords.txt \ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You've added about 2 minutes to the all CI containers. Would you add your docker build and test code to https://github.com/ckan/ckan/blob/master/.circleci-matrix.yml so that it only runs in one container instead of all 4?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The circlce-matrix docs are more than a little lacking, let me know if you'd like more direction here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, i will try to make it ;)
But im not sure if i can cache the images in the matrix :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe @amercader's suggestion of running the docker tests under travis is the best, then