Initial commit

This commit is contained in:
Sebastian Hugentobler 2018-05-29 09:39:04 +02:00
commit bc8b826e7c
10 changed files with 154 additions and 0 deletions

9
.editorconfig Normal file
View File

@ -0,0 +1,9 @@
root = true
[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 4

2
.gitignore vendored Executable file
View File

@ -0,0 +1,2 @@
*~
.DS_Store

10
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,10 @@
build:
image: docker:latest
services:
- docker:dind
stage: build
script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- docker build --pull --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA .
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA

45
Dockerfile Normal file
View File

@ -0,0 +1,45 @@
FROM registry.gitlab.com/thallian/docker-php7-fpm:master
ENV FPMUSER nginx
ENV FPMGROUP nginx
ENV VERSION master
RUN apk add --no-cache \
libressl \
git \
nginx \
wget \
php7 \
php7-opcache \
php7-pcntl \
php7-gd \
php7-sqlite3 \
php7-json \
php7-intl \
php7-xml \
php7-mbstring \
php7-zip \
php7-openssl \
php7-phar \
php7-pdo_sqlite \
php7-ctype \
php7-xmlwriter \
php7-dom
RUN mkdir -p /usr/share/webapps/cops
RUN wget -qO- https://github.com/seblucas/cops/archive/$VERSION.tar.gz | tar xz -C /usr/share/webapps/cops --strip 1
WORKDIR /usr/share/webapps/cops
RUN wget https://getcomposer.org/composer.phar
RUN php composer.phar global require "fxp/composer-asset-plugin:~1.1"
RUN php composer.phar install --no-dev --optimize-autoloader
RUN chown -R nginx:nginx /usr/share/webapps/cops
RUN mkdir /run/nginx
RUN rm /etc/nginx/conf.d/default.conf
ADD /rootfs /
VOLUME /var/lib/cops/calibre

16
README.md Normal file
View File

@ -0,0 +1,16 @@
[COPS](https://github.com/seblucas/cops), a web-based light alternative to Calibre content server.
# Volumes
- `/var/lib/cops/calibre`
# Environment Variables
## DOMAIN
Domain where the cops instance is reachable.
## TITLE
- default: COPS
Website title.
# Ports
- 80

View File

@ -0,0 +1,3 @@
[template]
src = "config_local.php.tmpl"
dest = "/usr/share/webapps/cops/config_local.php"

View File

@ -0,0 +1,3 @@
[template]
src = "cops.conf.tmpl"
dest = "/etc/nginx/conf.d/cops.conf"

View File

@ -0,0 +1,13 @@
<?php
if (!isset($config))
$config = array();
$config['calibre_directory'] = '/var/lib/cops/calibre/';
$config['calibre_internal_directory'] = '/calibre/';
$config['cops_full_url'] = '{{ getenv "DOMAIN" }}';
$config['cops_x_accel_redirect'] = "X-Accel-Redirect";
$config['cops_title_default'] = "{{ getenv "TITLE" "COPS" }}";
$config['cops_use_url_rewriting'] = "1";

View File

@ -0,0 +1,50 @@
error_log /dev/stdout info;
access_log /dev/stdout;
upstream php {
server 127.0.0.1:9000;
}
server {
listen 80;
server_name {{getenv "DOMAIN"}};
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header X-Robots-Tag none;
add_header X-Download-Options noopen;
add_header X-Permitted-Cross-Domain-Policies none;
index index.php;
root /usr/share/webapps/cops/;
gzip on;
gzip_vary on;
gzip_comp_level 4;
gzip_min_length 256;
location /download/ {
rewrite ^/download/(\d+)/(\d+)/.*\.(.*)$ /fetch.php?data=$1&db=$2&type=$3 last;
rewrite ^/download/(\d+)/.*\.(.*)$ /fetch.php?data=$1&type=$2 last;
break;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param HTTPS on;
fastcgi_param modHeadersAvailable true;
fastcgi_param front_controller_active true;
fastcgi_pass php;
fastcgi_intercept_errors on;
}
location /calibre {
root /var/lib/cops;
internal;
}
}

View File

@ -0,0 +1,3 @@
#!/usr/bin/with-contenv sh
exec nginx -g "daemon off;"