diff --git a/.github/workflows/publish-develop-image.yml b/.github/workflows/publish-develop-image.yml index ac2eb99..858a41c 100644 --- a/.github/workflows/publish-develop-image.yml +++ b/.github/workflows/publish-develop-image.yml @@ -7,20 +7,35 @@ on: jobs: build: runs-on: ubuntu-latest + steps: - name: Checkout uses: actions/checkout@v2 + + - name: Read CKAN_UNI_VERSION from docker/ckan/files/env/base.env + run: | + echo "CKAN_UNI_VERSION=$(grep CKAN_UNI_VERSION docker/ckan/files/env/base.env | cut -d '=' -f2)" >> $GITHUB_ENV + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 + - name: Login to DockerHub uses: docker/login-action@v1 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build develop version for ckan-base 2.9 + + - name: Build develop UNCKAN ver ${{ env.CKAN_UNI_VERSION }} uses: docker/build-push-action@v2 with: - context: ckan-2.9/ckan - file: ckan-2.9/ckan/Dockerfile + context: docker/ckan + file: docker/ckan/Dockerfile push: true - tags: avdata99/ckan-env:ckan29 + build-args: | + ENV_NAME=gh-action + TZ=America/Argentina/Cordoba + tags: | + avdata99/unckan:dev + avdata99/unckan:dev-${{ env.CKAN_UNI_VERSION }} + env: + CKAN_UNI_VERSION: ${{ env.CKAN_UNI_VERSION }} diff --git a/.github/workflows/publish-latest-image.yml b/.github/workflows/publish-latest-image.yml index 8a422fa..8786df0 100644 --- a/.github/workflows/publish-latest-image.yml +++ b/.github/workflows/publish-latest-image.yml @@ -2,7 +2,7 @@ name: Build and publish production docker-ckan image version on: push: branches: - - master + - main jobs: build: @@ -10,17 +10,31 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 + + - name: Read CKAN_UNI_VERSION from docker/ckan/files/env/base.env + run: | + echo "CKAN_UNI_VERSION=$(grep CKAN_UNI_VERSION docker/ckan/files/env/base.env | cut -d '=' -f2)" >> $GITHUB_ENV + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 + - name: Login to DockerHub uses: docker/login-action@v1 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build latest version for ckan-base 2.9 + + - name: Build develop UNCKAN ver ${{ env.CKAN_UNI_VERSION }} uses: docker/build-push-action@v2 with: - context: ckan-2.9/ckan - file: ckan-2.9/ckan/Dockerfile-prod + context: docker/ckan + file: docker/ckan/Dockerfile push: true - tags: avdata99/ckan-env:latest + build-args: | + ENV_NAME=gh-action + TZ=America/Argentina/Cordoba + tags: | + avdata99/unckan:latest + avdata99/unckan:${{ env.CKAN_UNI_VERSION }} + env: + CKAN_UNI_VERSION: ${{ env.CKAN_UNI_VERSION }} \ No newline at end of file diff --git a/.github/workflows/test-build.yml b/.github/workflows/test-build.yml new file mode 100644 index 0000000..1c6f594 --- /dev/null +++ b/.github/workflows/test-build.yml @@ -0,0 +1,34 @@ +name: Test Build +on: + - push + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Read CKAN_UNI_VERSION from docker/ckan/files/env/base.env + id: read_version + run: | + UNI_VERSION=$(grep CKAN_UNI_VERSION docker/ckan/files/env/base.env | cut -d '=' -f2) + echo "CKAN_UNI_VERSION found $UNI_VERSION" + echo "CKAN_UNI_VERSION=$UNI_VERSION" >> $GITHUB_ENV + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Build develop UNCKAN ver ${{ env.CKAN_UNI_VERSION }} + uses: docker/build-push-action@v2 + with: + context: docker/ckan + file: docker/ckan/Dockerfile + build-args: | + ENV_NAME=gh-action + TZ=America/Argentina/Cordoba + push: false + env: + CKAN_UNI_VERSION: ${{ env.CKAN_UNI_VERSION }} + diff --git a/.gitignore b/.gitignore index dec81cf..729bb03 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ docker-compose.yml docker-compose-prod.yml docker/src/* +docker/ckan/files/env/local.env *.pyc *.pyo diff --git a/README.md b/README.md index ca72c91..cca6121 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -[![Docker Stars](https://img.shields.io/docker/stars/avdata99/ckan-env.svg)](https://hub.docker.com/r/avdata99/ckan-env/tags) -[![Docker Pulls](https://img.shields.io/docker/pulls/avdata99/ckan-env.svg)](https://hub.docker.com/r/avdata99/ckan-env/tags) -[![Docker Automated](https://img.shields.io/docker/automated/avdata99/ckan-env.svg)](https://hub.docker.com/r/avdata99/ckan-env/tags) -[![Docker Build](https://img.shields.io/docker/build/avdata99/ckan-env.svg)](https://hub.docker.com/r/avdata99/ckan-env/tags) +[![Docker Stars](https://img.shields.io/docker/stars/avdata99/unckan.svg)](https://hub.docker.com/r/avdata99/unckan/tags) +[![Docker Pulls](https://img.shields.io/docker/pulls/avdata99/unckan.svg)](https://hub.docker.com/r/avdata99/unckan/tags) +[![Docker Automated](https://img.shields.io/docker/automated/avdata99/unckan.svg)](https://hub.docker.com/r/avdata99/unckan/tags) +[![Docker Build](https://img.shields.io/docker/build/avdata99/unckan.svg)](https://hub.docker.com/r/avdata99/unckan/tags) # Entorno CKAN para Universidades Argentinas @@ -15,9 +15,9 @@ Al estar desarrollado sobre CKAN este proyecto permite además subir datos manua ## Entorno El portal completo está compuesto por: - - CKAN 2.9 (python 3) + - CKAN 2.10.5 (python 3) + Portal de datos base - - Extensiones + - Extensiones (en progreso) + [SIU Harvester](https://github.com/unckan/ckanext-siu-harvester): Extensión para cosechar datos desde sistemas [SIU](https://www.siu.edu.ar/) usando la librería [pySIUData](https://github.com/unckan/pySIUdata) (creada especialmente como parte de este proceso). + [Dataset previews](https://github.com/unckan/ckanext-datasetpreview): Extensión CKAN para agregar gráficos a los datasets de manera simple. + El template CKAN usado está en el repositorio [UI Universidad](https://github.com/unckan/ckanext-ui-universidad). @@ -32,4 +32,4 @@ docker-compose up ## Imagen pública -La compilación de esta imagen esta [disponible en DockerHub](https://hub.docker.com/r/avdata99/ckan-env/tags?page=1&ordering=last_updated) (el tag ckan29 corresponde a la ultima version en desarrollo). +La compilación de esta imagen esta [disponible en DockerHub](https://hub.docker.com/r/avdata99/unckan/tags?page=1&ordering=last_updated). diff --git a/docker/.env b/docker/.env deleted file mode 100644 index c5b7dc8..0000000 --- a/docker/.env +++ /dev/null @@ -1,97 +0,0 @@ -CKAN_UNI_VERSION=0.1.4 - -# DB image settings -POSTGRES_PASSWORD=ckan -DATASTORE_READONLY_PASSWORD=datastore - -# Basic -CKAN_SITE_ID=default -CKAN_SITE_URL=http://ckan:5000 -CKAN_PORT=5000 -CKAN_SYSADMIN_NAME=ckan_admin -CKAN_SYSADMIN_PASSWORD=test1234 -CKAN_SYSADMIN_EMAIL=your_email@example.com -TZ=America/Argentina/Cordoba - -CKAN_DATASET_PER_PAGE = 5 - -# Database connections (TODO: avoid duplication) -CKAN_SQLALCHEMY_URL=postgresql://ckan:ckan@db/ckan -CKAN_DATASTORE_WRITE_URL=postgresql://ckan:ckan@db/datastore -CKAN_DATASTORE_READ_URL=postgresql://datastore_ro:datastore@db/datastore - -# Test database connections -TEST_CKAN_SQLALCHEMY_URL=postgres://ckan:ckan@db/ckan_test -TEST_CKAN_DATASTORE_WRITE_URL=postgresql://ckan:ckan@db/datastore_test -TEST_CKAN_DATASTORE_READ_URL=postgresql://datastore_ro:datastore@db/datastore_test - -# Other services connections -CKAN_SOLR_URL=http://solr:8983/solr/ckan -CKAN_REDIS_URL=redis://redis:6379/1 - -TEST_CKAN_SOLR_URL=http://solr:8983/solr/ckan -TEST_CKAN_REDIS_URL=redis://redis:6379/1 - -# Core settings -CKAN__STORAGE_PATH=/var/lib/ckan - -CKAN_SMTP_SERVER=smtp.corporateict.domain:25 -CKAN_SMTP_STARTTLS=True -CKAN_SMTP_USER=user -CKAN_SMTP_PASSWORD=pass -CKAN_SMTP_MAIL_FROM=ckan@localhost - -# Extensions - -CKAN__PLUGINS=envvars stats image_view text_view recline_view recline_grid_view recline_graph_view datatables_view webpage_view ui_universidad datastore xloader pages harvest siu siu_transp_harvester datasetpreview linechart barchart piechart basicgrid - -CKAN__HARVEST__MQ__TYPE=redis -CKAN__HARVEST__MQ__HOSTNAME=redis -CKAN__HARVEST__MQ__PORT=6379 -CKAN__HARVEST__MQ__REDIS_DB=1 - -# XLoader - -# Default of an sqlite file is fine for development. For production use a -# Postgresql database. -CKANEXT__XLOADER__JOBS_DB__URI=sqlite:////tmp/xloader_jobs.db - -# The formats that are accepted. If the value of the resource.format is -# anything else then it won't be 'xloadered' to DataStore (and will therefore -# only be available to users in the form of the original download/link). -# Case insensitive. -# (optional, defaults are listed in plugin.py - DEFAULT_FORMATS). -CKANEXT__XLOADER__FORMATS=csv application/csv xls application/vnd.ms-excel - -# The maximum size of files to load into DataStore. In bytes. Default is 1 GB. -CKANEXT__XLOADER__MAX_CONTENT_LENGTH=1000000000 - -# To always use messytables to load data, instead of attempting a direct -# PostgreSQL COPY, set this to True. This more closely matches the -# DataPusher's behavior. It has the advantage that the column types -# are guessed. However it is more error prone, far slower and you can't run -# the CPU-intensive queue on a separate machine. -CKANEXT__XLOADER__JUST_LOAD_WITH_MESSYTABLES=False - -# The maximum time for the loading of a resource before it is aborted. -# Give an amount in seconds. Default is 60 minutes -CKANEXT__XLOADER__JOB_TIMEOUT=3600 - -# Ignore the file hash when submitting to the DataStore, if set to True -# resources are always submitted (if their format matches), if set to -# False (default), resources are only submitted if their hash has changed. -CKANEXT__XLOADER__IGNORE_HASH=False - -# When loading a file that is bigger than `max_content_length`, xloader can -# still try and load some of the file, which is useful to display a -# preview. Set this option to the desired number of lines/rows that it -# loads in this case. -# If the file-type is supported (CSV, TSV) an excerpt with the number of -# `max_excerpt_lines` lines will be submitted while the `max_content_length` -# is not exceeded. -# If set to 0 (default) files that exceed the `max_content_length` will -# not be loaded into the datastore. -CKANEXT__XLOADER__MAX_EXCERPT_LINES=100 - -# No solo gráficos que tengan extras definidos -CKANEXT__DATASETPREVIEW__DRAW='ALL' diff --git a/docker/Makefile b/docker/Makefile index 7cdc7e6..7246b6c 100644 --- a/docker/Makefile +++ b/docker/Makefile @@ -1,30 +1,35 @@ .PHONY: build clean up debug - + build: - docker-compose build + @if [ ! -f docker-compose.yml ]; then cp docker-compose.example.yml docker-compose.yml; fi + $(eval TZ ?= America/Argentina/Cordoba) + $(eval ENV_NAME ?= local) + BUILDKIT_PROGRESS=plain docker build \ + --file ckan/Dockerfile \ + --build-arg ENV_NAME=${ENV_NAME} \ + --build-arg TZ=${TZ} \ + -t unckan:${ENV_NAME} ckan + echo "Build done unckan:${ENV_NAME}" + +down: + docker compose down clean: - docker-compose down -v --remove-orphans + docker compose down -v --remove-orphans debug: - docker-compose build - docker-compose run --service-ports ckan + docker compose build + docker compose run --service-ports ckan_uni up: - docker-compose up + docker compose up build-up: - docker-compose build - docker-compose up - -gather: - docker-compose exec ckan ckan harvester gather-consumer - -fetch: - docker-compose exec ckan ckan harvester fetch-consumer - -harvest-run: - docker-compose exec ckan ckan harvester run + docker compose build + docker compose up ckan-worker: - docker-compose exec ckan ckan jobs worker + docker compose exec ckan_uni ckan jobs worker + +bash: + docker compose exec ckan_uni bash diff --git a/docker/ckan/Dockerfile b/docker/ckan/Dockerfile index 796c812..314afc1 100644 --- a/docker/ckan/Dockerfile +++ b/docker/ckan/Dockerfile @@ -1,130 +1,62 @@ -FROM alpine:3.13 +FROM debian:stable-slim + +# Args +ARG TZ +ARG ENV_NAME # Internals, you probably don't need to change these -ENV APP_DIR=/srv/app -ENV SRC_DIR=/srv/app/src +ENV APP_DIR=/app/unckan ENV CKAN_INI=${APP_DIR}/ckan.ini -ENV PIP_SRC=${SRC_DIR} -ENV CKAN_STORAGE_PATH=/var/lib/ckan -ENV GIT_URL=https://github.com/ckan/ckan.git -# CKAN version to build -ENV GIT_BRANCH=ckan-2.9.8 -# Customize these on the .env file if needed -ENV CKAN_SITE_URL=http://localhost:5000 -ENV CKAN__PLUGINS image_view text_view recline_view datastore envvars WORKDIR ${APP_DIR} +RUN apt update -# Install necessary packages to run CKAN -RUN apk add --no-cache tzdata \ - git \ - gettext \ - postgresql-client \ - python3 \ - libxml2 \ - libxslt \ - musl-dev \ - uwsgi \ - uwsgi-http \ - uwsgi-corerouter \ - uwsgi-python \ - py3-gevent \ - uwsgi-gevent \ - libmagic \ - curl \ - patch \ - sudo && \ - # Packages to build CKAN requirements and plugins - apk add --no-cache --virtual .build-deps \ - postgresql-dev \ - gcc \ - make \ - g++ \ - autoconf \ - automake \ - libtool \ - python3-dev \ - libxml2-dev \ - libxslt-dev \ - linux-headers \ - openssl-dev \ - libffi-dev \ - cargo && \ - # Create SRC_DIR - mkdir -p ${SRC_DIR} && \ - # Install pip, supervisord and uwsgi - curl -o ${SRC_DIR}/get-pip.py https://bootstrap.pypa.io/get-pip.py && \ - python3 ${SRC_DIR}/get-pip.py && \ - pip3 install -U pip && \ - pip3 install supervisor && \ - mkdir /etc/supervisord.d && \ - #pip wheel --wheel-dir=/wheels uwsgi gevent && \ - rm -rf ${SRC_DIR}/get-pip.py +# Copy files one by one to ensure Dockerfile is caching layers +# and the change in one file does not invalidate the cache of the others -COPY common/supervisord.conf /etc +# Prepare the environment vars +COPY files/scripts/build-env-vars.sh ${APP_DIR}/files/scripts/build-env-vars.sh -# Install CKAN -RUN pip3 install -e git+${GIT_URL}@${GIT_BRANCH}#egg=ckan && \ - cd ${SRC_DIR}/ckan && \ - cp who.ini ${APP_DIR} && \ - pip3 install -r requirement-setuptools.txt && \ - pip3 install --no-binary :all: -r requirements.txt && \ - # Install CKAN envvars to support loading config from environment variables - pip3 install -e git+https://github.com/okfn/ckanext-envvars.git#egg=ckanext-envvars && \ - # Create and update CKAN config - ckan generate config ${CKAN_INI} && \ - ckan config-tool ${CKAN_INI} "ckan.plugins = ${CKAN__PLUGINS}" && \ - ckan config-tool ${CKAN_INI} "ckan.site_url = ${CKAN__SITE_URL}" +COPY files/env/base.env ${APP_DIR}/files/env/base.env +COPY files/env/${ENV_NAME}.env ${APP_DIR}/files/env/${ENV_NAME}.env +RUN ${APP_DIR}/files/scripts/build-env-vars.sh -# Create a local user and group to run the app -RUN addgroup -g 92 -S ckan && \ - adduser -u 92 -h /srv/app -H -D -S -G ckan ckan +# Install OS dependencies +COPY files/scripts/install-python.sh ${APP_DIR}/files/scripts/install-python.sh +RUN ${APP_DIR}/files/scripts/install-python.sh -# Create local storage folder -RUN mkdir -p $CKAN_STORAGE_PATH && \ - chown -R ckan:ckan $CKAN_STORAGE_PATH +COPY files/scripts/install-os-deps.sh ${APP_DIR}/files/scripts/install-os-deps.sh +RUN ${APP_DIR}/files/scripts/install-os-deps.sh -COPY setup/prerun.py ${APP_DIR} -COPY setup/supervisor.worker.conf /etc/supervisord.d/worker.conf -COPY setup/start_ckan.sh ${APP_DIR} -COPY setup/start_ckan_dev.sh ${APP_DIR} -ADD https://raw.githubusercontent.com/ckan/ckan/${GIT_BRANCH}/wsgi.py ${APP_DIR} +COPY files/etc/supervisord.base ${APP_DIR}/files/etc/supervisord.conf +COPY files/etc/ckan*.conf ${APP_DIR}/files/etc/ +COPY files/scripts/prepare-supervisor.sh ${APP_DIR}/files/scripts/prepare-supervisor.sh +RUN ${APP_DIR}/files/scripts/prepare-supervisor.sh -# Create entrypoint directory for children image scripts -ONBUILD RUN mkdir /docker-entrypoint.d -COPY docker-entrypoint.d/* /docker-entrypoint.d/ +# Copy all pending files +COPY files/scripts/prepare-local-dev-extensions.sh ${APP_DIR}/files/scripts/prepare-local-dev-extensions.sh +COPY files/cert/localhost.cert ${APP_DIR}/files/cert/localhost.cert +COPY files/cert/localhost.key ${APP_DIR}/files/cert/localhost.key -RUN chown ckan -R /srv/app +COPY files/patches ${APP_DIR}/files/patches +COPY files/ckan.ini ${CKAN_INI} +COPY files/scripts/install-ckan.sh ${APP_DIR}/files/scripts/install-ckan.sh +COPY files/scripts/setup-ckan-ini-file.sh ${APP_DIR}/files/scripts/setup-ckan-ini-file.sh -EXPOSE 5000 +# Create the ckan user +RUN useradd -m -s /bin/bash ckan +RUN chown ckan -R ${APP_DIR} +RUN chown ckan -R /var/log/supervisor +USER ckan -HEALTHCHECK --interval=60s --timeout=5s --retries=5 CMD curl --fail http://localhost:5000/api/3/action/status_show || exit 1 - -# Set timezone -ARG TZ -# RUN echo $TZ > /etc/timezone -# RUN cp /usr/share/zoneinfo/$TZ /etc/localtime - -RUN echo America/Argentina/Cordoba > /etc/timezone -RUN cp /usr/share/zoneinfo/America/Argentina/Cordoba /etc/localtime - -# Install this project requirements -COPY ckan-uni-requirements.txt ${APP_DIR} -RUN pip3 install -r ${APP_DIR}/ckan-uni-requirements.txt - -# Apply any patches needed to CKAN core or any of the built extensions (not the -# runtime mounted ones) -# See https://github.com/okfn/docker-ckan#applying-patches -COPY patches ${APP_DIR}/patches +# Install CKAN +RUN ${APP_DIR}/files/scripts/install-ckan.sh +RUN cp $APP_DIR/ckan/wsgi.py . +RUN chmod u+x wsgi.py +RUN ${APP_DIR}/files/scripts/setup-ckan-ini-file.sh -RUN for d in $APP_DIR/patches/*; do \ - if [ -d $d ]; then \ - for f in `ls $d/*.patch | sort -g`; do \ - cd $SRC_DIR/`basename "$d"` && echo "$0: Applying patch $f to $SRC_DIR/`basename $d`"; patch -p1 < "$f" ; \ - done ; \ - fi ; \ - done +HEALTHCHECK --interval=60s --timeout=5s --retries=5 CMD curl --fail http://localhost:5000/api/3/action/status_show || exit 1 +EXPOSE 5000 -ENV SRC_EXTENSIONS_DIR=/srv/app/src_extensions -RUN pip3 install flask-debugtoolbar -CMD ["/srv/app/start_ckan_dev.sh"] +COPY files/scripts/entrypoint.sh ${APP_DIR}/entrypoint.sh +ENTRYPOINT [ "./entrypoint.sh" ] diff --git a/docker/ckan/Dockerfile-prod b/docker/ckan/Dockerfile-prod deleted file mode 100644 index 098b10a..0000000 --- a/docker/ckan/Dockerfile-prod +++ /dev/null @@ -1,128 +0,0 @@ -FROM alpine:3.13 - -# Internals, you probably don't need to change these -ENV APP_DIR=/srv/app -ENV SRC_DIR=/srv/app/src -ENV CKAN_INI=${APP_DIR}/ckan.ini -ENV PIP_SRC=${SRC_DIR} -ENV CKAN_STORAGE_PATH=/var/lib/ckan -ENV GIT_URL=https://github.com/ckan/ckan.git -# CKAN version to build -ENV GIT_BRANCH=ckan-2.9.8 -# Customize these on the .env file if needed -ENV CKAN_SITE_URL=http://localhost:5000 -ENV CKAN__PLUGINS image_view text_view recline_view datastore envvars - -WORKDIR ${APP_DIR} - -# Install necessary packages to run CKAN -RUN apk add --no-cache tzdata \ - git \ - gettext \ - postgresql-client \ - python3 \ - libxml2 \ - libxslt \ - musl-dev \ - uwsgi \ - uwsgi-http \ - uwsgi-corerouter \ - uwsgi-python \ - py3-gevent \ - uwsgi-gevent \ - libmagic \ - curl \ - patch \ - sudo && \ - # Packages to build CKAN requirements and plugins - apk add --no-cache --virtual .build-deps \ - postgresql-dev \ - gcc \ - make \ - g++ \ - autoconf \ - automake \ - libtool \ - python3-dev \ - libxml2-dev \ - libxslt-dev \ - linux-headers \ - openssl-dev \ - libffi-dev \ - cargo && \ - # Create SRC_DIR - mkdir -p ${SRC_DIR} && \ - # Install pip, supervisord and uwsgi - curl -o ${SRC_DIR}/get-pip.py https://bootstrap.pypa.io/get-pip.py && \ - python3 ${SRC_DIR}/get-pip.py && \ - pip3 install -U pip && \ - pip3 install supervisor && \ - mkdir /etc/supervisord.d && \ - #pip wheel --wheel-dir=/wheels uwsgi gevent && \ - rm -rf ${SRC_DIR}/get-pip.py - -COPY common/supervisord.conf /etc - -# Install CKAN -RUN pip3 install -e git+${GIT_URL}@${GIT_BRANCH}#egg=ckan && \ - cd ${SRC_DIR}/ckan && \ - cp who.ini ${APP_DIR} && \ - pip3 install -r requirement-setuptools.txt && \ - pip3 install --no-binary :all: -r requirements.txt && \ - # Install CKAN envvars to support loading config from environment variables - pip3 install -e git+https://github.com/okfn/ckanext-envvars.git#egg=ckanext-envvars && \ - # Create and update CKAN config - ckan generate config ${CKAN_INI} && \ - ckan config-tool ${CKAN_INI} "ckan.plugins = ${CKAN__PLUGINS}" && \ - ckan config-tool ${CKAN_INI} "ckan.site_url = ${CKAN__SITE_URL}" - -# Create a local user and group to run the app -RUN addgroup -g 92 -S ckan && \ - adduser -u 92 -h /srv/app -H -D -S -G ckan ckan - -# Create local storage folder -RUN mkdir -p $CKAN_STORAGE_PATH && \ - chown -R ckan:ckan $CKAN_STORAGE_PATH - -COPY setup/prerun.py ${APP_DIR} -COPY setup/supervisor.worker.conf /etc/supervisord.d/worker.conf -COPY setup/start_ckan.sh ${APP_DIR} -COPY setup/start_ckan_dev.sh ${APP_DIR} -ADD https://raw.githubusercontent.com/ckan/ckan/${GIT_BRANCH}/wsgi.py ${APP_DIR} - -# Create entrypoint directory for children image scripts -ONBUILD RUN mkdir /docker-entrypoint.d -COPY docker-entrypoint.d/* /docker-entrypoint.d/ - -RUN chown ckan -R /srv/app - -EXPOSE 5000 - -HEALTHCHECK --interval=60s --timeout=5s --retries=5 CMD curl --fail http://localhost:5000/api/3/action/status_show || exit 1 - -# Set timezone -ARG TZ -# RUN echo $TZ > /etc/timezone -# RUN cp /usr/share/zoneinfo/$TZ /etc/localtime - -RUN echo America/Argentina/Cordoba > /etc/timezone -RUN cp /usr/share/zoneinfo/America/Argentina/Cordoba /etc/localtime - -# Install this project requirements -COPY ckan-uni-requirements.txt ${APP_DIR} -RUN pip3 install -r ${APP_DIR}/ckan-uni-requirements.txt - -# Apply any patches needed to CKAN core or any of the built extensions (not the -# runtime mounted ones) -# See https://github.com/okfn/docker-ckan#applying-patches -COPY patches ${APP_DIR}/patches - -RUN for d in $APP_DIR/patches/*; do \ - if [ -d $d ]; then \ - for f in `ls $d/*.patch | sort -g`; do \ - cd $SRC_DIR/`basename "$d"` && echo "$0: Applying patch $f to $SRC_DIR/`basename $d`"; patch -p1 < "$f" ; \ - done ; \ - fi ; \ - done - -CMD ["/srv/app/start_ckan.sh"] diff --git a/docker/ckan/ckan-uni-requirements.txt b/docker/ckan/ckan-uni-requirements.txt deleted file mode 100644 index cab9564..0000000 --- a/docker/ckan/ckan-uni-requirements.txt +++ /dev/null @@ -1,22 +0,0 @@ -siu-data>=0.3.5 -ckantoolkit==0.0.3 -pika>=1.1.0 -pyOpenSSL==18.0.0 -# redis>=3.5.3 -redis>=2.10.6 -six>=1.12.0 -messytables==0.15.2 -Unidecode==1.0.22 -requests>=2.23.0 -python-slugify>=1.2.6 -pyexcel>=-0.5.15 -pyexcel-xls>=0.5.8 -pyexcel-xlsx>=0.5.8 - --e git+https://github.com/ckan/ckanext-harvest.git#egg=ckanext-harvest --e git+https://github.com/ckan/ckanext-pages.git#egg=ckanext-pages --e git+https://github.com/ckan/ckanext-xloader.git#egg=ckanext-xloader --e git+https://github.com/unckan/ckanext-siu-harvester.git#egg=ckanext-siu-harvester --e git+https://github.com/unckan/ckanext-datasetpreview.git#egg=ckanext-datasetpreview --e git+https://github.com/localidata/ckanext-basiccharts.git#egg=ckanext-basiccharts --e git+https://github.com/unckan/ckanext-ui-universidad.git#egg=ckanext-ui-universidad diff --git a/docker/ckan/common/supervisord.conf b/docker/ckan/common/supervisord.conf deleted file mode 100644 index a3f6671..0000000 --- a/docker/ckan/common/supervisord.conf +++ /dev/null @@ -1,23 +0,0 @@ -[unix_http_server] -file = /tmp/supervisor.sock -chmod = 0777 -chown = nobody:nogroup - -[supervisord] -logfile = /tmp/supervisord.log -logfile_maxbytes = 50MB -logfile_backups=10 -loglevel = info -pidfile = /tmp/supervisord.pid -nodaemon = true -umask = 022 -identifier = supervisor - -[supervisorctl] -serverurl = unix:///tmp/supervisor.sock - -[rpcinterface:supervisor] -supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface - -[include] -files = /etc/supervisord.d/*.conf diff --git a/docker/ckan/common/uwsgi.conf b/docker/ckan/common/uwsgi.conf deleted file mode 100644 index 6321d6d..0000000 --- a/docker/ckan/common/uwsgi.conf +++ /dev/null @@ -1,2 +0,0 @@ -[uwsgi] -route = ^(?!/api).*$ basicauth:Restricted,/srv/app/.htpasswd diff --git a/docker/ckan/docker-entrypoint.d/100-start-ckanext-harvest.sh b/docker/ckan/docker-entrypoint.d/100-start-ckanext-harvest.sh deleted file mode 100644 index a2120cb..0000000 --- a/docker/ckan/docker-entrypoint.d/100-start-ckanext-harvest.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -echo "Enabling ckanext-harvest" -ckan --config=$CKAN_INI harvester initdb diff --git a/docker/ckan/files/cert/localhost.cert b/docker/ckan/files/cert/localhost.cert new file mode 100644 index 0000000..eb24fc0 --- /dev/null +++ b/docker/ckan/files/cert/localhost.cert @@ -0,0 +1,22 @@ +-----BEGIN CERTIFICATE----- +MIIDtzCCAp+gAwIBAgIUG7oo+0zZ1ynU0q1NMJdhstUy9hgwDQYJKoZIhvcNAQEL +BQAwazELMAkGA1UEBhMCQVIxEDAOBgNVBAgMB0NvcmRvYmExEzARBgNVBAcMCk1l +bmRpb2xhemExDTALBgNVBAoMBE9LRk4xJjAkBgkqhkiG9w0BCQEWF2FuZHJlcy52 +YXpxdWV6QG9rZm4ub3JnMB4XDTI0MDIyMTEzMjY0MloXDTM0MDIxODEzMjY0Mlow +azELMAkGA1UEBhMCQVIxEDAOBgNVBAgMB0NvcmRvYmExEzARBgNVBAcMCk1lbmRp +b2xhemExDTALBgNVBAoMBE9LRk4xJjAkBgkqhkiG9w0BCQEWF2FuZHJlcy52YXpx +dWV6QG9rZm4ub3JnMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvs7I +/XU0xFKyVufvh+TI6ndNHwwkMH+cJG9TKtHPIlab69aMy7QAbDVZwjCeyUxEpR1v +6AOi0ROFANckSTyZkov6VfphifX75Zu9CjFlx4Nxx0QO43ejvPeENhk/A7V/dubD +OIT3/zdZ5KprgLfE0Ue7ozKQsZlDNWEDOn5tEF7y8R/yxIqjKSOzMD1jnE6uymLy +mSdcUvlt+N/NVz4/brH5C82CBzx6J4dD+BcL8T6s1BwqbakKpDsT9wGZBCF2m1t5 +oxrKtCvBORjHIKmveoRC899JlSFFtF7Qgh7eqW7UbPy75ifkP4fE/vmNr970hi/F +Vg438BSXFDIBNu6kFwIDAQABo1MwUTAdBgNVHQ4EFgQU2ddEVsad4Ct7fisvUByt +BRkHjTEwHwYDVR0jBBgwFoAU2ddEVsad4Ct7fisvUBytBRkHjTEwDwYDVR0TAQH/ +BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAkB2a8QH4ILUqTfwCWeurv51BOMfm +TZQQIvFkwx9cFKJO6dTn9BjFSnnZZUvHWx5hvooA6FKZZf4RlAApz1NwGrxDjd2Q +97HnJK1YQ77T1zyKoiNGurateCn7bz0I0M9pZOsdlmdG0HcNiHalF3kx5I3tPJk3 +GPmxi7fF9dE+Mp+zYrIAeiq5QZVYJNTal2bPWWcU9lbOR8Thk+oDwxLeUY9XRfrp +vqdUqPi4waFezqEY2LQCPONTGzhDp3oBgjkB7/YCwSw/gyT7NWlqd/a86HnuWicE +l+Nyj58dMyq5DgpDnCZa7R10SGQNxwVUKrolBqU6aRbRApWjR8SmUWGQVQ== +-----END CERTIFICATE----- diff --git a/docker/ckan/files/cert/localhost.key b/docker/ckan/files/cert/localhost.key new file mode 100644 index 0000000..92d4c3d --- /dev/null +++ b/docker/ckan/files/cert/localhost.key @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEowIBAAKCAQEAvs7I/XU0xFKyVufvh+TI6ndNHwwkMH+cJG9TKtHPIlab69aM +y7QAbDVZwjCeyUxEpR1v6AOi0ROFANckSTyZkov6VfphifX75Zu9CjFlx4Nxx0QO +43ejvPeENhk/A7V/dubDOIT3/zdZ5KprgLfE0Ue7ozKQsZlDNWEDOn5tEF7y8R/y +xIqjKSOzMD1jnE6uymLymSdcUvlt+N/NVz4/brH5C82CBzx6J4dD+BcL8T6s1Bwq +bakKpDsT9wGZBCF2m1t5oxrKtCvBORjHIKmveoRC899JlSFFtF7Qgh7eqW7UbPy7 +5ifkP4fE/vmNr970hi/FVg438BSXFDIBNu6kFwIDAQABAoIBAB7+zFuP7JBvtpSz +fI+gtJqR4q9Gc6KFOEIa63GrP3CejRmUcq6sgN0TFY+cAk9E2mnQDFuuK4a3GwX1 +7OkQtQm/P100HSAiG1dDI0RCnfv4+EScY6bDyo9pzcpT846QrzILbm8B+p80yJ+C +p4/zSj+M3Yg3MJYJBYfoSHP6EZF080RrE3US2LMNeh1fnjVnTdOURWe8IWgUde5n +E8zqxyaKJ66KvmIGEqtPlN/jvr/73Itnz65l/WAN4ENlnHxbYpXwY6sJCvh/ncmy +uihoKNNViHya0fGel1BNJxtZ2ZiW5DufUazdu5l0HWPVhTnth9nUWlG1lp88ihyZ +S6MkP4ECgYEA4WJIsGeBOgbAUW1WphjQOielanVH1qeSDkvGRp2qJHdQI2T8suuV +6rTlbQcd6gjdGC7F44oEWNuy84q1uoVAAsHG0WXDzI4qKy4qOceKGOoVB8jWmIvV +SHQlt8PoCiXam+YnZe0vWpOKJYenEeAOmNi9ZuPJYgQ74zfQvvhbM/cCgYEA2Lod +0J6UmQmdsNqqcQVbdliHvW1e5L6k7sfdBSl6OsW39tG0XRvVAG74mGKBmwNMdH04 +AAr90Qr3aBlvUQ3ps6+SaAA+j7CAHMSnwy9rQdYQloq1PJeXeR4Qzw1aQIVMci2V +SugauIi+yv3dcosFvzKco6alA5cHwN3ik137yOECgYEA3EpsMb95F3Yx02TDJGVs +YOsPSxaGuM/gegimK68+9ZWIxo+WTmrlhRp6hC5Ils9DCrfsw5HK3e8e4dvZ9Az5 +m7g608BbuDvcC4h7zS2zVNa253zuAvvp439ivlLFIeYN3gL+zykc97Lte/Ey4s3U +dqChv0c1NpBc2KFdbsrgmdECgYB7GCKtBhTyYxLMizX5YYiUTC40ufUGyP1Wne/7 +6ZYB4aDeMDdYFuHBEEZkDrb8O0BmfWScKaIF5EunNaMTD2roYtUt+s2NwTrSnCOI +6drqltHvHzNXCea/pQL5BuV29f74bsl3tSLQIuLy2oO3dhy6ft2W2aSpyFNgCOaS +uvOyIQKBgDX71ooeSNXhbSscnWwa0sUetZvkB0Zz2ebje1IXOOfU5T9EI6p7arx4 +NAInkeup/oqgkoR+L5bzqdm6sh8GQ+WQnIX3NfPYS2u4rsDV+mle624DRzf7Z0kV +GnT4XNGjFzZ1yahUzF3k6baHK9O5QJAABu9MhMb3JRDHHqMYt1le +-----END RSA PRIVATE KEY----- diff --git a/docker/ckan/files/ckan.ini b/docker/ckan/files/ckan.ini new file mode 100644 index 0000000..e7471e2 --- /dev/null +++ b/docker/ckan/files/ckan.ini @@ -0,0 +1,299 @@ +# +# CKAN configuration +# +# http://docs.ckan.org/en/latest/maintaining/configuration.html +# +# The %(here)s variable will be replaced with the parent directory of this file +# +[DEFAULT] + +## Default settings ############################################################ +debug = false + +[app:main] + +## General settings ############################################################ +use = egg:ckan +SECRET_KEY = +ckan.legacy_route_mappings = {} +config.mode = strict + +## Development settings ######################################################## +ckan.devserver.host = localhost +ckan.devserver.port = 5000 +ckan.devserver.threaded = false +ckan.devserver.multiprocess = 1 +ckan.devserver.watch_patterns = +ckan.devserver.ssl_cert = +ckan.devserver.ssl_key = + +## Session settings ############################################################ +ckan.user.last_active_interval = 600 +cache_dir = /tmp/%(ckan.site_id)s +beaker.session.key = ckan +beaker.session.secret = string:%(SECRET_KEY)s +beaker.session.auto = false +beaker.session.cookie_expires = false +# beaker.session.cookie_domain = .example.com +beaker.session.save_accessed_time = true +beaker.session.secure = false +beaker.session.timeout = 1200 +beaker.session.type = cookie +beaker.session.validate_key = +beaker.session.httponly = true +beaker.session.samesite = Lax + +## Database settings ########################################################### +sqlalchemy.url = +sqlalchemy.pool_pre_ping = true +# sqlalchemy.