You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
134 lines
3.4 KiB
134 lines
3.4 KiB
###
|
|
### Meta Information
|
|
###
|
|
FROM localhost/debian
|
|
|
|
# deploy options
|
|
# -p (port) and -v (volume) both go host:container
|
|
LABEL config_default="\
|
|
--cap-add=sys_admin --security-opt apparmor=unconfined \
|
|
-p 9080:80 \
|
|
-v /srv/vol/nextcloud/files:/vol/files \
|
|
-v /srv/vol/nextcloud/data:/vol/data"
|
|
|
|
# Build Variables
|
|
# uid that the files owner user should have
|
|
ARG FILESUID=5000
|
|
# database name and user
|
|
ENV DBUSER=ncadmin
|
|
ENV DBNAME=nextcloud
|
|
|
|
###
|
|
### General Setup
|
|
###
|
|
|
|
# install packages we want
|
|
RUN apt update -y && apt install -y apache2 php-fpm php-gd php-zip php-pgsql \
|
|
php-curl php-mbstring php-intl php-imagick php-xml php-gmp php-json \
|
|
redis php-redis postgresql postgresql-doc php-ldap php-bcmath cron
|
|
|
|
|
|
# put database variables in /etc/environment so anyone can access them
|
|
# also autodetect versions of php and postgres and put them in /etc/environment as well
|
|
RUN echo "DBUSER=$DBUSER" >> /etc/environment && \
|
|
echo "DBNAME=$DBNAME" >> /etc/environment && \
|
|
echo "PSQLV=$(psql -V | cut -d ' ' -f 3 | cut -d '.' -f 1)" >> /etc/environment && \
|
|
echo "PHPV=$(echo $(php -r 'echo PHP_VERSION;') | cut -d '.' -f 1-2)" >> /etc/environment
|
|
|
|
# change www-data's UID to the file owner UID
|
|
RUN usermod --uid $FILESUID www-data && \
|
|
groupmod --gid $FILESUID www-data && \
|
|
chown -R www-data:www-data /var/www
|
|
|
|
# copy our custom scripts
|
|
COPY assets/bin/ /usr/local/bin/
|
|
|
|
# make sure volume dirs exist, and copy sample data
|
|
RUN mkdir -p /vol/data /vol/files
|
|
|
|
COPY --chown=www-data:www-data assets/data/ /vol/data/
|
|
|
|
###
|
|
### PHP
|
|
###
|
|
|
|
# enable PHP interpreter
|
|
RUN systemctl enable php${PHPV:?}-fpm
|
|
|
|
# copy php configuration
|
|
COPY assets/php/ php/
|
|
RUN mv php/php.ini /etc/php/${PHPV:?}/fpm/ && \
|
|
mv php/www.conf /etc/php/${PHPV:?}/fpm/pool.d/ && \
|
|
rmdir php
|
|
|
|
###
|
|
### PostgreSQL ###
|
|
###
|
|
|
|
# configure PostgreSQL access
|
|
COPY --chown=postgres:postgres assets/pg_hba.conf ./
|
|
RUN mv pg_hba.conf /etc/postgresql/${PSQLV:?}/main/
|
|
|
|
###
|
|
### Apache
|
|
###
|
|
|
|
# enable modules we need
|
|
RUN a2enmod rewrite headers env dir mime proxy_fcgi && \
|
|
a2enconf php${PHPV:?}-fpm
|
|
|
|
# copy site config
|
|
COPY assets/apache/nextcloud.conf /etc/apache2/sites-available/
|
|
WORKDIR /etc/apache2/sites-enabled
|
|
RUN rm 000-default.conf && ln -s ../sites-available/nextcloud.conf
|
|
|
|
###
|
|
### Redis
|
|
###
|
|
|
|
# copy redis config
|
|
COPY --chown=redis:redis assets/redis.conf /etc/redis/redis.conf
|
|
|
|
# add www-data to redis group so it can use the socket
|
|
RUN usermod -a -G redis www-data
|
|
|
|
###
|
|
### Nextcloud
|
|
###
|
|
|
|
# download nextcloud
|
|
WORKDIR /var/www/html
|
|
RUN wget https://download.nextcloud.com/server/releases/latest.zip && \
|
|
echo "Unzipping ..." && \
|
|
unzip -q latest.zip && \
|
|
chown -R www-data:www-data nextcloud && \
|
|
rm latest.zip
|
|
|
|
# create data dir for nextcloud
|
|
RUN mkdir -p /srv/nextcloud/data && \
|
|
chown -R www-data:www-data /srv/nextcloud
|
|
|
|
# copy nextcloud config
|
|
COPY --chown=www-data:www-data assets/config/ nextcloud/config/
|
|
# make link to host config
|
|
RUN ln -s /vol/data/host.config.php nextcloud/config/host.config.php
|
|
|
|
###
|
|
### Crontab
|
|
###
|
|
COPY assets/crontab /root/
|
|
# crontab for www-data
|
|
RUN crontab -u www-data /root/crontab
|
|
|
|
###
|
|
### Bugfix
|
|
###
|
|
|
|
# push the fixed systemd file for redis
|
|
COPY assets/bugfix/redis-server.service /etc/systemd/system/redis-server.service
|
|
|
|
COPY assets/bugfix/apache2.override /etc/systemd/system/apache2.service.d/override.conf
|
|
|
|
# bugfix for cron
|
|
COPY assets/bugfix/cronfix /root/
|
|
RUN chmod +x /root/cronfix && /root/cronfix
|
|
|