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.
143 lines
3.6 KiB
143 lines
3.6 KiB
###
|
|
### Meta Information
|
|
###
|
|
FROM localhost/debian
|
|
|
|
# deploy options
|
|
# -p (port) and -v (volume) both go host:container
|
|
LABEL config_default="\
|
|
-p 9080:80 \
|
|
-v /srv/vol/nextcloud/files:/vol/files \
|
|
-v /srv/vol/nextcloud/data:/vol/data
|
|
--shm-size=1g"
|
|
|
|
# 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 jq
|
|
|
|
|
|
# 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 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
|
|
COPY --chown=postgres:postgres assets/postgresql ./
|
|
# If the posgresql.conf file contains multiple entries for the same parameter, all but the last one is ignored.
|
|
# So we can just append our settings to the already-existing postgresql.conf file.
|
|
RUN mv postgresql/pg_hba.conf /etc/postgresql/${PSQLV:?}/main/ & \
|
|
cat postgresql/postgresql.conf >> /etc/postgresql/${PSQLV:?}/main/postgresql.conf
|
|
|
|
###
|
|
### Apache
|
|
###
|
|
|
|
# enable modules we need
|
|
RUN a2enmod rewrite headers env dir mime proxy_fcgi http2 && \
|
|
a2enconf php${PHPV:?}-fpm
|
|
|
|
# copy site config
|
|
COPY assets/apache/nextcloud.conf /etc/apache2/sites-available/
|
|
RUN a2dissite 000-default && a2ensite nextcloud
|
|
|
|
###
|
|
### 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 --progress=dot:giga 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 /vol/files && \
|
|
chown -R www-data:www-data /vol/files
|
|
|
|
# copy nextcloud config
|
|
COPY --chown=www-data:www-data assets/config/ nextcloud/config/
|
|
# make link to host config & secret config
|
|
RUN cd nextcloud/config && \
|
|
ln -s /vol/data/host.config.php && \
|
|
ln -s /vol/data/secret.config.php
|
|
|
|
###
|
|
### Systemd
|
|
###
|
|
|
|
# copy services
|
|
COPY assets/systemd/ /etc/systemd/system/
|
|
|
|
# enable service
|
|
RUN systemctl enable db-updown.service
|
|
|
|
###
|
|
### 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
|
|
|
|
###
|
|
### Workdir
|
|
###
|
|
|
|
WORKDIR /vol/data
|
|
|