diff --git a/Dockerfile b/Dockerfile old mode 100755 new mode 100644 index 204b367..e3b446a --- a/Dockerfile +++ b/Dockerfile @@ -1,84 +1,15 @@ -FROM alpine:3.13.5 +FROM nginx:1.19.8-alpine -ENV APP_DIR=/srv/app -ENV SRC_DIR=${APP_DIR}/src -ENV GIT_URL https://github.com/kowh-ai/datapusher.git -#ENV GIT_URL https://github.com/keitaroinc/datapusher.git -ENV GIT_BRANCH master -ENV JOB_CONFIG ${APP_DIR}/datapusher_settings.py -ENV CKAN__PLUGINS image_view text_view recline_view datastore datapusher envvars +ENV NGINX_DIR=/etc/nginx -WORKDIR ${APP_DIR} +COPY index.html /usr/share/nginx/html/index.html -RUN apk upgrade && \ - apk add --no-cache \ - python3 \ - curl \ - gcc \ - make \ - g++ \ - autoconf \ - automake \ - libtool \ - git \ - musl-dev \ - python3-dev \ - libffi-dev \ - openssl-dev \ - libxml2-dev \ - libxslt-dev \ - rust \ - cargo +RUN mkdir -p ${NGINX_DIR}/sites-available +RUN mkdir -p ${NGINX_DIR}/sites-enabled -RUN apk add --no-cache \ - uwsgi \ - uwsgi-http \ - uwsgi-corerouter \ - uwsgi-python +COPY setup/nginx.conf ${NGINX_DIR} +COPY setup/sites-available/* ${NGINX_DIR}/sites-available -# Create the src directory -RUN mkdir -p ${SRC_DIR} +RUN ln -s ${NGINX_DIR}/sites-available/ckan.conf ${NGINX_DIR}/sites-enabled/ckan.conf -# Install pip -RUN curl -o ${SRC_DIR}/get-pip.py https://bootstrap.pypa.io/get-pip.py && \ - python3 ${SRC_DIR}/get-pip.py - -# Install datapusher -RUN cd ${SRC_DIR} && \ - git clone -b ${GIT_BRANCH} --depth=1 --single-branch ${GIT_URL} && \ - cd datapusher && \ - python3 setup.py install && \ - pip3 install --no-cache-dir -r requirements.txt - -RUN cp ${APP_DIR}/src/datapusher/deployment/*.* ${APP_DIR} && \ - # Remove default values in ini file - sed -i '/http/d' ${APP_DIR}/datapusher-uwsgi.ini && \ - sed -i '/wsgi-file/d' ${APP_DIR}/datapusher-uwsgi.ini && \ - sed -i '/virtualenv/d' ${APP_DIR}/datapusher-uwsgi.ini - # Remove src files - #rm -rf ${APP_DIR}/src - -# Install and configure supervisor -RUN pip3 install supervisor && \ -mkdir /etc/supervisord.d - -# Copy all setup files -COPY setup/start_datapusher.sh ${APP_DIR} -COPY setup/datapusher-uwsgi.ini ${APP_DIR} -COPY setup/datapusher_settings.py ${APP_DIR} -COPY setup/supervisor.uwsgi.conf /etc/supervisord.d/datapusher.uwsgi.conf -COPY setup/supervisord.conf /etc/supervisord.conf - -# Create a 'ckan' local user and group to run the app -RUN addgroup -g 92 -S www-data && \ - adduser -u 92 -h /srv/app -H -D -S -G www-data www-data - -# Set timezone -RUN echo "UTC" > /etc/timezone && \ - # Change ownership to app user - chown -R www-data:www-data /srv/app - -EXPOSE 8800 -CMD ["/srv/app/start_datapusher.sh"] -#CMD ["sh", "-c", \ -# "uwsgi --plugins=http,python --http=0.0.0.0:8800 --socket=/tmp/uwsgi.sock --ini=`echo ${APP_DIR}`/datapusher-uwsgi.ini --wsgi-file=`echo ${APP_DIR}`/datapusher.wsgi"] +EXPOSE 80 \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..561b63b --- /dev/null +++ b/index.html @@ -0,0 +1,22 @@ + + + + + + + CKAN Docker NGINX landing page + + + + +

+ CKAN Docker NGINX landing page +

+ + + \ No newline at end of file diff --git a/setup/nginx.conf b/setup/nginx.conf new file mode 100644 index 0000000..7f06cea --- /dev/null +++ b/setup/nginx.conf @@ -0,0 +1,34 @@ + +user nginx; +worker_processes auto; + +error_log /var/log/nginx/error.log warn; +pid /var/run/nginx.pid; + + +events { + worker_connections 1024; +} + + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; + + sendfile on; + #tcp_nopush on; + + keepalive_timeout 65; + + #gzip on; + + include /etc/nginx/sites-enabled/*.conf; +} + + diff --git a/setup/sites-available/ckan.conf b/setup/sites-available/ckan.conf new file mode 100644 index 0000000..7ffc6bb --- /dev/null +++ b/setup/sites-available/ckan.conf @@ -0,0 +1,18 @@ +proxy_cache_path /tmp/nginx_cache levels=1:2 keys_zone=cache:30m max_size=250m; +proxy_temp_path /tmp/nginx_proxy 1 2; + +server { + client_max_body_size 100M; + location / { + proxy_pass http://ckan:5000/; + proxy_set_header X-Forwarded-For $remote_addr; + proxy_set_header Host $host; + proxy_cache cache; + proxy_cache_bypass $cookie_auth_tkt; + proxy_no_cache $cookie_auth_tkt; + proxy_cache_valid 30m; + proxy_cache_key $host$scheme$proxy_host$request_uri; + # In emergency comment out line to force caching + # proxy_ignore_headers X-Accel-Expires Expires Cache-Control; + } +} \ No newline at end of file