| If you have existing data, create folders (otherwise setup script will do it) and copy it data: | 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 mkdir -p /media/volumes/nextcloud | ||||
| sudo chown -R pirate:pirate /media/volumes/* | sudo chown -R pirate:pirate /media/volumes/* | ||||
| rsync -auv --delete -e "ssh -i ~/.ssh/your-key_rsa" /var/www/nextcloud/data your-main-host:/media/volumes/nextcloud/ | 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 | 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 | Configuration and deployment |
| exit 1 | exit 1 | ||||
| fi | fi | ||||
| echo "" | |||||
| echo "Adding DNS entries to PI-HOLE" | |||||
| CONF_FILE=custom_dnsmasq.conf | CONF_FILE=custom_dnsmasq.conf | ||||
| IP_LOOKUP="$(ip route get 8.8.8.8 | awk '{ print $NF; exit }')" # May not work for VPN / tun0 | IP_LOOKUP="$(ip route get 8.8.8.8 | awk '{ print $NF; exit }')" # May not work for VPN / tun0 |
| fi | fi | ||||
| # ##### Add users to LDAP ###### # | # ##### 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 }') | host=$(docker stack ps ${STACK_NAME} | grep -v Shutdown | grep Running | grep openldap | awk '{ print $4 }') | ||||
| #echo Host=$host | #echo Host=$host | ||||
| # read variables, for mail data path | # read variables, for mail data path | ||||
| . .env | . .env | ||||
| # Replace Mail data path for users | # 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" {} \; | sed -i "s/\${MAIL_DATA_PATH}/${MAIL_DATA_PATH//\//\\/}/g" {} \; | ||||
| echo Copying user files to Host $host | echo Copying user files to Host $host | ||||
| ssh $host "mkdir -p /tmp/users" | 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 | echo Copying user files to Container $container in Host $host | ||||
| ssh $host "docker cp /tmp/users $container:/tmp/" | ssh $host "docker cp /tmp/users $container:/tmp/" |
| #!/bin/bash | #!/bin/bash | ||||
| STACK_NAME=$1 | STACK_NAME=$1 | ||||
| if [ $# -eq 0 ]; then | |||||
| echo "You must pass stack name as a parameter" | |||||
| exit 1 | |||||
| fi | |||||
| BUILD=$2 | BUILD=$2 | ||||
| if [ -z $BUILD ]; then | if [ -z $BUILD ]; then | ||||
| BUILD=1; | BUILD=1; | ||||
| fi | 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 | fi | ||||
| # Delete previous running stack | # Delete previous running stack | ||||
| # Build images | # Build images | ||||
| if [ $BUILD -eq 1 ]; then | if [ $BUILD -eq 1 ]; then | ||||
| docker-compose build | 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 | fi | ||||
| # Deploy Stack | # Deploy Stack | ||||
| ./add_dns_entries.sh ${STACK_NAME} | ./add_dns_entries.sh ${STACK_NAME} | ||||
| # Wait for Nextcloud | # Wait for Nextcloud | ||||
| echo "Waiting for Nextcloud" | |||||
| NC_UP=0 | NC_UP=0 | ||||
| while [ $NC_UP -eq 0 ]; do | while [ $NC_UP -eq 0 ]; do | ||||
| # TODO: Use docker inspect Go templates | # TODO: Use docker inspect Go templates |
| services: | services: | ||||
| openldap: | openldap: | ||||
| build: | build: | ||||
| context: ./images/rpi-openldap/ | |||||
| image: bingen/rpi-openldap:latest | |||||
| context: ./images/openldap/ | |||||
| image: bingen/${ARCH}-openldap:latest | |||||
| deploy: | deploy: | ||||
| placement: | placement: | ||||
| constraints: | constraints: | ||||
| db: | db: | ||||
| build: | build: | ||||
| context: ./images/rpi-mariadb/ | |||||
| image: bingen/rpi-mariadb:latest | |||||
| context: ./images/mariadb/ | |||||
| image: bingen/${ARCH}-mariadb:latest | |||||
| secrets: | secrets: | ||||
| - source: db_pwd | - source: db_pwd | ||||
| target: admin_pwd | target: admin_pwd | ||||
| mode: 0440 | mode: 0440 | ||||
| environment: | |||||
| - MYSQL_ROOT_PWD_FILE=/run/secrets/admin_pwd | |||||
| #container_name: mariadb | #container_name: mariadb | ||||
| env_file: | |||||
| - mariadb.env | |||||
| networks: | networks: | ||||
| - default | - default | ||||
| #ports: | #ports: | ||||
| haproxy: | haproxy: | ||||
| build: | build: | ||||
| context: ./images/rpi-haproxy/ | |||||
| image: bingen/rpi-haproxy:latest | |||||
| context: ./images/haproxy/ | |||||
| image: bingen/${ARCH}-haproxy:latest | |||||
| depends_on: | depends_on: | ||||
| # For DNS resolution | # For DNS resolution | ||||
| - nextcloud | - nextcloud | ||||
| - ${LETSENCRYPT_VOLUME_PATH}:/etc/letsencrypt | - ${LETSENCRYPT_VOLUME_PATH}:/etc/letsencrypt | ||||
| mail: | mail: | ||||
| build: | build: | ||||
| context: ./images/rpi-email/ | |||||
| image: bingen/rpi-mailserver:latest | |||||
| context: ./images/email/ | |||||
| image: bingen/${ARCH}-mailserver:latest | |||||
| depends_on: | depends_on: | ||||
| - openldap | - openldap | ||||
| secrets: | secrets: | ||||
| nextcloud: | nextcloud: | ||||
| build: | build: | ||||
| context: ./images/rpi-nextcloud/ | |||||
| context: ./images/nextcloud/ | |||||
| args: | args: | ||||
| - NEXTCLOUD_VERSION=${NEXTCLOUD_VERSION} | - NEXTCLOUD_VERSION=${NEXTCLOUD_VERSION} | ||||
| - NEXTCLOUD_DATA_PATH=${NEXTCLOUD_DATA_PATH} | - NEXTCLOUD_DATA_PATH=${NEXTCLOUD_DATA_PATH} | ||||
| - NEXTCLOUD_BACKUP_PATH=${NEXTCLOUD_BACKUP_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: | depends_on: | ||||
| - db | - db | ||||
| - openldap | - openldap | ||||
| sftp: | sftp: | ||||
| build: | build: | ||||
| context: ./images/rpi-sftp/ | |||||
| image: bingen/rpi-sftp | |||||
| context: ./images/sftp/ | |||||
| image: bingen/${ARCH}-sftp | |||||
| ports: | ports: | ||||
| - "1022:22" | - "1022:22" | ||||
| volumes: | volumes: | ||||
| gogs: | gogs: | ||||
| build: | build: | ||||
| context: ./images/rpi-gogs/ | |||||
| image: bingen/rpi-gogs | |||||
| context: ./images/gogs/ | |||||
| image: bingen/${ARCH}-gogs | |||||
| depends_on: | depends_on: | ||||
| - db | - db | ||||
| - openldap | - openldap | ||||
| mode: 0440 | mode: 0440 | ||||
| pihole: | pihole: | ||||
| image: pihole/pihole:v4.0_armhf | |||||
| image: pihole/pihole:latest | |||||
| deploy: | deploy: | ||||
| placement: | placement: | ||||
| constraints: | constraints: |
| # modify and copy to .env | # modify and copy to .env | ||||
| ARCH=ARCH_PLACEHOLDER | |||||
| # DB | # DB | ||||
| DB_DATA_VOLUME_PATH=${VOLUMES_PATH}/mariadb/data | DB_DATA_VOLUME_PATH=${VOLUMES_PATH}/mariadb/data | ||||
| #DB_CONFIG_VOLUME_PATH=${VOLUMES_PATH}/mariadb/config | #DB_CONFIG_VOLUME_PATH=${VOLUMES_PATH}/mariadb/config |
| FROM resin/raspberrypi3-debian:latest | |||||
| FROM debian:stretch | |||||
| ENV DEBIAN_FRONTEND=noninteractive | ENV DEBIAN_FRONTEND=noninteractive | ||||
| 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"] |
| FROM resin/raspberrypi3-debian:latest | |||||
| FROM debian:stretch | |||||
| ENV GO_VERSION 1.9 | ENV GO_VERSION 1.9 | ||||
| ENV GO_OS linux | ENV GO_OS linux | ||||
| ENV GO_ARCH armv6l | |||||
| ENV GO_ARCH amd64 | |||||
| ENV GOGS_CUSTOM /data/gogs | ENV GOGS_CUSTOM /data/gogs | ||||
| ENV GIT_HOME /home/git | ENV GIT_HOME /home/git | ||||
| # Install dependencies | # Install dependencies | ||||
| RUN apt-get update \ | RUN apt-get update \ | ||||
| && apt-get install -y --no-install-recommends \ | && 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/* | && rm -rf /var/lib/apt/lists/* | ||||
| RUN mkdir -p /data/gogs/data \ | RUN mkdir -p /data/gogs/data \ |
| 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"] |
| exit 1; | exit 1; | ||||
| fi | fi | ||||
| GOGS_PATH=${GOPATH}/src/github.com/gogs/gogs | |||||
| function check_result { | function check_result { | ||||
| if [ $1 != 0 ]; then | if [ $1 != 0 ]; then | ||||
| echo "Error: $2"; | echo "Error: $2"; | ||||
| # ### DB setup ### | # ### DB setup ### | ||||
| # wait for DB to be ready | # wait for DB to be ready | ||||
| sleep 60 # to avoid hitting it while the first start for setting root pwd | |||||
| R=111 | R=111 | ||||
| while [ $R -eq 111 ]; do | while [ $R -eq 111 ]; do | ||||
| mysql -u root -p${MYSQL_ROOT_PWD} -h ${DB_HOST} -e "SHOW DATABASES" 2> /dev/null; | mysql -u root -p${MYSQL_ROOT_PWD} -h ${DB_HOST} -e "SHOW DATABASES" 2> /dev/null; | ||||
| # SSH certs | # SSH certs | ||||
| if [[ ! -e ${GOGS_CUSTOM}/https/cert.pem || ! -e ${GOGS_CUSTOM}/https/key.pem ]]; then | 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 "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 | fi | ||||
| # ### Conf file ### | # ### Conf file ### | ||||
| # We need to re-generate conf file because we are changing DB pwd | # We need to re-generate conf file because we are changing DB pwd | ||||
| #if [[ ! -e ${CONF_FILE} ]]; then | #if [[ ! -e ${CONF_FILE} ]]; then | ||||
| su git -c "mkdir -p ${GOGS_CUSTOM}/conf" | 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 | echo Setting domain | ||||
| sed -i "s/GOGS_DOMAIN/${GOGS_DOMAIN}/g" ${CONF_FILE} | sed -i "s/GOGS_DOMAIN/${GOGS_DOMAIN}/g" ${CONF_FILE} | ||||
| LDAP_FILE=${GOGS_CUSTOM}/conf/auth.d/ldap.conf | LDAP_FILE=${GOGS_CUSTOM}/conf/auth.d/ldap.conf | ||||
| #if [[ ! -e ${CONF_FILE} ]]; then | #if [[ ! -e ${CONF_FILE} ]]; then | ||||
| su git -c "mkdir -p ${GOGS_CUSTOM}/conf/auth.d" | 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 | echo Setting LDAP conf | ||||
| sed -i "s/LDAP_SERVER_HOST/${LDAP_SERVER_HOST}/g" ${LDAP_FILE} | sed -i "s/LDAP_SERVER_HOST/${LDAP_SERVER_HOST}/g" ${LDAP_FILE} | ||||
| # Create admin user if DB was new | # Create admin user if DB was new | ||||
| if [ -z "${DB_EXISTS}" ]; then | 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 | fi | ||||
| #exec "$@" | #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" |
| FROM resin/raspberrypi3-debian:latest | |||||
| FROM debian:stretch | |||||
| RUN echo deb http://deb.debian.org/debian jessie-backports main >> /etc/apt/sources.list | 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 \ | 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 | RUN mkdir -p /run/haproxy | ||||
| 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 |
| # | |||||
| # 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 |
| # | # | ||||
| # MariaDB Dockerfile | # MariaDB Dockerfile | ||||
| # | |||||
| # https://github.com/bingen/rpi-mariadb | |||||
| # | |||||
| # Pull base image. | # Pull base image. | ||||
| FROM resin/raspberrypi3-debian:latest | |||||
| FROM BASE_IMAGE_PLACEHOLDER | |||||
| ENV DEBIAN_FRONTEND=noninteractive | ENV DEBIAN_FRONTEND=noninteractive | ||||
| # Install MariaDB. | # Install MariaDB. | ||||
| RUN \ | RUN \ | ||||
| apt-get update && \ | 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 | COPY tuning.cnf /etc/mysql/conf.d/tuning.cnf | ||||
| #!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 | # set root password from secret | ||||
| if [ ! -z $MYSQL_ROOT_PWD_FILE -a -f $MYSQL_ROOT_PWD_FILE ]; then | if [ ! -z $MYSQL_ROOT_PWD_FILE -a -f $MYSQL_ROOT_PWD_FILE ]; then |
| FROM bingen/rpi-nginx-php | |||||
| FROM bingen/amd64-nginx-php | |||||
| ENV DEBIAN_FRONTEND=noninteractive | ENV DEBIAN_FRONTEND=noninteractive | ||||
| ARG NEXTCLOUD_BACKUP_PATH | ARG NEXTCLOUD_BACKUP_PATH | ||||
| RUN apt-get update && \ | 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 | apt-get clean | ||||
| # Change upload-limits and -sizes | # Change upload-limits and -sizes |
| 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"] |
| exit 1 | exit 1 | ||||
| fi | 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 | # set Admin password from secret | ||||
| if [ ! -z $NEXTCLOUD_ADMIN_PWD_FILE -a -f $NEXTCLOUD_ADMIN_PWD_FILE ]; then | if [ ! -z $NEXTCLOUD_ADMIN_PWD_FILE -a -f $NEXTCLOUD_ADMIN_PWD_FILE ]; then | ||||
| # ### DB ### | # ### DB ### | ||||
| # wait for DB to be ready | # wait for DB to be ready | ||||
| sleep 60 # to avoid hitting it while the first start for setting root pwd | |||||
| R=111 | R=111 | ||||
| while [ $R -eq 111 ]; do | while [ $R -eq 111 ]; do | ||||
| mysql -u root -p${MYSQL_ROOT_PWD} -h ${DB_HOST} -e "SHOW DATABASES" 2> /dev/null; | mysql -u root -p${MYSQL_ROOT_PWD} -h ${DB_HOST} -e "SHOW DATABASES" 2> /dev/null; |
| FROM bingen/rpi-nginx | |||||
| FROM bingen/amd64-nginx | |||||
| # Add PHP 7.2 repo | # Add PHP 7.2 repo | ||||
| RUN apt-get update && \ | RUN apt-get update && \ |
| 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 |
| FROM resin/raspberrypi3-debian:stretch | |||||
| FROM debian:stretch | |||||
| #ENV NGINX_VERSION 1.2.1-2.2+wheezy3 | #ENV NGINX_VERSION 1.2.1-2.2+wheezy3 | ||||
| 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"] |
| 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 | # 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 | 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 | # Install OpenLDAP, ldap-utils and ssl-tools from baseimage and clean apt-get files | ||||
| RUN apt-get -y update \ | 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 \ | ldap-utils \ | ||||
| openssl \ | openssl \ | ||||
| slapd \ | slapd \ | ||||
| procps \ | |||||
| # ca-certificates \ | # ca-certificates \ | ||||
| # curl \ | # curl \ | ||||
| # patch \ | # patch \ |
| 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 |
| FROM resin/raspberrypi3-debian:latest | |||||
| FROM debian:stretch | |||||
| # Install dependencies | # Install dependencies | ||||
| RUN apt-get update \ | RUN apt-get update \ |
| 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"] |
| fi | fi | ||||
| # ##### Add Let's Encrypt certificates ###### # | # ##### Add Let's Encrypt certificates ###### # | ||||
| echo "" | |||||
| echo "Adding Let's Encrypt certificates" | |||||
| # Find Nextcloud container | # Find Nextcloud container | ||||
| SERVICE=nextcloud | SERVICE=nextcloud |
| MYSQL_ROOT_PWD_FILE=/run/secrets/admin_pwd |
| #!/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 |
| sudo mkdir -p ${LETSENCRYPT_VOLUME_PATH} | sudo mkdir -p ${LETSENCRYPT_VOLUME_PATH} | ||||
| echo "Copying getmail confs" | 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/ |