| @@ -147,8 +147,7 @@ Data and volumes | |||
| If you have existing data, create folders (otherwise setup script will do it) and copy it data: | |||
| sudo mkdir -p /media/volumes/mail/data | |||
| sudo mkdir -p /media/volumes/mail/state | |||
| sudo mkdir -p /media/volumes/mail/ | |||
| sudo mkdir -p /media/volumes/nextcloud | |||
| sudo chown -R pirate:pirate /media/volumes/* | |||
| @@ -162,7 +161,8 @@ From your current installation: | |||
| rsync -auv --delete -e "ssh -i ~/.ssh/your-key_rsa" /var/www/nextcloud/data your-main-host:/media/volumes/nextcloud/ | |||
| mysqldump --lock-tables -u nextcloud -p -h localhost nextcloud > /var/www/nextcloud/nextcloud_db_backup.sql | |||
| rsync -auv --delete -e "ssh -i ~/.ssh/your-key_rsa" /srv/vmail/ your-main-host:/media/volumes/mail/data | |||
| scp -i ~/.ssh/your-key_rsa /var/www/nextcloud/nextcloud_db_backup.sql your-main-host:/media/volumes/nextcloud/data/ | |||
| rsync -auv --delete -e "ssh -i ~/.ssh/your-key_rsa" /srv/vmail/ your-main-host:/media/volumes/mail | |||
| Configuration and deployment | |||
| @@ -7,6 +7,9 @@ if [ $# -eq 0 ]; then | |||
| exit 1 | |||
| fi | |||
| echo "" | |||
| echo "Adding DNS entries to PI-HOLE" | |||
| CONF_FILE=custom_dnsmasq.conf | |||
| IP_LOOKUP="$(ip route get 8.8.8.8 | awk '{ print $NF; exit }')" # May not work for VPN / tun0 | |||
| @@ -8,6 +8,8 @@ if [ $# -eq 0 ]; then | |||
| fi | |||
| # ##### Add users to LDAP ###### # | |||
| echo "" | |||
| echo "Adding users to LDAP" | |||
| host=$(docker stack ps ${STACK_NAME} | grep -v Shutdown | grep Running | grep openldap | awk '{ print $4 }') | |||
| #echo Host=$host | |||
| @@ -31,12 +33,12 @@ fi | |||
| # read variables, for mail data path | |||
| . .env | |||
| # Replace Mail data path for users | |||
| find images/rpi-openldap/users -type f -exec \ | |||
| find images/openldap/users -type f -exec \ | |||
| sed -i "s/\${MAIL_DATA_PATH}/${MAIL_DATA_PATH//\//\\/}/g" {} \; | |||
| echo Copying user files to Host $host | |||
| ssh $host "mkdir -p /tmp/users" | |||
| scp -r images/rpi-openldap/users/userimport*.ldif $host:/tmp/users/ | |||
| scp -r images/openldap/users/userimport*.ldif $host:/tmp/users/ | |||
| echo Copying user files to Container $container in Host $host | |||
| ssh $host "docker cp /tmp/users $container:/tmp/" | |||
| @@ -1,13 +1,19 @@ | |||
| #!/bin/bash | |||
| STACK_NAME=$1 | |||
| if [ $# -eq 0 ]; then | |||
| echo "You must pass stack name as a parameter" | |||
| exit 1 | |||
| fi | |||
| BUILD=$2 | |||
| if [ -z $BUILD ]; then | |||
| BUILD=1; | |||
| fi | |||
| if [ $# -eq 0 ]; then | |||
| echo "You must pass stack name as a parameter" | |||
| exit 1 | |||
| PUSH=$3 | |||
| if [ -z $PUSH ]; then | |||
| PUSH=0; | |||
| fi | |||
| # Delete previous running stack | |||
| @@ -16,12 +22,13 @@ docker stack rm ${STACK_NAME} | |||
| # Build images | |||
| if [ $BUILD -eq 1 ]; then | |||
| docker-compose build | |||
| docker push bingen/rpi-openldap | |||
| docker push bingen/rpi-mariadb | |||
| docker push bingen/rpi-haproxy | |||
| docker push bingen/rpi-mailserver | |||
| docker push bingen/rpi-nextcloud | |||
| docker push bingen/rpi-zoneminder | |||
| fi | |||
| # Push images | |||
| if [ $PUSH -eq 1 ]; then | |||
| source .env # for $ARCH | |||
| for i in `ls images`; do | |||
| docker push bingen/${ARCH}-${i} | |||
| done; | |||
| fi | |||
| # Deploy Stack | |||
| @@ -40,6 +47,7 @@ sleep 60 | |||
| ./add_dns_entries.sh ${STACK_NAME} | |||
| # Wait for Nextcloud | |||
| echo "Waiting for Nextcloud" | |||
| NC_UP=0 | |||
| while [ $NC_UP -eq 0 ]; do | |||
| # TODO: Use docker inspect Go templates | |||
| @@ -2,8 +2,8 @@ version: '3.1' | |||
| services: | |||
| openldap: | |||
| build: | |||
| context: ./images/rpi-openldap/ | |||
| image: bingen/rpi-openldap:latest | |||
| context: ./images/openldap/ | |||
| image: bingen/${ARCH}-openldap:latest | |||
| deploy: | |||
| placement: | |||
| constraints: | |||
| @@ -44,15 +44,15 @@ services: | |||
| db: | |||
| build: | |||
| context: ./images/rpi-mariadb/ | |||
| image: bingen/rpi-mariadb:latest | |||
| context: ./images/mariadb/ | |||
| image: bingen/${ARCH}-mariadb:latest | |||
| secrets: | |||
| - source: db_pwd | |||
| target: admin_pwd | |||
| mode: 0440 | |||
| environment: | |||
| - MYSQL_ROOT_PWD_FILE=/run/secrets/admin_pwd | |||
| #container_name: mariadb | |||
| env_file: | |||
| - mariadb.env | |||
| networks: | |||
| - default | |||
| #ports: | |||
| @@ -63,8 +63,8 @@ services: | |||
| haproxy: | |||
| build: | |||
| context: ./images/rpi-haproxy/ | |||
| image: bingen/rpi-haproxy:latest | |||
| context: ./images/haproxy/ | |||
| image: bingen/${ARCH}-haproxy:latest | |||
| depends_on: | |||
| # For DNS resolution | |||
| - nextcloud | |||
| @@ -81,8 +81,8 @@ services: | |||
| - ${LETSENCRYPT_VOLUME_PATH}:/etc/letsencrypt | |||
| mail: | |||
| build: | |||
| context: ./images/rpi-email/ | |||
| image: bingen/rpi-mailserver:latest | |||
| context: ./images/email/ | |||
| image: bingen/${ARCH}-mailserver:latest | |||
| depends_on: | |||
| - openldap | |||
| secrets: | |||
| @@ -109,16 +109,16 @@ services: | |||
| nextcloud: | |||
| build: | |||
| context: ./images/rpi-nextcloud/ | |||
| context: ./images/nextcloud/ | |||
| args: | |||
| - NEXTCLOUD_VERSION=${NEXTCLOUD_VERSION} | |||
| - NEXTCLOUD_DATA_PATH=${NEXTCLOUD_DATA_PATH} | |||
| - NEXTCLOUD_BACKUP_PATH=${NEXTCLOUD_BACKUP_PATH} | |||
| image: bingen/rpi-nextcloud:latest | |||
| deploy: | |||
| placement: | |||
| constraints: | |||
| - node.role == worker | |||
| image: bingen/${ARCH}-nextcloud:latest | |||
| # deploy: | |||
| # placement: | |||
| # constraints: | |||
| # - node.role == worker | |||
| depends_on: | |||
| - db | |||
| - openldap | |||
| @@ -156,8 +156,8 @@ services: | |||
| sftp: | |||
| build: | |||
| context: ./images/rpi-sftp/ | |||
| image: bingen/rpi-sftp | |||
| context: ./images/sftp/ | |||
| image: bingen/${ARCH}-sftp | |||
| ports: | |||
| - "1022:22" | |||
| volumes: | |||
| @@ -172,8 +172,8 @@ services: | |||
| gogs: | |||
| build: | |||
| context: ./images/rpi-gogs/ | |||
| image: bingen/rpi-gogs | |||
| context: ./images/gogs/ | |||
| image: bingen/${ARCH}-gogs | |||
| depends_on: | |||
| - db | |||
| - openldap | |||
| @@ -199,7 +199,7 @@ services: | |||
| mode: 0440 | |||
| pihole: | |||
| image: pihole/pihole:v4.0_armhf | |||
| image: pihole/pihole:latest | |||
| deploy: | |||
| placement: | |||
| constraints: | |||
| @@ -1,5 +1,7 @@ | |||
| # modify and copy to .env | |||
| ARCH=ARCH_PLACEHOLDER | |||
| # DB | |||
| DB_DATA_VOLUME_PATH=${VOLUMES_PATH}/mariadb/data | |||
| #DB_CONFIG_VOLUME_PATH=${VOLUMES_PATH}/mariadb/config | |||
| @@ -1,4 +1,4 @@ | |||
| FROM resin/raspberrypi3-debian:latest | |||
| FROM debian:stretch | |||
| ENV DEBIAN_FRONTEND=noninteractive | |||
| @@ -0,0 +1,26 @@ | |||
| FROM BASE_IMAGE_PLACEHOLDER | |||
| ENV DEBIAN_FRONTEND=noninteractive | |||
| # Packages | |||
| RUN DEBIAN_FRONTEND=noninteractive apt-get update -q --fix-missing && \ | |||
| apt-get -y upgrade && \ | |||
| apt-get -y install --no-install-recommends \ | |||
| rsyslog \ | |||
| postfix postfix-pcre postfix-ldap \ | |||
| cron getmail4 \ | |||
| mutt swaks \ | |||
| dovecot-core dovecot-imapd dovecot-pop3d dovecot-lmtpd dovecot-ldap \ | |||
| libsasl2-2 sasl2-bin libsasl2-modules-ldap | |||
| RUN addgroup --system --gid 5000 vmail && \ | |||
| adduser --system --home /srv/vmail --uid 5000 --gid 5000 --disabled-password --disabled-login vmail | |||
| RUN adduser postfix sasl | |||
| COPY config /tmp/config | |||
| COPY startup.sh /usr/local/bin/ | |||
| RUN chmod +x /usr/local/bin/startup.sh | |||
| CMD ["/usr/local/bin/startup.sh"] | |||
| @@ -1,15 +1,15 @@ | |||
| FROM resin/raspberrypi3-debian:latest | |||
| FROM debian:stretch | |||
| ENV GO_VERSION 1.9 | |||
| ENV GO_OS linux | |||
| ENV GO_ARCH armv6l | |||
| ENV GO_ARCH amd64 | |||
| ENV GOGS_CUSTOM /data/gogs | |||
| ENV GIT_HOME /home/git | |||
| # Install dependencies | |||
| RUN apt-get update \ | |||
| && apt-get install -y --no-install-recommends \ | |||
| git wget openssh-server mariadb-client \ | |||
| git wget ca-certificates openssh-server mariadb-client \ | |||
| && rm -rf /var/lib/apt/lists/* | |||
| RUN mkdir -p /data/gogs/data \ | |||
| @@ -0,0 +1,81 @@ | |||
| FROM BASE_IMAGE_PLACEHOLDER | |||
| ENV GO_VERSION 1.9 | |||
| ENV GO_OS linux | |||
| ENV GO_ARCH GO_ARCH_PLACEHOLDER | |||
| ENV GOGS_CUSTOM /data/gogs | |||
| ENV GIT_HOME /home/git | |||
| # Install dependencies | |||
| RUN apt-get update \ | |||
| && apt-get install -y --no-install-recommends \ | |||
| git wget ca-certificates openssh-server mariadb-client \ | |||
| && rm -rf /var/lib/apt/lists/* | |||
| RUN mkdir -p /data/gogs/data \ | |||
| && mkdir -p /data/gogs/conf \ | |||
| && mkdir -p /data/gogs/log \ | |||
| && mkdir -p /data/gogs/gogs-repositories \ | |||
| && mkdir -p /data/ssh | |||
| # Create git user for Gogs | |||
| RUN export PUID=${PUID:-1000} \ | |||
| && export PGID=${PGID:-1000} \ | |||
| && addgroup --gid ${PGID} git \ | |||
| && adduser --uid ${PUID} --ingroup git --disabled-login --gecos 'Gogs Git User' --home ${GIT_HOME} --shell /bin/bash git \ | |||
| && ln -s /data/ssh ${GIT_HOME}/.ssh | |||
| RUN chown -R git:git /data | |||
| RUN chown -R git:git ${GIT_HOME} | |||
| RUN echo "export GOGS_CUSTOM=${GOGS_CUSTOM}" > /etc/profile.d/gogs.sh | |||
| RUN echo "export GOROOT=${GIT_HOME}/local/go" | tee -a /etc/profile.d/gogs.sh /etc/bash.bashrc > /dev/null \ | |||
| && echo "export GOPATH=${GIT_HOME}/go" | tee -a /etc/profile.d/gogs.sh /etc/bash.bashrc > /dev/null \ | |||
| && echo 'export PATH=$PATH:$GOROOT/bin:$GOPATH/bin' | tee -a /etc/profile.d/gogs.sh /etc/bash.bashrc > /dev/null | |||
| # ############## USER git ######################## | |||
| USER git | |||
| # Install Golang | |||
| RUN cd $HOME \ | |||
| && mkdir local \ | |||
| && cd local \ | |||
| && wget https://storage.googleapis.com/golang/go${GO_VERSION}.${GO_OS}-${GO_ARCH}.tar.gz \ | |||
| && tar zxvf go${GO_VERSION}.${GO_OS}-${GO_ARCH}.tar.gz \ | |||
| && rm go${GO_VERSION}.${GO_OS}-${GO_ARCH}.tar.gz | |||
| # Install Gogs | |||
| RUN . /etc/profile.d/gogs.sh \ | |||
| && ${GOROOT}/bin/go get -u -tags "cert" github.com/gogs/gogs \ | |||
| && cd $GOPATH/src/github.com/gogs/gogs \ | |||
| && go build -tags "cert" | |||
| # TODO: | |||
| # clean stuff | |||
| # https://github.com/gogs/gogs/blob/master/docker/finalize.sh | |||
| # Clean stuff | |||
| RUN rm -r $HOME/go/src/github.com/gogs/gogs/.git | |||
| #RUN rm -r $HOME/local | |||
| # Configuration | |||
| # $HOME doesn't work with COPY | |||
| RUN mkdir -p ${GIT_HOME}/go/src/github.com/gogs/gogs/custom/conf | |||
| COPY app.ini ${GIT_HOME}/go/src/github.com/gogs/gogs/custom/conf/ | |||
| # LDAP | |||
| RUN mkdir -p ${GIT_HOME}/go/src/github.com/gogs/gogs/custom/conf/auth.d | |||
| COPY ldap.conf ${GIT_HOME}/go/src/github.com/gogs/gogs/custom/conf/auth.d/ | |||
| # ############## USER root ######################## | |||
| USER root | |||
| COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh | |||
| RUN chmod 755 /usr/local/bin/docker-entrypoint.sh | |||
| #ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] | |||
| #CMD gosu git ${GOPATH}/src/github.com/gogs/gogs/gogs web | |||
| ENTRYPOINT [] | |||
| CMD ["/usr/local/bin/docker-entrypoint.sh"] | |||
| @@ -36,6 +36,8 @@ GOGS_DB_USER, GOGS_DB_PWD, GOGS_ADMIN_PWD, ADMIN_EMAIL and LDAP stuff"; | |||
| exit 1; | |||
| fi | |||
| GOGS_PATH=${GOPATH}/src/github.com/gogs/gogs | |||
| function check_result { | |||
| if [ $1 != 0 ]; then | |||
| echo "Error: $2"; | |||
| @@ -46,6 +48,7 @@ function check_result { | |||
| # ### DB setup ### | |||
| # wait for DB to be ready | |||
| sleep 60 # to avoid hitting it while the first start for setting root pwd | |||
| R=111 | |||
| while [ $R -eq 111 ]; do | |||
| mysql -u root -p${MYSQL_ROOT_PWD} -h ${DB_HOST} -e "SHOW DATABASES" 2> /dev/null; | |||
| @@ -87,7 +90,7 @@ service ssh start | |||
| # SSH certs | |||
| if [[ ! -e ${GOGS_CUSTOM}/https/cert.pem || ! -e ${GOGS_CUSTOM}/https/key.pem ]]; then | |||
| su git -c "mkdir -p ${GOGS_CUSTOM}/https" | |||
| su git -c "cd ${GOGS_CUSTOM}/https && ${GOPATH}/src/github.com/gogits/gogs/gogs cert --ca=true --duration=8760h0m0s --host=${GOGS_DOMAIN} && cd -" | |||
| su git -c "cd ${GOGS_CUSTOM}/https && ${GOGS_PATH}/gogs cert --ca=true --duration=8760h0m0s --host=${GOGS_DOMAIN} && cd -" | |||
| fi | |||
| # ### Conf file ### | |||
| @@ -97,7 +100,7 @@ CONF_FILE=${GOGS_CUSTOM}/conf/app.ini | |||
| # We need to re-generate conf file because we are changing DB pwd | |||
| #if [[ ! -e ${CONF_FILE} ]]; then | |||
| su git -c "mkdir -p ${GOGS_CUSTOM}/conf" | |||
| mv ${GOPATH}/src/github.com/gogits/gogs/custom/conf/app.ini ${CONF_FILE} | |||
| mv ${GOGS_PATH}/custom/conf/app.ini ${CONF_FILE} | |||
| echo Setting domain | |||
| sed -i "s/GOGS_DOMAIN/${GOGS_DOMAIN}/g" ${CONF_FILE} | |||
| @@ -114,7 +117,7 @@ sed -i "s/GOGS_DB_PWD/${GOGS_DB_PWD//\//\\/}/g" ${CONF_FILE} | |||
| LDAP_FILE=${GOGS_CUSTOM}/conf/auth.d/ldap.conf | |||
| #if [[ ! -e ${CONF_FILE} ]]; then | |||
| su git -c "mkdir -p ${GOGS_CUSTOM}/conf/auth.d" | |||
| mv ${GOPATH}/src/github.com/gogits/gogs/custom/conf/auth.d/ldap.conf ${LDAP_FILE} | |||
| mv ${GOGS_PATH}/custom/conf/auth.d/ldap.conf ${LDAP_FILE} | |||
| echo Setting LDAP conf | |||
| sed -i "s/LDAP_SERVER_HOST/${LDAP_SERVER_HOST}/g" ${LDAP_FILE} | |||
| @@ -125,9 +128,9 @@ sed -i "s/LDAP_SEARCH_BASE/${LDAP_SEARCH_BASE}/g" ${LDAP_FILE} | |||
| # Create admin user if DB was new | |||
| if [ -z "${DB_EXISTS}" ]; then | |||
| su -c git "${GOPATH}/src/github.com/gogits/gogs/gogs admin create-user --name admin --password ${GOGS_ADMIN_PWD} --admin --email ${ADMIN_EMAIL}" | |||
| su -c git "${GOGS_PATH}/gogs admin create-user --name admin --password ${GOGS_ADMIN_PWD} --admin --email ${ADMIN_EMAIL}" | |||
| fi | |||
| #exec "$@" | |||
| #exec gosu git ${GOPATH}/src/github.com/gogits/gogs/gogs web | |||
| exec su git -c "${GOPATH}/src/github.com/gogits/gogs/gogs web" | |||
| #exec gosu git ${GOGS_PATH}/gogs web | |||
| exec su git -c "${GOGS_PATH}/gogs web" | |||
| @@ -1,8 +1,8 @@ | |||
| FROM resin/raspberrypi3-debian:latest | |||
| FROM debian:stretch | |||
| RUN echo deb http://deb.debian.org/debian jessie-backports main >> /etc/apt/sources.list | |||
| RUN apt-get update && apt-get install -y haproxy cron \ | |||
| && apt-get install certbot -t jessie-backports | |||
| && apt-get install -y certbot -t jessie-backports | |||
| RUN mkdir -p /run/haproxy | |||
| @@ -0,0 +1,19 @@ | |||
| FROM BASE_IMAGE_PLACEHOLDER | |||
| RUN echo deb http://deb.debian.org/debian jessie-backports main >> /etc/apt/sources.list | |||
| RUN apt-get update && apt-get install -y haproxy cron \ | |||
| && apt-get install -y certbot -t jessie-backports | |||
| RUN mkdir -p /run/haproxy | |||
| COPY haproxy.cfg /etc/haproxy/haproxy.cfg | |||
| COPY haproxy_letsencrypt.cfg /etc/haproxy/haproxy_letsencrypt.cfg | |||
| COPY startup.sh /usr/local/bin/ | |||
| RUN chmod +x /usr/local/bin/startup.sh | |||
| COPY letsencrypt.cron /usr/local/bin/ | |||
| RUN chmod +x /usr/local/bin/letsencrypt.cron | |||
| #CMD haproxy -f /etc/haproxy/haproxy.cfg | |||
| CMD /usr/local/bin/startup.sh | |||
| @@ -0,0 +1,42 @@ | |||
| # | |||
| # MariaDB Dockerfile | |||
| # Pull base image. | |||
| FROM debian:stretch | |||
| ENV DEBIAN_FRONTEND=noninteractive | |||
| # Install MariaDB. | |||
| RUN \ | |||
| apt-get update && \ | |||
| apt-get upgrade -y && \ | |||
| apt-get -y install mariadb-server procps | |||
| RUN find /etc/mysql/ -name *.cnf -exec sed -i 's/^\(bind-address\s.*\)/# \1/' {} \; | |||
| #RUN \ | |||
| # find /etc/mysql/ -name *.cnf -exec sed -i 's/^\(bind-address\s.*\)/# \1/' {} \; && \ | |||
| # echo "mysqld_safe &" > /tmp/config && \ | |||
| # echo "mysqladmin --silent --wait=30 ping || exit 1" >> /tmp/config && \ | |||
| # echo "mysql -e 'GRANT ALL PRIVILEGES ON *.* TO \"root\"@\"%\" WITH GRANT OPTION;'" >> /tmp/config && \ | |||
| # bash /tmp/config && \ | |||
| # mysql -e "SELECT Host, User, Password FROM mysql.user;" > /tmp/a.out | |||
| #rm -f /tmp/config | |||
| COPY tuning.cnf /etc/mysql/conf.d/tuning.cnf | |||
| COPY tuning-primer.sh /usr/local/bin/ | |||
| RUN chmod +x /usr/local/bin/tuning-primer.sh | |||
| COPY mysqltuner.pl /usr/local/bin/ | |||
| RUN chmod +x /usr/local/bin/mysqltuner.pl | |||
| COPY startup.sh /usr/local/bin/ | |||
| RUN chmod +x /usr/local/bin/startup.sh | |||
| # Define mountable directories. | |||
| #VOLUME ["/var/lib/mysql"] | |||
| # Define default command. | |||
| CMD ["/usr/local/bin/startup.sh"] | |||
| # Expose ports. | |||
| EXPOSE 3306 | |||
| @@ -1,27 +1,21 @@ | |||
| # | |||
| # MariaDB Dockerfile | |||
| # | |||
| # https://github.com/bingen/rpi-mariadb | |||
| # | |||
| # Pull base image. | |||
| FROM resin/raspberrypi3-debian:latest | |||
| FROM BASE_IMAGE_PLACEHOLDER | |||
| ENV DEBIAN_FRONTEND=noninteractive | |||
| # Install MariaDB. | |||
| RUN \ | |||
| apt-get update && \ | |||
| apt-get upgrade && \ | |||
| apt-get -y install mariadb-server | |||
| RUN \ | |||
| sed -i 's/^\(bind-address\s.*\)/# \1/' /etc/mysql/my.cnf && \ | |||
| echo "mysqld_safe &" > /tmp/config && \ | |||
| echo "mysqladmin --silent --wait=30 ping || exit 1" >> /tmp/config && \ | |||
| echo "mysql -e 'GRANT ALL PRIVILEGES ON *.* TO \"root\"@\"%\" WITH GRANT OPTION;'" >> /tmp/config && \ | |||
| bash /tmp/config && \ | |||
| mysql -e "SELECT Host, User, Password FROM mysql.user;" > /tmp/a.out | |||
| #rm -f /tmp/config | |||
| apt-get upgrade -y && \ | |||
| apt-get -y install mariadb-server procps | |||
| RUN find /etc/mysql/ -name *.cnf -exec sed -i 's/^\(bind-address\s.*\)/# \1/' {} \; | |||
| # Install Mysql DB | |||
| RUN mysql_install_db --user=mysql --ldata=/var/lib/mysql | |||
| COPY tuning.cnf /etc/mysql/conf.d/tuning.cnf | |||
| @@ -1,7 +1,7 @@ | |||
| #!bin/bash | |||
| #!/bin/bash | |||
| echo "Installing Mysql DB" | |||
| mysql_install_db --user=mysql --ldata=/var/lib/mysql | |||
| echo "Permissions" | |||
| chown -R mysql:mysql /var/lib/mysql | |||
| # set root password from secret | |||
| if [ ! -z $MYSQL_ROOT_PWD_FILE -a -f $MYSQL_ROOT_PWD_FILE ]; then | |||
| @@ -1,4 +1,4 @@ | |||
| FROM bingen/rpi-nginx-php | |||
| FROM bingen/amd64-nginx-php | |||
| ENV DEBIAN_FRONTEND=noninteractive | |||
| @@ -7,7 +7,7 @@ ARG NEXTCLOUD_DATA_PATH | |||
| ARG NEXTCLOUD_BACKUP_PATH | |||
| RUN apt-get update && \ | |||
| apt-get install -y wget bzip2 vim rsync mariadb-client cron && \ | |||
| apt-get install -y wget bzip2 vim rsync mariadb-client cron sudo && \ | |||
| apt-get clean | |||
| # Change upload-limits and -sizes | |||
| @@ -0,0 +1,58 @@ | |||
| FROM bingen/ARCH_PLACEHOLDER-nginx-php | |||
| ENV DEBIAN_FRONTEND=noninteractive | |||
| ARG NEXTCLOUD_VERSION | |||
| ARG NEXTCLOUD_DATA_PATH | |||
| ARG NEXTCLOUD_BACKUP_PATH | |||
| RUN apt-get update && \ | |||
| apt-get install -y wget bzip2 vim rsync mariadb-client cron sudo && \ | |||
| apt-get clean | |||
| # Change upload-limits and -sizes | |||
| RUN sed -i "s/upload_max_filesize = 2M/upload_max_filesize = 2048M/g" /etc/php/7.2/fpm/php.ini && \ | |||
| sed -i "s/post_max_size = 8M/post_max_size =root123 2048M/g" /etc/php/7.2/fpm/php.ini && \ | |||
| echo 'default_charset = "UTF-8"' >> /etc/php/7.2/fpm/php.ini && \ | |||
| echo "upload_tmp_dir = ${NEXTCLOUD_DATA_PATH}" >> /etc/php/7.2/fpm/php.ini && \ | |||
| echo "extension = apc.so" >> /etc/php/7.2/fpm/php.ini && \ | |||
| echo "apc.enabled = 1" >> /etc/php/7.2/fpm/php.ini && \ | |||
| echo "apc.include_once_override = 0" >> /etc/php/7.2/fpm/php.ini && \ | |||
| echo "apc.shm_size = 256" >> /etc/php/7.2/fpm/php.ini | |||
| # now add our hand-written nginx-default-configuration which makes use of all the stuff so far prepared | |||
| COPY default /etc/nginx/sites-available/default | |||
| # PHP config | |||
| COPY php_nc.ini /tmp/php_nc.ini | |||
| RUN cat /tmp/php_nc.ini >> /etc/php/7.2/fpm/php.ini && \ | |||
| cat /tmp/php_nc.ini >> /etc/php/7.2/cli/php.ini | |||
| # https://docs.nextcloud.com/server/13/admin_manual/installation/source_installation.html#php-fpm-tips-label | |||
| RUN sed -i 's/^;env/env/g' /etc/php/7.2/fpm/pool.d/www.conf | |||
| # Create the data-directory where NEXTCLOUD can store its stuff | |||
| RUN mkdir -p "${NEXTCLOUD_DATA_PATH}" && \ | |||
| chown -R www-data:www-data "${NEXTCLOUD_DATA_PATH}" && \ | |||
| mkdir -p "${NEXTCLOUD_BACKUP_PATH}" | |||
| # finally, download NEXTCLOUD and extract it | |||
| RUN mkdir -p /var/www | |||
| WORKDIR /var/www | |||
| RUN wget https://download.nextcloud.com/server/releases/${NEXTCLOUD_VERSION}.tar.bz2 && \ | |||
| tar xvf ${NEXTCLOUD_VERSION}.tar.bz2 && \ | |||
| chown -R www-data:www-data nextcloud && \ | |||
| rm ${NEXTCLOUD_VERSION}.tar.bz2 | |||
| WORKDIR / | |||
| COPY docker-entrypoint.sh /usr/local/bin/entrypoint.sh | |||
| RUN chmod +x /usr/local/bin/entrypoint.sh | |||
| COPY backup.sh /etc/cron.daily/backup | |||
| RUN chmod +x /etc/cron.daily/backup | |||
| #VOLUME ${NEXTCLOUD_DATA_PATH} | |||
| #VOLUME ${NEXTCLOUD_BACKUP_PATH} | |||
| ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] | |||
| CMD service php7.2-fpm start && nginx | |||
| #CMD ["service", "php7.2-fpm", "start", "&&", "nginx"] | |||
| @@ -10,7 +10,7 @@ if [ -z "${NEXTCLOUD_SERVER_NAME}" ]; then | |||
| exit 1 | |||
| fi | |||
| sudo sed -i "s/server_name localhost/server_name ${NEXTCLOUD_SERVER_NAME}.${NEXTCLOUD_DOMAIN} ${NEXTCLOUD_SERVER_NAME}/g" /etc/nginx/sites-available/default | |||
| sed -i "s/server_name localhost/server_name ${NEXTCLOUD_SERVER_NAME}.${NEXTCLOUD_DOMAIN} ${NEXTCLOUD_SERVER_NAME}/g" /etc/nginx/sites-available/default | |||
| # set Admin password from secret | |||
| if [ ! -z $NEXTCLOUD_ADMIN_PWD_FILE -a -f $NEXTCLOUD_ADMIN_PWD_FILE ]; then | |||
| @@ -67,6 +67,7 @@ function check_result { | |||
| # ### DB ### | |||
| # wait for DB to be ready | |||
| sleep 60 # to avoid hitting it while the first start for setting root pwd | |||
| R=111 | |||
| while [ $R -eq 111 ]; do | |||
| mysql -u root -p${MYSQL_ROOT_PWD} -h ${DB_HOST} -e "SHOW DATABASES" 2> /dev/null; | |||
| @@ -1,4 +1,4 @@ | |||
| FROM bingen/rpi-nginx | |||
| FROM bingen/amd64-nginx | |||
| # Add PHP 7.2 repo | |||
| RUN apt-get update && \ | |||
| @@ -0,0 +1,18 @@ | |||
| FROM bingen/ARCH_PLACEHOLDER-nginx | |||
| # Add PHP 7.2 repo | |||
| RUN apt-get update && \ | |||
| apt-get install -y apt-transport-https lsb-release ca-certificates wget && \ | |||
| wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg && \ | |||
| sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list' | |||
| # update and install php | |||
| RUN apt-get update && \ | |||
| apt-get install -y php7.2 php7.2-fpm php-pear php7.2-common \ | |||
| php7.2-mysql php7.2-cli php7.2-gd php7.2-curl php-apcu php7.2-opcache \ | |||
| php7.2-mbstring php7.2-ldap php7.2-zip && \ | |||
| apt-get clean | |||
| # overwrite the default-configuration with our own settings - enabling PHP | |||
| COPY default /etc/nginx/sites-available/default | |||
| CMD service php7.2-fpm start && nginx | |||
| @@ -1,4 +1,4 @@ | |||
| FROM resin/raspberrypi3-debian:stretch | |||
| FROM debian:stretch | |||
| #ENV NGINX_VERSION 1.2.1-2.2+wheezy3 | |||
| @@ -0,0 +1,25 @@ | |||
| FROM BASE_IMAGE_PLACEHOLDER | |||
| #ENV NGINX_VERSION 1.2.1-2.2+wheezy3 | |||
| # update and install nginx | |||
| RUN apt-get update && \ | |||
| apt-get install -y nginx && \ | |||
| #=${NGINX_VERSION} | |||
| apt-get clean | |||
| # trim the original configuration for our little raspberry | |||
| RUN sed -i "s/worker_processes 4;/worker_processes 2;/g" /etc/nginx/nginx.conf | |||
| RUN sed -i "s/worker_connections 768;/worker_connections 256;/g" /etc/nginx/nginx.conf | |||
| RUN echo "daemon off;" >> /etc/nginx/nginx.conf | |||
| # like in the official nginx-image - forward request and error logs to docker log collector | |||
| RUN ln -sf /dev/stdout /var/log/nginx/access.log | |||
| RUN ln -sf /dev/stderr /var/log/nginx/error.log | |||
| VOLUME ["/var/cache/nginx"] | |||
| # Ports to be exposed | |||
| EXPOSE 80 443 | |||
| CMD ["nginx"] | |||
| @@ -1,14 +1,15 @@ | |||
| FROM resin/raspberrypi3-debian:latest | |||
| FROM debian:stretch | |||
| # Add openldap user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added | |||
| RUN groupadd -r openldap && useradd -r -g openldap -u 999 openldap | |||
| # Install OpenLDAP, ldap-utils and ssl-tools from baseimage and clean apt-get files | |||
| RUN apt-get -y update \ | |||
| && LC_ALL=C DEBIAN_FRONTEND=noninteractive apt-get install -y --force-yes --no-install-recommends \ | |||
| && LC_ALL=C DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ | |||
| ldap-utils \ | |||
| openssl \ | |||
| slapd \ | |||
| procps \ | |||
| # ca-certificates \ | |||
| # curl \ | |||
| # patch \ | |||
| @@ -0,0 +1,41 @@ | |||
| FROM BASE_IMAGE_PLACEHOLDER | |||
| # Add openldap user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added | |||
| RUN groupadd -r openldap && useradd -r -g openldap -u 999 openldap | |||
| # Install OpenLDAP, ldap-utils and ssl-tools from baseimage and clean apt-get files | |||
| RUN apt-get -y update \ | |||
| && LC_ALL=C DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ | |||
| ldap-utils \ | |||
| openssl \ | |||
| slapd \ | |||
| procps \ | |||
| # ca-certificates \ | |||
| # curl \ | |||
| # patch \ | |||
| # php5-ldap \ | |||
| # php5-readline \ | |||
| # && curl -o phpldapadmin.tgz -SL https://downloads.sourceforge.net/project/phpldapadmin/phpldapadmin-php5/${PHPLDAPADMIN_VERSION}/phpldapadmin-${PHPLDAPADMIN_VERSION}.tgz \ | |||
| # && echo "$PHPLDAPADMIN_SHA1 *phpldapadmin.tgz" | sha1sum -c - \ | |||
| # && mkdir -p /var/www/phpldapadmin_bootstrap /var/www/phpldapadmin \ | |||
| # && tar -xzf phpldapadmin.tgz --strip 1 -C /var/www/phpldapadmin_bootstrap \ | |||
| # && apt-get remove -y --purge --auto-remove curl ca-certificates \ | |||
| # && rm phpldapadmin.tgz \ | |||
| && apt-get clean \ | |||
| && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | |||
| COPY data /tmp/data/ | |||
| COPY startup.sh /usr/local/bin/ | |||
| RUN chmod +x /usr/local/bin/startup.sh | |||
| # Set phpLDAPadmin data directory in a data volume | |||
| # VOLUME ["/var/www/phpldapadmin"] | |||
| VOLUME ["/etc/ldap"] | |||
| #CMD ["/usr/sbin/slapd", "-g", "openldap", "-u", "openldap", "-F", "/etc/ldap/slapd.d", "-d0"] | |||
| #CMD ["/usr/sbin/slapd", "-h", "ldap:/// ldapi:///", "-g", "openldap", "-u", "openldap", "-F", "/etc/ldap/slapd.d", "-d7"] | |||
| #CMD ["/bin/bash"] | |||
| CMD ["/usr/local/bin/startup.sh"] | |||
| EXPOSE 389 636 | |||
| #80 443 | |||
| @@ -1,4 +1,4 @@ | |||
| FROM resin/raspberrypi3-debian:latest | |||
| FROM debian:stretch | |||
| # Install dependencies | |||
| RUN apt-get update \ | |||
| @@ -0,0 +1,13 @@ | |||
| FROM BASE_IMAGE_PLACEHOLDER | |||
| # Install dependencies | |||
| RUN apt-get update \ | |||
| && apt-get install -y --no-install-recommends \ | |||
| openssh-server \ | |||
| && rm -rf /var/lib/apt/lists/* | |||
| COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh | |||
| RUN chmod 755 /usr/local/bin/docker-entrypoint.sh | |||
| ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] | |||
| CMD ["/usr/sbin/sshd", "-D"] | |||
| @@ -8,6 +8,8 @@ if [ $# -eq 0 ]; then | |||
| fi | |||
| # ##### Add Let's Encrypt certificates ###### # | |||
| echo "" | |||
| echo "Adding Let's Encrypt certificates" | |||
| # Find Nextcloud container | |||
| SERVICE=nextcloud | |||
| @@ -0,0 +1 @@ | |||
| MYSQL_ROOT_PWD_FILE=/run/secrets/admin_pwd | |||
| @@ -0,0 +1,35 @@ | |||
| #!/bin/bash | |||
| ARCH=$1 | |||
| if [ $# -eq 0 ]; then | |||
| echo "You must pass arch as a parameter" | |||
| exit 1 | |||
| fi | |||
| case ${ARCH} in | |||
| #'rpi') IMAGE='resin/raspberrypi3-debian:latest' ;; | |||
| 'rpi') | |||
| IMAGE='arm32v7/debian:stretch' | |||
| ARCH_PREFIX='rpi' | |||
| GO_ARCH='armv6l' | |||
| ;; | |||
| 'arm64') | |||
| IMAGE='arm64v7/debian:stretch' | |||
| ARCH_PREFIX='arm64' | |||
| GO_ARCH='arm64' | |||
| ;; | |||
| 'amd64') | |||
| IMAGE='debian:stretch' | |||
| ARCH_PREFIX='amd64' | |||
| GO_ARCH='amd64' | |||
| ;; | |||
| esac | |||
| for i in `find ./ -name Dockerfile.template`; do | |||
| dockerfile=${i/\.template/} | |||
| cp ${i} ${dockerfile} | |||
| sed -i "s/FROM BASE_IMAGE_PLACEHOLDER/FROM ${IMAGE}/g" ${dockerfile} | |||
| sed -i "s/GO_ARCH GO_ARCH_PLACEHOLDER/GO_ARCH ${GO_ARCH}/g" ${dockerfile} | |||
| sed -i "s/bingen\/ARCH_PLACEHOLDER/bingen\/${ARCH_PREFIX}/g" ${dockerfile} | |||
| done; | |||
| sed -i "s/ARCH_PLACEHOLDER/${ARCH_PREFIX}/g" .env | |||
| @@ -232,4 +232,4 @@ sudo mkdir -p ${PIHOLE_DNSMASQ_VOLUME_PATH} | |||
| sudo mkdir -p ${LETSENCRYPT_VOLUME_PATH} | |||
| echo "Copying getmail confs" | |||
| cp images/rpi-email/getmail/getmailrc-* ${MAIL_DATA_VOLUME_PATH}/getmail/ | |||
| cp images/email/getmail/getmailrc-* ${MAIL_DATA_VOLUME_PATH}/getmail/ | |||