refactor docker swarm to use just home without workers for now

add caching at nginx level for portainer and gitea
This commit is contained in:
2018-04-07 08:11:23 -04:00
parent 3ed65eefe9
commit 83ec6809d6
45 changed files with 438 additions and 192 deletions

View File

@@ -0,0 +1,2 @@
config/config.php
data

4
dockerfiles/services/nextcloud/Dockerfile Normal file → Executable file
View File

@@ -1,3 +1,7 @@
FROM nextcloud:13-fpm
#FROM nextcloud:stable-apache
RUN apt-get update && apt-get install -y smbclient && rm -rf /var/lib/apt/lists/*
COPY php/errorlog.conf /usr/local/etc/php-fpm.d/errorlog.conf

0
dockerfiles/services/nextcloud/Dockerfile-web Normal file → Executable file
View File

View File

@@ -0,0 +1,15 @@
<?php
$CONFIG = array (
"apps_paths" => array (
0 => array (
"path" => OC::$SERVERROOT."/apps",
"url" => "/apps",
"writable" => false,
),
1 => array (
"path" => OC::$SERVERROOT."/custom_apps",
"url" => "/custom_apps",
"writable" => true,
),
),
);

View File

@@ -0,0 +1,42 @@
<?php
$CONFIG = [
'memcache.local' => '\OC\Memcache\APCu',
'memcache.distributed' => '\OC\Memcache\Redis',
'memcache.locking' => '\OC\Memcache\Redis',
'redis' => [
'host' => getenv('REDISHOST'), // can also be a unix domain socket: '/tmp/redis.sock'
'port' => getenv('REDISPORT'),
'timeout' => 0.0,
'password' => '', // Optional, if not defined no password will be used.
'dbindex' => 0, // Optional, if undefined SELECT will not run and will use Redis Server's default DB Index.
],
'memcached_servers' => [
['memcached', 11211],
],
'memcached_options' => array(
// Set timeouts to 50ms
\Memcached::OPT_CONNECT_TIMEOUT => 50,
\Memcached::OPT_RETRY_TIMEOUT => 50,
\Memcached::OPT_SEND_TIMEOUT => 50,
\Memcached::OPT_RECV_TIMEOUT => 50,
\Memcached::OPT_POLL_TIMEOUT => 50,
// Enable compression
\Memcached::OPT_COMPRESSION => true,
// Turn on consistent hashing
\Memcached::OPT_LIBKETAMA_COMPATIBLE => true,
// Enable Binary Protocol
\Memcached::OPT_BINARY_PROTOCOL => true,
// Binary serializer vill be enabled if the igbinary PECL module is available
//\Memcached::OPT_SERIALIZER => \Memcached::SERIALIZER_IGBINARY,
),
];

View File

@@ -0,0 +1,14 @@
<?php
$CONFIG = [
'dbtype' => getenv('DBTYPE'),
'dbhost' => getenv('DBHOST') .':'. getenv('DBPORT'),
'dbname' => getenv('DBNAME'),
'dbuser' => getenv('DBUSER'),
'dbpassword' => getenv('DBPASS'),
'dbtableprefix' => 'oc_',
'mysql.utf8mb4' => true,
];

View File

@@ -0,0 +1,7 @@
<?php
$CONFIG = [
'log_type' => 'errorlog',
'loglevel' => getenv('LOGLEVEL'),
];

View File

@@ -0,0 +1,19 @@
<?php
$CONFIG = [
// 'maintenance' => false,
// 'theme' => '',
//
// 'installed' => false,
//
// 'instanceid' => 'ocxziwl6co38',
// 'passwordsalt' => 'FKWh+oXeNAm2EPHg6mz+9xE48gunGb',
// 'secret' => 'yC3EEMk31oZpas8U65awdT5rxR40+8uP5NEkD82S3iLNNWqr',
// 'trusted_domains' => [
// 0 => 'dkhost.xai-corp.net:8083',
// ],
// 'datadirectory' => '/var/www/html/data',
// 'overwritehost' => 'xaibox.xai-corp.net',
// 'overwriteprotocol' => 'https',
// 'overwrite.cli.url' => 'https://xaibox.xai-corp.net',
];

View File

@@ -0,0 +1,7 @@
#!/bin/bash -ex
export DOCKER_HOST=dkmanager:2376
docker login -u richard -p $DKREGISTRY_PASS $DKREGISTRY
docker stack deploy --with-registry-auth --prune -c docker-compose-prod.yml xaibox

19
dockerfiles/services/nextcloud/docker-compose-build.yml Normal file → Executable file
View File

@@ -5,24 +5,17 @@
# docker-compose build && docker push dkregistry.xai-corp.net:5000/xaicorp/nextcloud:latest
# DOCKER_HOST=dkhost:2376 docker stack deploy --with-registry-auth -c docker-compose-prod.yml owncloud
version: '3'
version: '2'
services:
xaicloud:
image: "dkregistry.xai-corp.net:5000/xaicorp/nextcloud:latest"
build:
context: .
dockerfile: Dockerfile
ports:
- 8083:80
# - 9083:9000
volumes:
- ./data:/var/www/html
dockerfile: ./Dockerfile
image: dkregistry.xai-corp.net:5000/xaicorp/nextcloud:latest
web:
image: "dkregistry.xai-corp.net:5000/xaicorp/nextcloud-web:latest"
build:
context: .
dockerfile: Dockerfile-web
ports:
- 8083:80
context: .
dockerfile: ./Dockerfile-web
image: dkregistry.xai-corp.net:5000/xaicorp/nextcloud-web:latest

79
dockerfiles/services/nextcloud/docker-compose-prod.yml Normal file → Executable file
View File

@@ -11,12 +11,25 @@ volumes:
services:
xaicloud:
app:
image: "dkregistry.xai-corp.net:5000/xaicorp/nextcloud:latest"
# ports:
# - 8083:80
volumes:
- /opt/shared/nextcloud/data:/var/www/html/data
- /opt/shared/nextcloud/config:/var/www/html/config
- /opt/shared/nextcloud/apps:/var/www/html/custom_apps
# - code:/var/www/html
- /opt/nextcloud/nextcloud2/data:/var/www/html/data
- /opt/nextcloud/nextcloud2/config:/var/www/html/config
- /opt/nextcloud/nextcloud2/apps:/var/www/html/custom_apps
environment:
- DBTYPE=mysql
- DBHOST=sql.xai-corp.net
- DBPORT=3306
- DBNAME=nextcloud2
- DBUSER=nextcloud
- DBPASS=xh891hx1hc89f239hibndnxc1i
- REDISHOST=tasks.services_redis
- REDISPORT=6379
- LOGLEVEL=3
deploy:
mode: replicated
replicas: 1
@@ -31,8 +44,11 @@ services:
resources:
limits:
memory: 512M
networks:
- prod
- prod_app
- prod_db
- prod_cache
# logging:
# driver: fluentd
@@ -40,6 +56,7 @@ services:
# fluentd-address: "logs.xai-corp.net:24224"
# fluentd-async-connect: 'true'
# tag: nextcloud
#
web:
image: "dkregistry.xai-corp.net:5000/xaicorp/nextcloud-web:latest"
@@ -47,9 +64,10 @@ services:
- 8083:80
volumes:
- cache:/data/nginx/cache/nextcloud
- /opt/shared/nextcloud/data:/var/www/html/data
- /opt/shared/nextcloud/config:/var/www/html/config
- /opt/shared/nextcloud/apps:/var/www/html/custom_apps
# - code:/var/www/html
- /opt/nextcloud/nextcloud2/data:/var/www/html/data
- /opt/nextcloud/nextcloud2/config:/var/www/html/config
- /opt/nextcloud/nextcloud2/apps:/var/www/html/custom_apps
deploy:
mode: replicated
@@ -72,42 +90,19 @@ services:
# timeout: 1s
# retries: 2
networks:
- ingress
- prod
# collabora:
# image: collabora/code
# ports:
# - 9980:9980
# environment:
# domain: office\\.xai-corp\\.net
# username: admin
# password: ah8031qhnbc
# server_name: office.xai-corp.net
#
# deploy:
# mode: replicated
# replicas: 0
# restart_policy:
# condition: any
# delay: "1s"
# max_attempts: 5
# update_config:
# parallelism: 1
# delay: 2s
# order: start-first
# resources:
# limits:
# cpus: '1'
# memory: 512M
- prod_ui
- prod_app
networks:
default:
prod_ui:
external:
name: ingress
ingress:
name: prod_ui
prod_db:
external:
name: ingress
prod:
name: prod_db
prod_cache:
external:
name: prod
name: prod_cache
prod_app:
external:
name: prod_app

44
dockerfiles/services/nextcloud/docker-compose.yml Normal file → Executable file
View File

@@ -5,10 +5,10 @@
# docker-compose build && docker push dkregistry.xai-corp.net:5000/xaicorp/nextcloud:latest
# DOCKER_HOST=dkhost:2376 docker stack deploy --with-registry-auth -c docker-compose-prod.yml owncloud
version: '2'
version: '3'
volumes:
nextcloud:
# nextcloud:
db:
cache:
@@ -25,21 +25,41 @@ services:
- MYSQL_USER=nextcloud
xaicloud:
image: nextcloud:fpm
links:
- db
image: dkregistry.xai-corp.net:5000/xaicorp/nextcloud:latest
volumes:
- nextcloud:/var/www/html
# - nextcloud:/var/www/html
- ./config:/var/www/html/config
- ./php/errorlog.conf:/usr/local/etc/php-fpm.d/errorlog.conf
environment:
- DBTYPE=mysql
- DBHOST=db
- DBPORT=3306
- DBNAME=nextcloud
- DBUSER=nextcloud
- DBPASS=test
- REDISHOST=redis
- REDISPORT=6379
- LOGLEVEL=3
web:
image: nginx
image: dkregistry.xai-corp.net:5000/xaicorp/nextcloud-web:latest
ports:
- 8083:80
links:
- app
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
- cache:/data/nginx/cache/nextcloud
volumes_from:
- app
# - nextcloud:/var/www/html
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
- ./config:/var/www/html/config
memcached:
image: "memcached:alpine"
ports:
- "11211:11211"
command:
- memcached
- -m64
redis:
image: "redis:4-alpine"
ports:
- "6379:6379"

View File

@@ -1,16 +1,23 @@
proxy_cache_path /data/nginx/cache/nextcloud levels=1:2 keys_zone=my_cache:10m max_size=10g
inactive=60m use_temp_path=off;
upstream xaibox_upstream {
server tasks.xaibox_app:9000;
}
server {
listen 80;
index index.php index.html;
server_name docker.test;
server_name xaibox.xai-corp.net;
client_max_body_size 256m;
root /var/www/html;
location /remote.php {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass tasks.xaicloud:9000;
fastcgi_pass xaibox_upstream;
fastcgi_index remote.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
@@ -18,18 +25,51 @@ server {
fastcgi_param PATH_INFO $fastcgi_path_info;
}
location / {
try_files $uri /index.php?$args;
}
# location / {
location ~ \.php$ {
location /public.php {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass tasks.xaicloud:9000;
fastcgi_index index.php;
fastcgi_pass xaibox_upstream;
fastcgi_index public.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# fastcgi_param SCRIPT_FILENAME $document_root/index.php;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
location / {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass xaibox_upstream;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
location /index.php {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass xaibox_upstream;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
fastcgi_param HTTP_PROXY "";
fastcgi_pass xaibox_upstream;
#fastcgi_index public.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#fastcgi_param SCRIPT_FILENAME $document_root/index.php;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
#location / {
# try_files $uri $uri/;
#}
}

View File

@@ -0,0 +1,2 @@
[www]
catch_workers_output = yes