ADDED:
- Data only container for Postgres db & CKAN FileStore - Nginx container (still based on official container, but copies the config for portability) UPDATED: - Postgres Dockerfile to allow custom PGDATA directory & initiate it if it's not there or is empty - fig.ml to reflect the latest changes (datapusher, nginx, data container)
This commit is contained in:
parent
9a20dea6a4
commit
39467745f1
|
@ -90,7 +90,7 @@ ADD docker/ckan/svc/ /etc/service/
|
|||
|
||||
CMD ["/sbin/my_init"]
|
||||
|
||||
VOLUME ["/usr/lib/ckan", "/etc/ckan"]
|
||||
VOLUME ["/usr/lib/ckan", "/var/lib/ckan", "/etc/ckan"]
|
||||
EXPOSE 8080
|
||||
|
||||
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
FROM phusion/baseimage:0.9.15
|
||||
MAINTAINER Open Knowledge
|
||||
|
||||
# set UTF-8 locale
|
||||
RUN locale-gen en_US.UTF-8 && \
|
||||
echo 'LANG="en_US.UTF-8"' > /etc/default/locale
|
||||
|
||||
ENV CKAN_DATA /var/lib/ckan
|
||||
ENV PGDATA /etc/postgresql/9.3/main
|
||||
|
||||
RUN mkdir -p $CKAN_DATA && chown -R www-data:www-data $CKAN_DATA
|
||||
|
||||
RUN echo "postgres:x:107:" >> /etc/group
|
||||
RUN echo "postgres:x:103:107:PostgreSQL administrator,,,:/var/lib/postgresql:/bin/bash" >> /etc/passwd
|
||||
RUN mkdir -p $PGDATA && chown -R postgres:postgres $PGDATA
|
||||
|
||||
CMD ["/sbin/my_init"]
|
||||
|
||||
VOLUME ["/var/lib/ckan", "/etc/postgresql/9.3/main"]
|
|
@ -0,0 +1,2 @@
|
|||
FROM nginx:1.7.6
|
||||
COPY nginx.conf /etc/nginx/nginx.conf
|
|
@ -24,9 +24,12 @@ ENV DATASTORE_DB datastore
|
|||
ENV DATASTORE_USER datastore_user
|
||||
ENV DATASTORE_PASS datastore_pass
|
||||
|
||||
ENV PGDATA /etc/postgresql/9.3/main
|
||||
RUN mkdir -p $PGDATA && chown -R postgres $PGDATA && chmod -R 700 $PGDATA
|
||||
|
||||
# Allow connections from anywhere with valid credentials (md5)
|
||||
RUN sed -i -e"s/^#listen_addresses =.*$/listen_addresses = '*'/" /etc/postgresql/9.3/main/postgresql.conf
|
||||
RUN echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/9.3/main/pg_hba.conf
|
||||
RUN sed -i -e "s|^#listen_addresses =.*$|listen_addresses = '*'|" $PGDATA/postgresql.conf
|
||||
RUN echo "host all all 0.0.0.0/0 md5" >> $PGDATA/pg_hba.conf
|
||||
|
||||
# Configure runit
|
||||
RUN touch /configure_db
|
||||
|
|
|
@ -76,8 +76,35 @@ init_db_when_ready () {
|
|||
init_db
|
||||
}
|
||||
|
||||
if [[ ! -d "$PGDATA" ]]; then
|
||||
echo "Creating Postgres Directory..."
|
||||
# create dirs if needed
|
||||
mkdir -p $PGDATA
|
||||
# Ensure postgres owns the PGDATA
|
||||
chown -R postgres $PGDATA
|
||||
# Ensure we have the right permissions set on the PGDATA
|
||||
chmod -R 700 $PGDATA
|
||||
fi
|
||||
|
||||
# initialize db if needed
|
||||
if [[ ! "$(ls -A $PGDATA)" ]]; then
|
||||
echo "Initializing PostgreSQL..."
|
||||
chown -R postgres $PGDATA
|
||||
# postgres initdb
|
||||
setuser postgres /usr/lib/postgresql/9.3/bin/initdb --locale=en_US.UTF-8 --encoding=UNICODE $PGDATA/
|
||||
# Update postgresql.conf settings
|
||||
sed -i -e "s|^#listen_addresses =.*$|listen_addresses = '*'|" $PGDATA/postgresql.conf
|
||||
sed -i -e "s|^#data_directory =.*$|data_directory = '/var/lib/postgresql/9.3/main'|" $PGDATA/postgresql.conf
|
||||
sed -i -e "s|^#hba_file =.*$|hba_file = '/etc/postgresql/9.3/main/pg_hba.conf'|" $PGDATA/postgresql.conf
|
||||
sed -i -e "s|^#ident_file =.*$|ident_file = '/etc/postgresql/9.3/main/pg_ident.conf'|" $PGDATA/postgresql.conf
|
||||
sed -i -e "s|^#external_pid_file =.*$|external_pid_file = '/var/run/postgresql/9.3-main.pid'|" $PGDATA/postgresql.conf
|
||||
# Allow connections from anywhere with valid credentials (md5)
|
||||
echo "local all postgres peer" >> $PGDATA/pg_hba.conf
|
||||
echo "host all all 0.0.0.0/0 md5" >> $PGDATA/pg_hba.conf
|
||||
fi
|
||||
|
||||
init_db_when_ready &
|
||||
|
||||
# Start PostgreSQL
|
||||
echo "Starting PostgreSQL..."
|
||||
setuser postgres /usr/lib/postgresql/9.3/bin/postgres -D /etc/postgresql/9.3/main
|
||||
setuser postgres /usr/lib/postgresql/9.3/bin/postgres -D $PGDATA
|
||||
|
|
15
fig.yml
15
fig.yml
|
@ -1,9 +1,16 @@
|
|||
data:
|
||||
build: docker/data
|
||||
hostname: data
|
||||
domainname: localdomain
|
||||
|
||||
postgres:
|
||||
build: docker/postgres
|
||||
hostname: postgres
|
||||
domainname: localdomain
|
||||
ports:
|
||||
- "5432:5432"
|
||||
volumes_from:
|
||||
- data
|
||||
environment:
|
||||
- CKAN_PASS=ckan_pass
|
||||
- DATASTORE_PASS=datastore_pass
|
||||
|
@ -18,7 +25,7 @@ solr:
|
|||
- ./_src/ckan/ckan/config/solr/schema.xml:/opt/solr/example/solr/ckan/conf/schema.xml
|
||||
|
||||
datapusher:
|
||||
build: _service-provider/datapusher
|
||||
build: _service-provider/_datapusher
|
||||
hostname: datapusher
|
||||
domainname: localdomain
|
||||
ports:
|
||||
|
@ -37,13 +44,15 @@ ckan:
|
|||
- solr:solr
|
||||
- datapusher:datapusher
|
||||
command: /sbin/my_init --enable-insecure-key
|
||||
volumes_from:
|
||||
- data
|
||||
volumes:
|
||||
- ./_src:/usr/lib/ckan/default/src
|
||||
- ./_etc/ckan/custom_options.ini:/etc/ckan/default/custom_options.ini
|
||||
- ./_etc/supervisor/conf.d:/etc/supervisor/conf.d
|
||||
|
||||
nginx:
|
||||
image: nginx:1.7.6
|
||||
build: docker/nginx
|
||||
hostname: nginx
|
||||
domainname: localdomain
|
||||
links:
|
||||
|
@ -51,7 +60,7 @@ nginx:
|
|||
ports:
|
||||
- "80:80"
|
||||
volumes:
|
||||
- ./_etc/nginx/nginx.conf:/etc/nginx/nginx.conf
|
||||
- ./docker/nginx/nginx.conf:/etc/nginx/nginx.conf
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue