Owncloud image
This commit is contained in:
parent
071dae17b1
commit
0350f0d5b1
@ -1,6 +1,56 @@
|
||||
FROM ubuntu:16.04
|
||||
MAINTAINER Przemek Grondek <github@nerull7.info>
|
||||
|
||||
ENV OWNCLOUD_VER 10.0.2
|
||||
|
||||
ENV DEBIAN_FRONTEND noninteractive
|
||||
RUN apt-get update
|
||||
RUN apt-get install -y nginx mysql-server php-fpm php-mysql pwgen
|
||||
RUN apt-get update && \
|
||||
apt-get install -y nginx mysql-server php-fpm php-mysql php-gd php-json php-curl php-intl php-mcrypt php-imagick php-zip php-xml php-mbstring php-smbclient pwgen bzip2 gosu supervisor && \
|
||||
apt-get clean
|
||||
|
||||
# Make required catalogs
|
||||
RUN mkdir -p /data/mysql \
|
||||
/data/owncloud \
|
||||
/data/owncloud/config \
|
||||
/data/owncloud/data \
|
||||
/data/nginx-log \
|
||||
/run/mysqld \
|
||||
/run/php
|
||||
|
||||
# Setup php
|
||||
RUN sed -i "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g" /etc/php/7.0/fpm/php.ini
|
||||
|
||||
# Setup nginx
|
||||
RUN rm -rf /etc/nginx/sites-enabled/default
|
||||
ADD owncloud /etc/nginx/sites-available/owncloud
|
||||
RUN ln -s /etc/nginx/sites-available/owncloud /etc/nginx/sites-enabled/owncloud
|
||||
RUN sed -i "s/\/var\/log\/nginx/\/data\/nginx-log/g" /etc/nginx/nginx.conf
|
||||
|
||||
# Setup MySQL
|
||||
RUN sed -i "s/\/var\/lib\/mysql/\/data\/mysql/g" /etc/mysql/mysql.conf.d/mysqld.cnf
|
||||
RUN mv /var/lib/mysql/* /data/mysql
|
||||
RUN chown mysql:mysql /data/mysql /var/run/mysqld
|
||||
|
||||
# Setup owncloud
|
||||
RUN rm -rf /var/www/*
|
||||
ADD https://download.owncloud.org/community/owncloud-${OWNCLOUD_VER}.tar.bz2 /var/www
|
||||
RUN tar xf /var/www/owncloud-${OWNCLOUD_VER}.tar.bz2 -C /var/www
|
||||
RUN mv /var/www/owncloud/* /var/www
|
||||
RUN rm /var/www/owncloud-${OWNCLOUD_VER}.tar.bz2 \
|
||||
/var/www/owncloud/.htaccess \
|
||||
/var/www/owncloud/.user.ini
|
||||
RUN rmdir /var/www/owncloud
|
||||
RUN mv /var/www/apps /data/owncloud && \
|
||||
mv /var/www/config /data/config
|
||||
RUN ln -s /data/owncloud/config /var/www && \
|
||||
ln -s /data/owncloud/apps /var/www && \
|
||||
ln -s /data/owncloud/data /var/www
|
||||
RUN chown -R www-data:www-data /data/owncloud /var/www
|
||||
|
||||
EXPOSE 80
|
||||
VOLUME ["/data"]
|
||||
|
||||
COPY run.sh /
|
||||
COPY supervisord.conf /
|
||||
|
||||
CMD ["/run.sh"]
|
||||
|
63
owncloud/owncloud
Normal file
63
owncloud/owncloud
Normal file
@ -0,0 +1,63 @@
|
||||
server {
|
||||
listen 80 default_server;
|
||||
listen [::]:80 default_server;
|
||||
|
||||
root /var/www;
|
||||
index index.php;
|
||||
|
||||
# set max upload size
|
||||
client_max_body_size 10G;
|
||||
fastcgi_buffers 64 4K;
|
||||
|
||||
# Disable gzip to avoid the removal of the ETag header
|
||||
gzip off;
|
||||
|
||||
rewrite ^/caldav(.*)$ /remote.php/caldav$1 redirect;
|
||||
rewrite ^/carddav(.*)$ /remote.php/carddav$1 redirect;
|
||||
rewrite ^/webdav(.*)$ /remote.php/webdav$1 redirect;
|
||||
|
||||
index index.php;
|
||||
error_page 403 /core/templates/403.php;
|
||||
error_page 404 /core/templates/404.php;
|
||||
|
||||
location / {
|
||||
# The following 2 rules are only needed with webfinger
|
||||
rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
|
||||
rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last;
|
||||
|
||||
rewrite ^/.well-known/carddav /remote.php/carddav/ redirect;
|
||||
rewrite ^/.well-known/caldav /remote.php/caldav/ redirect;
|
||||
|
||||
rewrite ^(/core/doc/[^\/]+/)$ $1/index.html;
|
||||
|
||||
try_files $uri $uri/ /index.php;
|
||||
}
|
||||
|
||||
location = /robots.txt {
|
||||
allow all;
|
||||
log_not_found off;
|
||||
access_log off;
|
||||
}
|
||||
|
||||
location ~ ^/(?:\.htaccess|data|config|db_structure\.xml|README){
|
||||
deny all;
|
||||
}
|
||||
|
||||
location ~ \.php(?:$|/) {
|
||||
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
||||
include fastcgi_params;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
|
||||
fastcgi_read_timeout 300;
|
||||
}
|
||||
|
||||
# Optional: set long EXPIRES header on static assets
|
||||
location ~* \.(?:jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ {
|
||||
expires 30d;
|
||||
# Optional: Don't log access to assets
|
||||
access_log off;
|
||||
}
|
||||
|
||||
}
|
||||
|
37
owncloud/run.sh
Executable file
37
owncloud/run.sh
Executable file
@ -0,0 +1,37 @@
|
||||
#!/bin/bash
|
||||
|
||||
function first_run() {
|
||||
echo FIRST RUN
|
||||
|
||||
SQL_ROOT_PASSWORD="$(pwgen -s -1 16)"
|
||||
SQL_OWNCLOUD_PASSWORD="$(pwgen -s -1 16)"
|
||||
|
||||
mysqld_safe &
|
||||
|
||||
sleep 5
|
||||
|
||||
mysql -u root -e "
|
||||
CREATE USER 'owncloud'@'localhost' IDENTIFIED BY '$SQL_OWNCLOUD_PASSWORD';
|
||||
CREATE DATABASE owncloud;
|
||||
GRANT ALL PRIVILEGES ON owncloud . * TO owncloud@localhost;
|
||||
FLUSH PRIVILEGES;"
|
||||
mysqladmin -u root password $SQL_ROOT_PASSWORD
|
||||
|
||||
cd /var/www
|
||||
gosu www-data php occ maintenance:install \
|
||||
--database "mysql" --database-name "owncloud" \
|
||||
--database-user "owncloud" --database-pass "$SQL_OWNCLOUD_PASSWORD" \
|
||||
--admin-user "admin" --admin-pass "password"
|
||||
|
||||
killall mysqld
|
||||
|
||||
touch /data/.provisioned
|
||||
|
||||
sleep 10
|
||||
}
|
||||
|
||||
if [ ! -a /data/.provisioned ]
|
||||
then
|
||||
first_run
|
||||
fi
|
||||
supervisord -n -c /supervisord.conf
|
12
owncloud/supervisord.conf
Normal file
12
owncloud/supervisord.conf
Normal file
@ -0,0 +1,12 @@
|
||||
[supervisord]
|
||||
[program:mysqld]
|
||||
command=mysqld_safe
|
||||
#numproc=1
|
||||
#autostart=true
|
||||
#autorestart=true
|
||||
|
||||
[program:nginx]
|
||||
command=nginx -g "daemon off;"
|
||||
|
||||
[program:php-fcgi]
|
||||
command=php-fpm7.0 -F
|
Loading…
Reference in New Issue
Block a user