From 7ce2bbde8d599ef99b4a760be43580953094ed78 Mon Sep 17 00:00:00 2001 From: Lieuwe Leene Date: Sun, 30 Oct 2022 11:25:25 +0100 Subject: [PATCH 01/19] WIP: gitea setup --- config/gitea.ini | 94 +++++++++++++++++++++++++++++++++++++++++++++ docker-compose.yaml | 63 ++++++++++++++++++++++++++---- 2 files changed, 150 insertions(+), 7 deletions(-) create mode 100644 config/gitea.ini diff --git a/config/gitea.ini b/config/gitea.ini new file mode 100644 index 0000000..0e572ad --- /dev/null +++ b/config/gitea.ini @@ -0,0 +1,94 @@ +APP_NAME = Gitea: Git with a cup of tea +RUN_MODE = prod +RUN_USER = git + +[repository] +ROOT = /data/git/repositories + +[repository.local] +LOCAL_COPY_PATH = /data/gitea/tmp/local-repo + +[repository.upload] +TEMP_PATH = /data/gitea/uploads + +[server] +APP_DATA_PATH = /data/gitea +DOMAIN = localhost +SSH_DOMAIN = localhost +HTTP_PORT = 3000 +ROOT_URL = http://localhost:3000/ +DISABLE_SSH = false +SSH_PORT = 22 +SSH_LISTEN_PORT = 22 +LFS_START_SERVER = true +LFS_JWT_SECRET = 13R03sc6ZlnDkBFwKup2PoeT3eOggjn2oEmkOSjkQsE +OFFLINE_MODE = false + +[database] +PATH = /data/gitea/gitea.db +DB_TYPE = postgres +HOST = database:5432 +NAME = gitea +USER = gitea +PASSWD = "hear397sew" +LOG_SQL = false +SCHEMA = +SSL_MODE = disable +CHARSET = utf8 + +[indexer] +ISSUE_INDEXER_PATH = /data/gitea/indexers/issues.bleve + +[session] +PROVIDER_CONFIG = /data/gitea/sessions +PROVIDER = file + +[picture] +AVATAR_UPLOAD_PATH = /data/gitea/avatars +REPOSITORY_AVATAR_UPLOAD_PATH = /data/gitea/repo-avatars +ENABLE_FEDERATED_AVATAR = false + +[attachment] +PATH = /data/gitea/attachments + +[log] +MODE = console +LEVEL = info +ROUTER = console +ROOT_PATH = /data/gitea/log + +[security] +INSTALL_LOCK = true +SECRET_KEY = +REVERSE_PROXY_LIMIT = 1 +REVERSE_PROXY_TRUSTED_PROXIES = * +INTERNAL_TOKEN = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE2NjcxMjI4NDN9.2POH2B9XRVJQx5Ixymbz1iNT7D8OOPiaJNnk1ELTM8s +PASSWORD_HASH_ALGO = pbkdf2 + +[service] +DISABLE_REGISTRATION = false +REQUIRE_SIGNIN_VIEW = false +REGISTER_EMAIL_CONFIRM = false +ENABLE_NOTIFY_MAIL = false +ALLOW_ONLY_EXTERNAL_REGISTRATION = false +ENABLE_CAPTCHA = false +DEFAULT_KEEP_EMAIL_PRIVATE = false +DEFAULT_ALLOW_CREATE_ORGANIZATION = true +DEFAULT_ENABLE_TIMETRACKING = true +NO_REPLY_ADDRESS = noreply.localhost + +[lfs] +PATH = /data/git/lfs + +[mailer] +ENABLED = false + +[openid] +ENABLE_OPENID_SIGNIN = true +ENABLE_OPENID_SIGNUP = true + +[repository.pull-request] +DEFAULT_MERGE_STYLE = merge + +[repository.signing] +DEFAULT_TRUST_MODEL = committer diff --git a/docker-compose.yaml b/docker-compose.yaml index 73ec0e9..6f46be6 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,10 +1,59 @@ version: "3.5" +networks: + gitea: + external: false + services: - blog: - container_name: personal-blog - build: - context: ./personal-page - args: - HUGO_ENV_ARG: "production" - HUGO_CMD: "-d localhost" + database: + container_name: PGSQLdb + image: postgres:15 + volumes: + - type: bind + source: ./pgsql + target: /var/lib/postgresql/data + - ./pg-init-scripts:/docker-entrypoint-initdb.d + restart: always + ports: + - "5432:5432" + environment: + POSTGRES_USER: "pgadmin" + POSTGRES_PASSWORD: "hear397sew" + POSTGRES_INITDB_ARGS: "--auth-host=scram-sha-256 --auth-local=scram-sha-256" + POSTGRES_MULTIPLE_DATABASES: "gitea, postfix" + networks: + - gitea + + adminer: + image: adminer + restart: always + depends_on: + - database + ports: + - 8080:8080 + networks: + - gitea + + server: + image: gitea/gitea + container_name: gitea + environment: + - USER_UID=1000 + - USER_GID=1000 + - GITEA__database__DB_TYPE=postgres + - GITEA__database__HOST=database:5432 + - GITEA__database__NAME=gitea + - GITEA__database__USER=gitea + - GITEA__database__PASSWD="hear397sew" + restart: always + networks: + - gitea + volumes: + - ./gitea:/data + - /etc/timezone:/etc/timezone:ro + - /etc/localtime:/etc/localtime:ro + ports: + - "3000:3000" + - "222:22" + depends_on: + - database From 2c4b686aabd70760be7ecf74325c6b5307b111da Mon Sep 17 00:00:00 2001 From: Lieuwe Leene Date: Sun, 30 Oct 2022 11:27:58 +0100 Subject: [PATCH 02/19] WIP: pgsql init --- pg-init-scripts/init_db.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 pg-init-scripts/init_db.sh diff --git a/pg-init-scripts/init_db.sh b/pg-init-scripts/init_db.sh new file mode 100644 index 0000000..d4d7f0f --- /dev/null +++ b/pg-init-scripts/init_db.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +set -e +set -u + +function create_user_and_database() { + local database=$1 + echo "Creating user and database '$database'" + psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL + CREATE USER $database; + CREATE DATABASE $database WITH OWNER $database TEMPLATE template0 ENCODING UTF8 LC_COLLATE 'en_US.UTF-8' LC_CTYPE 'en_US.UTF-8'; + GRANT ALL PRIVILEGES ON DATABASE $database TO $database; + ALTER ROLE $database WITH LOGIN PASSWORD '$POSTGRES_PASSWORD'; +EOSQL +} + +if [ -n "$POSTGRES_MULTIPLE_DATABASES" ]; then + echo "Creating databases: $POSTGRES_MULTIPLE_DATABASES" + for db in $(echo "$POSTGRES_MULTIPLE_DATABASES" | tr ',' ' '); do + create_user_and_database "$db" + done + echo "Multiple databases created" +fi From a1cf58614a7d75989f8ef6f05c3261ba199ba1b4 Mon Sep 17 00:00:00 2001 From: Lieuwe Leene Date: Sun, 30 Oct 2022 11:28:20 +0100 Subject: [PATCH 03/19] ignore docker volumes --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 0087b47..f1b5dcc 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,5 @@ bundles/ vendor/pkg/ pyenv Vagrantfile +gitea +pgsql From b7f215d3bf782e42d8760927c788e5ad4b78b149 Mon Sep 17 00:00:00 2001 From: Lieuwe Leene Date: Sat, 5 Nov 2022 10:45:43 +0100 Subject: [PATCH 04/19] update google dns --- docker-compose.yaml | 92 +++++++++++++++++++++++++++------------------ local.env | 35 +++++++++++++++++ 2 files changed, 90 insertions(+), 37 deletions(-) create mode 100644 local.env diff --git a/docker-compose.yaml b/docker-compose.yaml index 6f46be6..b2d43cb 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,12 +1,24 @@ -version: "3.5" +version: "3.8" networks: - gitea: + internalnet: external: false +x-mail: &defaults + env_file: local.env + networks: + - internalnet + services: + ddnsgd: + <<: *defaults + container_name: "ddnsgd" + image: "ghcr.io/dominickbrasileiro/ddnsgd" + restart: "always" + database: - container_name: PGSQLdb + <<: *defaults + container_name: pgsqlserver image: postgres:15 volumes: - type: bind @@ -16,44 +28,50 @@ services: restart: always ports: - "5432:5432" - environment: - POSTGRES_USER: "pgadmin" - POSTGRES_PASSWORD: "hear397sew" - POSTGRES_INITDB_ARGS: "--auth-host=scram-sha-256 --auth-local=scram-sha-256" - POSTGRES_MULTIPLE_DATABASES: "gitea, postfix" - networks: - - gitea + + roundcubemail: + <<: *defaults + image: roundcube/roundcubemail:latest-fpm + container_name: roundcube + depends_on: + - roundcubedb + links: + - roundcubedb + ports: + - 9000:9000 + volumes: + - ./mail/html:/var/www/html + + + mailserver: + <<: *defaults + image: docker.io/mailserver/docker-mailserver:latest + container_name: mailserver + hostname: mail + domainname: zathura.leene.dev + ports: + - "25:25" + - "143:143" + - "587:587" + - "993:993" + volumes: + - ./mail/mail-data/:/var/mail/ + - ./mail/mail-state/:/var/mail-state/ + - ./mail/mail-logs/:/var/log/mail/ + - ./mail/config/:/tmp/docker-mailserver/ + - /etc/localtime:/etc/localtime:ro + cap_add: + - NET_ADMIN + depends_on: + - ddnsgd + restart: always + adminer: + <<: *defaults image: adminer restart: always depends_on: - database ports: - - 8080:8080 - networks: - - gitea - - server: - image: gitea/gitea - container_name: gitea - environment: - - USER_UID=1000 - - USER_GID=1000 - - GITEA__database__DB_TYPE=postgres - - GITEA__database__HOST=database:5432 - - GITEA__database__NAME=gitea - - GITEA__database__USER=gitea - - GITEA__database__PASSWD="hear397sew" - restart: always - networks: - - gitea - volumes: - - ./gitea:/data - - /etc/timezone:/etc/timezone:ro - - /etc/localtime:/etc/localtime:ro - ports: - - "3000:3000" - - "222:22" - depends_on: - - database + - "8080:8080" diff --git a/local.env b/local.env new file mode 100644 index 0000000..93fcb5a --- /dev/null +++ b/local.env @@ -0,0 +1,35 @@ + +## Google Dynamic DNS + +INTERVAL=30 +HOSTNAME="zathura.leene.dev" +USERNAME="JaMolgvImRt3jznO" +PASSWORD="Enl0rRgqBsZPVupA" + +## Mail Server Env + +ENABLE_SPAMASSASSIN=1 +SPAMASSASSIN_SPAM_TO_INBOX=1 +ENABLE_CLAMAV=1 +ENABLE_FAIL2BAN=1 +ENABLE_POSTGREY=1 +ENABLE_SASLAUTHD=0 +ONE_DIR=1 + +## SQL Server Env + +POSTGRES_USER="pgadmin" +POSTGRES_PASSWORD="hear397sew" +POSTGRES_INITDB_ARGS="--auth-host=scram-sha-256 --auth-local=scram-sha-256" +POSTGRES_MULTIPLE_DATABASES="gitea, roundcube" + +## Round Cube Env + +ROUNDCUBEMAIL_DB_TYPE=pgsql +ROUNDCUBEMAIL_DB_HOST=database +ROUNDCUBEMAIL_DB_NAME=roundcube +ROUNDCUBEMAIL_DB_USER=roundcube +ROUNDCUBEMAIL_DB_PASSWORD=hear397sew +ROUNDCUBEMAIL_SKIN=elastic +ROUNDCUBEMAIL_DEFAULT_HOST=tls://mail.zathura.leene.dev +ROUNDCUBEMAIL_SMTP_SERVER=tls://mail.zathura.leene.dev From f95536338b28571a8b5c3c403e95f4aeba1f5e00 Mon Sep 17 00:00:00 2001 From: Lieuwe Leene Date: Sat, 5 Nov 2022 15:00:31 +0100 Subject: [PATCH 05/19] WIP: trying mailserver --- Dockerfile | 14 ++++ config/mail/10-custom.conf | 7 ++ .../pg-init-scripts}/init_db.sh | 0 docker-compose.yaml | 65 ++++++++++++++----- local.env | 22 +++++++ 5 files changed, 93 insertions(+), 15 deletions(-) create mode 100644 Dockerfile create mode 100644 config/mail/10-custom.conf rename {pg-init-scripts => config/pg-init-scripts}/init_db.sh (100%) diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..963e3e4 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM alpine + +MAINTAINER Lieuwe Leene + +ARG SSL_ALGO=secp521r1 + +RUN apk update && \ + apk add --no-cache openssl && \ + rm -rf /var/cache/apk/* + +COPY ./mail/certs /certs + +RUN openssl ecparam -name ${SSL_ALGO} -genkey | openssl pkey -out /certs/ecprivkey.pem && \ + openssl pkey -in /certs/ecprivkey.pem -pubout -out /certs/ecpubkey.pem diff --git a/config/mail/10-custom.conf b/config/mail/10-custom.conf new file mode 100644 index 0000000..9fa9c41 --- /dev/null +++ b/config/mail/10-custom.conf @@ -0,0 +1,7 @@ +# Enables mail_crypt for all services (imap, pop3, etc) +mail_plugins = $mail_plugins mail_crypt +plugin { + mail_crypt_global_private_key = Date: Sat, 5 Nov 2022 17:42:02 +0100 Subject: [PATCH 06/19] selinux for volumes: --- docker-compose.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 4b0d3d6..b106e12 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -24,7 +24,7 @@ services: - type: bind source: ./pgsql target: /var/lib/postgresql/data:z - - ./config/pg-init-scripts:/docker-entrypoint-initdb.d + - ./config/pg-init-scripts:/docker-entrypoint-initdb.d:z restart: always ports: - "5432:5432" @@ -49,7 +49,7 @@ services: ports: - 9000:9000 volumes: - - ./mail/html:/var/www/html + - ./mail/html:/var/www/html:z mailserver: From 4c574954fe906fe549fe57a8a3400aa7cb2e1a73 Mon Sep 17 00:00:00 2001 From: Lieuwe Leene Date: Sun, 6 Nov 2022 10:41:10 +0100 Subject: [PATCH 07/19] WIP mail stack --- docker-compose.yaml | 42 +++++++++++++++++++----------------------- local.env | 26 ++++++++++++++------------ 2 files changed, 33 insertions(+), 35 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index b106e12..d04a1fb 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -2,6 +2,8 @@ version: "3.8" networks: internalnet: + driver: bridge + enable_ipv6: false x-mail: &defaults @@ -16,7 +18,7 @@ services: image: "ghcr.io/dominickbrasileiro/ddnsgd" restart: "always" - database: + pgsqlserver: <<: *defaults container_name: pgsqlserver image: postgres:15 @@ -29,33 +31,25 @@ services: ports: - "5432:5432" - adminer: - <<: *defaults - image: adminer - restart: always - depends_on: - - database - ports: - - "8080:8080" - roundcubemail: <<: *defaults image: roundcube/roundcubemail:latest-fpm - container_name: roundcube + container_name: roundcubemail + environment: + - ROUNDCUBEMAIL_DB_HOST=pgsqlserver depends_on: - - database + - pgsqlserver links: - - database + - pgsqlserver ports: - - 9000:9000 + - "9000:9000" volumes: - - ./mail/html:/var/www/html:z - + - ./nginx/html/:/var/www/html/:z mailserver: build: . <<: *defaults - image: docker.io/mailserver/docker-mailserver:latest + image: mailserver/docker-mailserver:latest container_name: mailserver hostname: mail domainname: zathura.leene.dev @@ -65,12 +59,12 @@ services: - "587:587" - "993:993" volumes: - - ./mail/letsencrypt:/etc/letsencrypt:z + - ./nginx/certs/:/etc/letsencrypt/live/:z - ./mail/mail-data/:/var/mail/:z - ./mail/mail-state/:/var/mail-state/:z - ./mail/mail-logs/:/var/log/mail/:z - ./mail/config/:/tmp/docker-mailserver/:z - - ./mail/certs/:/certs:z + - ./nginx/certs/:/certs/:z - /etc/localtime:/etc/localtime:ro cap_add: @@ -83,6 +77,8 @@ services: <<: *defaults image: nginxproxy/nginx-proxy container_name: nginx-proxy + environment: + - NGINX_PHP_CGI=roundcubemail:9000 restart: always ports: - "80:80" @@ -91,9 +87,9 @@ services: - ./nginx/conf/:/etc/nginx/conf.d:z - ./nginx/html/:/usr/share/nginx/html/:z - ./nginx/vhost/:/etc/nginx/vhost.d/:z - - ./nginx/certs/:/etc/nginx/certs/:ro + - ./nginx/certs/:/etc/nginx/certs/:z - ./nginx/dhparam:/etc/nginx/dhparam:z - - /var/run/docker.sock:/tmp/docker.sock:ro + - /var/run/docker.sock:/tmp/docker.sock:z depends_on: - ddnsgd @@ -105,8 +101,8 @@ services: volumes_from: - reverse-proxy volumes: - - ./nginx/certs/:/etc/nginx/certs/:rw + - ./nginx/certs/:/etc/nginx/certs/:z - ./nginx/acme-state/:/etc/acme.sh/:z - - /var/run/docker.sock:/var/run/docker.sock:ro + - /var/run/docker.sock:/var/run/docker.sock:z depends_on: - ddnsgd diff --git a/local.env b/local.env index 306b0f8..a5a6d12 100644 --- a/local.env +++ b/local.env @@ -1,17 +1,24 @@ +## Keys + +ROUNDCUBEMAIL_DB_PASSWORD=hear397sew +POSTGRES_PASSWORD="hear397sew" +USERNAME="JaMolgvImRt3jznO" +PASSWORD="Enl0rRgqBsZPVupA" + +## Docker Env + DEBUG=1 -DOCKER_HOST_ROOTLESS_PATH=/run/user/1000/docker.sock +PERMIT_DOCKER=network ## Google Dynamic DNS INTERVAL=30 HOSTNAME="zathura.leene.dev" -USERNAME="JaMolgvImRt3jznO" -PASSWORD="Enl0rRgqBsZPVupA" ## Mail Server Env POSTFIX_INET_PROTOCOLS=ipv4 -TZ=NL +TZ=Europe/Berlin ENABLE_SPAMASSASSIN=1 SPAMASSASSIN_SPAM_TO_INBOX=1 ENABLE_CLAMAV=1 @@ -25,33 +32,28 @@ POSTMASTER_ADDRESS=admin@leene.dev ENABLE_UPDATE_CHECK=1 SSL_TYPE=letsencrypt -VIRTUAL_HOST=mail.zathura.leene.dev -LETSENCRYPT_HOST=mail.zathura.leene.dev +VIRTUAL_HOST=zathura.leene.dev,mail.zathura.leene.dev,git.zathura.leene.dev +LETSENCRYPT_HOST=zathura.leene.dev,mail.zathura.leene.dev,git.zathura.leene.dev ## SQL Server Env POSTGRES_USER="pgadmin" -POSTGRES_PASSWORD="hear397sew" POSTGRES_INITDB_ARGS="--auth-host=scram-sha-256 --auth-local=scram-sha-256" POSTGRES_MULTIPLE_DATABASES="gitea, roundcube" ## Round Cube Env ROUNDCUBEMAIL_DB_TYPE=pgsql -ROUNDCUBEMAIL_DB_HOST=database ROUNDCUBEMAIL_DB_NAME=roundcube ROUNDCUBEMAIL_DB_USER=roundcube -ROUNDCUBEMAIL_DB_PASSWORD=hear397sew ROUNDCUBEMAIL_SKIN=elastic ROUNDCUBEMAIL_DEFAULT_HOST=tls://mail.zathura.leene.dev ROUNDCUBEMAIL_SMTP_SERVER=tls://mail.zathura.leene.dev ## NGINX Reverse Proxy - +NGINX_HOST=zathura.leene.dev NGINX_PROXY_CONTAINER=nginx-proxy LETSENCRYPT_TEST=true LETSENCRYPT_RESTART_CONTAINER=true DEFAULT_EMAIL=lieuwe@leene.dev -NGINX_HOST=zathura.leene.dev -NGINX_PHP_CGI=roundcubemail:9000 From 273cb5f82906b3563770e1c1e746c017e8c4d352 Mon Sep 17 00:00:00 2001 From: Lieuwe Leene Date: Sun, 6 Nov 2022 10:42:47 +0100 Subject: [PATCH 08/19] config nginx --- config/nginx/default.conf | 17 +++ setup.sh | 223 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 240 insertions(+) create mode 100644 config/nginx/default.conf create mode 100644 setup.sh diff --git a/config/nginx/default.conf b/config/nginx/default.conf new file mode 100644 index 0000000..ae7ee20 --- /dev/null +++ b/config/nginx/default.conf @@ -0,0 +1,17 @@ +server { + index index.php index.html; + server_name php-docker.local; + error_log /var/log/nginx/error.log; + access_log /var/log/nginx/access.log; + root /var/www/html; + + location ~ \.php$ { + try_files $uri =404; + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_pass ${NGINX_PHP_CGI}; + fastcgi_index index.php; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param PATH_INFO $fastcgi_path_info; + } +} diff --git a/setup.sh b/setup.sh new file mode 100644 index 0000000..7c6fbfd --- /dev/null +++ b/setup.sh @@ -0,0 +1,223 @@ +#!/bin/bash + +# version v1.0.0 +# executed manually / via Make +# task wrapper for various setup scripts + +CONFIG_PATH= +CONTAINER_NAME= +CRI= +DEFAULT_CONFIG_PATH= +DESIRED_CONFIG_PATH= +DIR=$(pwd) +DMS_CONFIG='/tmp/docker-mailserver' +IMAGE_NAME= +DEFAULT_IMAGE_NAME='docker.io/mailserver/docker-mailserver:latest' +INFO= +PODMAN_ROOTLESS=false +USE_SELINUX= +USE_TTY= +VOLUME= + +WHITE=$(echo -ne '\e[37m') +ORANGE=$(echo -ne '\e[38;5;214m') +LBLUE=$(echo -ne '\e[94m') +RESET=$(echo -ne '\e[0m') + +set -euEo pipefail +shopt -s inherit_errexit 2>/dev/null || true + +function _show_local_usage +{ + # shellcheck disable=SC2059 + printf '%s' "${ORANGE}OPTIONS${RESET} + ${LBLUE}Config path, container or image adjustments${RESET} + -i IMAGE_NAME + Provides the name of the 'docker-mailserver' image. The default value is + '${WHITE}${DEFAULT_IMAGE_NAME}${RESET}' + + -c CONTAINER_NAME + Provides the name of the running container. + + -p PATH + Provides the local path of the config folder to the temporary container instance. + Does not work if an existing a 'docker-mailserver' container is already running. + + ${LBLUE}SELinux${RESET} + -z + Allows container access to the bind mount content that is shared among + multiple containers on a SELinux-enabled host. + + -Z + Allows container access to the bind mount content that is private and + unshared with other containers on a SELinux-enabled host. + + ${LBLUE}Podman${RESET} + -R + Accept running in Podman rootless mode. Ignored when using Docker / Docker Compose. + +" + + [[ ${1:-} == 'no-exit' ]] && return 0 + + # shellcheck disable=SC2059 + printf '%s' "${ORANGE}EXIT STATUS${RESET} + Exit status is 0 if the command was successful. If there was an unexpected error, an error + message is shown describing the error. In case of an error, the script will exit with exit + status 1. + +" +} + +function _get_absolute_script_directory +{ + if dirname "$(readlink -f "${0}")" &>/dev/null + then + DIR=$(dirname "$(readlink -f "${0}")") + elif realpath -e -L "${0}" &>/dev/null + then + DIR=$(realpath -e -L "${0}") + DIR="${DIR%/setup.sh}" + fi +} + +function _set_default_config_path +{ + if [[ -d "${DIR}/config" ]] + then + # legacy path (pre v10.2.0) + DEFAULT_CONFIG_PATH="${DIR}/config" + else + DEFAULT_CONFIG_PATH="${DIR}/docker-data/dms/config" + fi +} + +function _handle_config_path +{ + if [[ -z ${DESIRED_CONFIG_PATH} ]] + then + # no desired config path + if [[ -n ${CONTAINER_NAME} ]] + then + VOLUME=$(${CRI} inspect "${CONTAINER_NAME}" \ + --format="{{range .Mounts}}{{ println .Source .Destination}}{{end}}" | \ + grep "${DMS_CONFIG}$" 2>/dev/null || :) + fi + + if [[ -n ${VOLUME} ]] + then + CONFIG_PATH=$(echo "${VOLUME}" | awk '{print $1}') + fi + + if [[ -z ${CONFIG_PATH} ]] + then + CONFIG_PATH=${DEFAULT_CONFIG_PATH} + fi + else + CONFIG_PATH=${DESIRED_CONFIG_PATH} + fi +} + +function _run_in_new_container +{ + # start temporary container with specified image + if ! ${CRI} history -q "${IMAGE_NAME}" &>/dev/null + then + echo "Image '${IMAGE_NAME}' not found. Pulling ..." + ${CRI} pull "${IMAGE_NAME}" + fi + + ${CRI} run --rm "${USE_TTY}" \ + -v "${CONFIG_PATH}:${DMS_CONFIG}${USE_SELINUX}" \ + "${IMAGE_NAME}" "${@}" +} + +function _main +{ + _get_absolute_script_directory + _set_default_config_path + + local OPTIND + while getopts ":c:i:p:zZR" OPT + do + case ${OPT} in + ( i ) IMAGE_NAME="${OPTARG}" ;; + ( z | Z ) USE_SELINUX=":${OPT}" ;; + ( c ) CONTAINER_NAME="${OPTARG}" ;; + ( R ) PODMAN_ROOTLESS=true ;; + ( p ) + case "${OPTARG}" in + ( /* ) DESIRED_CONFIG_PATH="${OPTARG}" ;; + ( * ) DESIRED_CONFIG_PATH="${DIR}/${OPTARG}" ;; + esac + + if [[ ! -d ${DESIRED_CONFIG_PATH} ]] + then + echo "Specified directory '${DESIRED_CONFIG_PATH}' doesn't exist" >&2 + exit 1 + fi + ;; + + ( * ) + echo "Invalid option: '-${OPTARG}'" >&2 + echo -e "Use './setup.sh help' to get a complete overview.\n" >&2 + _show_local_usage 'no-exit' + exit 1 + ;; + + esac + done + shift $(( OPTIND - 1 )) + + if command -v docker &>/dev/null + then + CRI=docker + elif command -v podman &>/dev/null + then + CRI=podman + if ! ${PODMAN_ROOTLESS} && [[ ${EUID} -ne 0 ]] + then + read -r -p "You are running Podman in rootless mode. Continue? [Y/n] " + [[ -n ${REPLY} ]] && [[ ${REPLY} =~ (n|N) ]] && exit 0 + fi + else + echo 'No supported Container Runtime Interface detected.' + exit 1 + fi + + INFO=$(${CRI} ps --no-trunc --format "{{.Image}};{{.Names}}" --filter \ + label=org.opencontainers.image.title="docker-mailserver" | tail -1) + + [[ -z ${CONTAINER_NAME} ]] && CONTAINER_NAME=${INFO#*;} + [[ -z ${IMAGE_NAME} ]] && IMAGE_NAME=${INFO%;*} + if [[ -z ${IMAGE_NAME} ]] + then + IMAGE_NAME=${NAME:-${DEFAULT_IMAGE_NAME}} + fi + + if test -t 0 + then + USE_TTY="-it" + else + # GitHub Actions will fail (or really anything else + # lacking an interactive tty) if we don't set a + # value here; "-t" alone works for these cases. + USE_TTY="-t" + fi + + _handle_config_path + + if [[ -n ${CONTAINER_NAME} ]] + then + ${CRI} exec "${USE_TTY}" "${CONTAINER_NAME}" setup "${@}" + else + _run_in_new_container setup "${@}" + fi + + [[ ${1:-} == 'help' ]] && _show_local_usage + + return 0 +} + +[[ -z ${1:-} ]] && set 'help' +_main "${@}" From dde53d34528dc5c1f2a5fefa968ec128ccca6a9a Mon Sep 17 00:00:00 2001 From: Lieuwe Leene Date: Sat, 12 Nov 2022 16:54:48 +0100 Subject: [PATCH 09/19] Working Draft --- config/mail/10-custom.conf | 4 +- Dockerfile => config/mail/Dockerfile | 6 +- config/nginx/default.conf | 17 ------ config/nginx/zathura.leene.dev_location | 27 +++++++++ docker-compose.yaml | 73 ++++++++++++++----------- local.env | 14 ++--- 6 files changed, 80 insertions(+), 61 deletions(-) rename Dockerfile => config/mail/Dockerfile (53%) delete mode 100644 config/nginx/default.conf create mode 100644 config/nginx/zathura.leene.dev_location diff --git a/config/mail/10-custom.conf b/config/mail/10-custom.conf index 9fa9c41..975cfb5 100644 --- a/config/mail/10-custom.conf +++ b/config/mail/10-custom.conf @@ -1,7 +1,7 @@ # Enables mail_crypt for all services (imap, pop3, etc) mail_plugins = $mail_plugins mail_crypt plugin { - mail_crypt_global_private_key = Date: Sun, 13 Nov 2022 09:29:11 +0100 Subject: [PATCH 10/19] WIP: progress build --- TODO.md | 9 ++++++ config/nginx/git.zathura.leene.dev_location | 9 ++++++ ...ation => inbox.zathura.leene.dev_location} | 0 docker-compose.yaml | 32 +++++++++++++++++-- local.env | 2 -- 5 files changed, 47 insertions(+), 5 deletions(-) create mode 100644 TODO.md create mode 100644 config/nginx/git.zathura.leene.dev_location rename config/nginx/{zathura.leene.dev_location => inbox.zathura.leene.dev_location} (100%) diff --git a/TODO.md b/TODO.md new file mode 100644 index 0000000..f361f7a --- /dev/null +++ b/TODO.md @@ -0,0 +1,9 @@ +# Startup + + - Update accounts + - Update dkim + +# Compose + + - Include Hugo in build + - Include nextcloud in build diff --git a/config/nginx/git.zathura.leene.dev_location b/config/nginx/git.zathura.leene.dev_location new file mode 100644 index 0000000..e193fd2 --- /dev/null +++ b/config/nginx/git.zathura.leene.dev_location @@ -0,0 +1,9 @@ + +location / { + proxy_pass git.zathura.leene.dev; + proxy_redirect off; + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; +} diff --git a/config/nginx/zathura.leene.dev_location b/config/nginx/inbox.zathura.leene.dev_location similarity index 100% rename from config/nginx/zathura.leene.dev_location rename to config/nginx/inbox.zathura.leene.dev_location diff --git a/docker-compose.yaml b/docker-compose.yaml index a071f8f..5585a5f 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -17,6 +17,8 @@ services: <<: *defaults container_name: pgsqlserver image: postgres:15 + environment: + - POSTGRES_MULTIPLE_DATABASES="gitea, roundcube" volumes: - sql_data:/var/lib/postgresql/data/:z - ./config/pg-init-scripts:/docker-entrypoint-initdb.d:ro @@ -24,13 +26,37 @@ services: expose: - "5432" + gitea: + <<: *defaults + container_name: gitea + image: gitea/gitea + restart: always + environment: + - VIRTUAL_HOST=git.zathura.leene.dev + - VIRTUAL_PORT=3000 + - LETSENCRYPT_HOST=zathura.leene.dev + - LETSENCRYPT_EMAIL=admin@zathura.leene.dev + volumes: + - gitea_data:/data:z + - /etc/timezone:/etc/timezone:ro + - /etc/localtime:/etc/localtime:ro + expose: + - "3000" + ports: + - "222:22" + depends_on: + - pgsqlserver + links: + - pgsqlserver + roundcubemail: <<: *defaults image: roundcube/roundcubemail:latest-fpm container_name: roundcubemail environment: - ROUNDCUBEMAIL_DB_HOST=pgsqlserver - - VIRTUAL_HOST=zathura.leene.dev + - VIRTUAL_HOST=inbox.zathura.leene.dev + - VIRTUAL_PORT=9000 - LETSENCRYPT_HOST=zathura.leene.dev - LETSENCRYPT_EMAIL=admin@zathura.leene.dev depends_on: @@ -66,7 +92,6 @@ services: - ddnsgd restart: always - reverse-proxy: <<: *defaults image: nginxproxy/nginx-proxy @@ -107,8 +132,8 @@ services: build: ./config/nginx volumes: - sql_data: acme-state: + gitea_data: nginx_certs: nginx_dhparam: nginx_html: @@ -117,3 +142,4 @@ volumes: mail_data: mail_config: mail_state: + sql_data: diff --git a/local.env b/local.env index f86934d..70680d2 100644 --- a/local.env +++ b/local.env @@ -32,12 +32,10 @@ ENABLE_UPDATE_CHECK=1 SSL_TYPE=letsencrypt - ## SQL Server Env POSTGRES_USER="pgadmin" POSTGRES_INITDB_ARGS="--auth-host=scram-sha-256 --auth-local=scram-sha-256" -POSTGRES_MULTIPLE_DATABASES="gitea, roundcube" ## Round Cube Env From c8fe500d18cdae728e5cf897b72881a5460998f1 Mon Sep 17 00:00:00 2001 From: Lieuwe Leene Date: Sun, 13 Nov 2022 10:19:12 +0100 Subject: [PATCH 11/19] WIP --- config/nginx/git.zathura.leene.dev_location | 9 --------- config/nginx/inbox.zathura.leene.dev_location | 5 ++--- docker-compose.yaml | 16 +++++++++------- 3 files changed, 11 insertions(+), 19 deletions(-) delete mode 100644 config/nginx/git.zathura.leene.dev_location diff --git a/config/nginx/git.zathura.leene.dev_location b/config/nginx/git.zathura.leene.dev_location deleted file mode 100644 index e193fd2..0000000 --- a/config/nginx/git.zathura.leene.dev_location +++ /dev/null @@ -1,9 +0,0 @@ - -location / { - proxy_pass git.zathura.leene.dev; - proxy_redirect off; - proxy_set_header Host $http_host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; -} diff --git a/config/nginx/inbox.zathura.leene.dev_location b/config/nginx/inbox.zathura.leene.dev_location index 7cbfe2e..4262324 100644 --- a/config/nginx/inbox.zathura.leene.dev_location +++ b/config/nginx/inbox.zathura.leene.dev_location @@ -1,7 +1,6 @@ -root /var/www/html/roundcubemail; +root /var/www/html/roundcube; index index.php index.html index.htm; -client_max_body_size 128M; location / { try_files $uri $uri/ /index.php?q=$uri&$args; @@ -11,8 +10,8 @@ location ~ \.php$ { try_files $uri =404; fastcgi_keep_conn on; fastcgi_split_path_info ^(.+\.php)(.*)$; - fastcgi_pass zathura.leene.dev; fastcgi_index index.php; + fastcgi_pass inbox.zathura.leene.dev; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; diff --git a/docker-compose.yaml b/docker-compose.yaml index 5585a5f..8693f41 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -34,7 +34,7 @@ services: environment: - VIRTUAL_HOST=git.zathura.leene.dev - VIRTUAL_PORT=3000 - - LETSENCRYPT_HOST=zathura.leene.dev + - LETSENCRYPT_HOST=git.zathura.leene.dev - LETSENCRYPT_EMAIL=admin@zathura.leene.dev volumes: - gitea_data:/data:z @@ -57,7 +57,7 @@ services: - ROUNDCUBEMAIL_DB_HOST=pgsqlserver - VIRTUAL_HOST=inbox.zathura.leene.dev - VIRTUAL_PORT=9000 - - LETSENCRYPT_HOST=zathura.leene.dev + - LETSENCRYPT_HOST=inbox.zathura.leene.dev - LETSENCRYPT_EMAIL=admin@zathura.leene.dev depends_on: - pgsqlserver @@ -66,14 +66,14 @@ services: expose: - "9000" volumes: - - nginx_html/roundcubemail:/var/www/html + - mail_html:/var/www/html:z mailserver: build: ./config/mail <<: *defaults image: mailserver/docker-mailserver:latest container_name: mailserver - hostname: mail + hostname: inbox domainname: zathura.leene.dev ports: - "25:25" @@ -81,7 +81,7 @@ services: - "587:587" - "993:993" volumes: - - nginx_certs:/etc/letsencrypt/live/ + - nginx_certs:/etc/letsencrypt/live:ro - mail_data:/var/mail/:z - mail_state:/var/mail-state/:z - mail_config:/tmp/docker-mailserver/:z @@ -106,7 +106,8 @@ services: - nginx_conf:/etc/nginx/conf.d/:z - nginx_vhost:/etc/nginx/vhost.d/:z - nginx_html:/usr/share/nginx/html/:z - - ./config/nginx/zathura.leene.dev_location:/etc/nginx/vhost.d/zathura.leene.dev_location:ro + - mail_html:/var/www/html/roundcube:z + - ./config/nginx/inbox.zathura.leene.dev_location:/etc/nginx/vhost.d/inbox.zathura.leene.dev_location:z - /var/run/docker.sock:/tmp/docker.sock:z depends_on: - ddnsgd @@ -129,7 +130,7 @@ services: - /var/run/docker.sock:/var/run/docker.sock:z depends_on: - ddnsgd - build: ./config/nginx + volumes: acme-state: @@ -142,4 +143,5 @@ volumes: mail_data: mail_config: mail_state: + mail_html: sql_data: From f2c84d08cd03e46c02c11af16c7e92dae69c716c Mon Sep 17 00:00:00 2001 From: Lieuwe Leene Date: Sun, 13 Nov 2022 10:41:45 +0100 Subject: [PATCH 12/19] working state --- config/nginx/inbox.zathura.leene.dev_location | 2 +- docker-compose.yaml | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/config/nginx/inbox.zathura.leene.dev_location b/config/nginx/inbox.zathura.leene.dev_location index 4262324..6a3f84a 100644 --- a/config/nginx/inbox.zathura.leene.dev_location +++ b/config/nginx/inbox.zathura.leene.dev_location @@ -1,5 +1,5 @@ -root /var/www/html/roundcube; +root /var/www/roundcube; index index.php index.html index.htm; location / { diff --git a/docker-compose.yaml b/docker-compose.yaml index 8693f41..e353ea8 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -18,7 +18,7 @@ services: container_name: pgsqlserver image: postgres:15 environment: - - POSTGRES_MULTIPLE_DATABASES="gitea, roundcube" + - POSTGRES_MULTIPLE_DATABASES=gitea, roundcube volumes: - sql_data:/var/lib/postgresql/data/:z - ./config/pg-init-scripts:/docker-entrypoint-initdb.d:ro @@ -67,6 +67,7 @@ services: - "9000" volumes: - mail_html:/var/www/html:z + - mail_html:/var/www/roundcube:z mailserver: build: ./config/mail @@ -105,8 +106,8 @@ services: - nginx_certs:/etc/nginx/certs/:z - nginx_conf:/etc/nginx/conf.d/:z - nginx_vhost:/etc/nginx/vhost.d/:z - - nginx_html:/usr/share/nginx/html/:z - - mail_html:/var/www/html/roundcube:z + - nginx_html:/usr/share/nginx/html:z + - mail_html:/var/www/roundcube:z - ./config/nginx/inbox.zathura.leene.dev_location:/etc/nginx/vhost.d/inbox.zathura.leene.dev_location:z - /var/run/docker.sock:/tmp/docker.sock:z depends_on: From 57f470798fa32eab75501f1483a1969a167e7cb4 Mon Sep 17 00:00:00 2001 From: Lieuwe Leene Date: Sun, 13 Nov 2022 11:32:34 +0100 Subject: [PATCH 13/19] Cleanup env and security tokens --- .env.example | 9 ++++++ ...hura.leene.dev_location => inbox_location} | 0 docker-compose.yaml | 29 +++++++++++++------ local.env | 20 ------------- 4 files changed, 29 insertions(+), 29 deletions(-) create mode 100644 .env.example rename config/nginx/{inbox.zathura.leene.dev_location => inbox_location} (100%) diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..97ac53c --- /dev/null +++ b/.env.example @@ -0,0 +1,9 @@ +# SET HOST NAME +NGINX_HOST="" + +# GOOGLE DNS API TOKEN +DNS_USERNAME="" +DNS_PASSWORD="" + +# COMMON DB PASSWORD +SQL_PSWD="" diff --git a/config/nginx/inbox.zathura.leene.dev_location b/config/nginx/inbox_location similarity index 100% rename from config/nginx/inbox.zathura.leene.dev_location rename to config/nginx/inbox_location diff --git a/docker-compose.yaml b/docker-compose.yaml index e353ea8..ac42762 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,5 +1,6 @@ version: "3.8" + networks: internalnet: driver: bridge @@ -19,6 +20,7 @@ services: image: postgres:15 environment: - POSTGRES_MULTIPLE_DATABASES=gitea, roundcube + - POSTGRES_PASSWORD=${SQL_PSWD} volumes: - sql_data:/var/lib/postgresql/data/:z - ./config/pg-init-scripts:/docker-entrypoint-initdb.d:ro @@ -32,10 +34,9 @@ services: image: gitea/gitea restart: always environment: - - VIRTUAL_HOST=git.zathura.leene.dev + - VIRTUAL_HOST=git.${NGINX_HOST} - VIRTUAL_PORT=3000 - - LETSENCRYPT_HOST=git.zathura.leene.dev - - LETSENCRYPT_EMAIL=admin@zathura.leene.dev + - LETSENCRYPT_HOST=git.${NGINX_HOST} volumes: - gitea_data:/data:z - /etc/timezone:/etc/timezone:ro @@ -54,11 +55,13 @@ services: image: roundcube/roundcubemail:latest-fpm container_name: roundcubemail environment: - - ROUNDCUBEMAIL_DB_HOST=pgsqlserver - - VIRTUAL_HOST=inbox.zathura.leene.dev + - VIRTUAL_HOST=inbox.${NGINX_HOST} - VIRTUAL_PORT=9000 - - LETSENCRYPT_HOST=inbox.zathura.leene.dev - - LETSENCRYPT_EMAIL=admin@zathura.leene.dev + - LETSENCRYPT_HOST=inbox.${NGINX_HOST} + - ROUNDCUBEMAIL_DB_HOST=pgsqlserver + - ROUNDCUBEMAIL_DEFAULT_HOST=tls://${NGINX_HOST} + - ROUNDCUBEMAIL_SMTP_SERVER=tls://${NGINX_HOST} + - ROUNDCUBEMAIL_DB_PASSWORD=${SQL_PSWD} depends_on: - pgsqlserver links: @@ -75,7 +78,9 @@ services: image: mailserver/docker-mailserver:latest container_name: mailserver hostname: inbox - domainname: zathura.leene.dev + domainname: ${NGINX_HOST} + environment: + - POSTMASTER_ADDRESS=admin@${NGINX_HOST} ports: - "25:25" - "143:143" @@ -98,6 +103,8 @@ services: image: nginxproxy/nginx-proxy container_name: nginx-proxy restart: always + environment: + - DEFAULT_EMAIL=admin@${NGINX_HOST} ports: - "80:80" - "443:443" @@ -108,7 +115,7 @@ services: - nginx_vhost:/etc/nginx/vhost.d/:z - nginx_html:/usr/share/nginx/html:z - mail_html:/var/www/roundcube:z - - ./config/nginx/inbox.zathura.leene.dev_location:/etc/nginx/vhost.d/inbox.zathura.leene.dev_location:z + - ./config/nginx/inbox_location:/etc/nginx/vhost.d/inbox.${NGINX_HOST}_location:z - /var/run/docker.sock:/tmp/docker.sock:z depends_on: - ddnsgd @@ -118,6 +125,10 @@ services: container_name: "ddnsgd" image: "ghcr.io/dominickbrasileiro/ddnsgd" restart: "always" + environment: + - HOSTNAME=${NGINX_HOST} + - USERNAME=${DNS_USERNAME} + - PASSWORD=${DNS_PASSWORD} acme-companion: <<: *defaults diff --git a/local.env b/local.env index 70680d2..1d03bf8 100644 --- a/local.env +++ b/local.env @@ -1,21 +1,10 @@ -## Keys - -ROUNDCUBEMAIL_DB_PASSWORD=hear397sew -POSTGRES_PASSWORD="hear397sew" -USERNAME="JaMolgvImRt3jznO" -PASSWORD="Enl0rRgqBsZPVupA" - ## Docker Env - PERMIT_DOCKER=network ## Google Dynamic DNS - INTERVAL=900 -HOSTNAME="zathura.leene.dev" ## Mail Server Env - POSTFIX_INET_PROTOCOLS=ipv4 TZ=Europe/Berlin ENABLE_SPAMASSASSIN=1 @@ -27,29 +16,20 @@ ENABLE_POSTGREY=1 ENABLE_SASLAUTHD=0 ONE_DIR=1 TLS_LEVEL=modern -POSTMASTER_ADDRESS=admin@leene.dev ENABLE_UPDATE_CHECK=1 - SSL_TYPE=letsencrypt ## SQL Server Env - POSTGRES_USER="pgadmin" POSTGRES_INITDB_ARGS="--auth-host=scram-sha-256 --auth-local=scram-sha-256" ## Round Cube Env - ROUNDCUBEMAIL_DB_TYPE=pgsql ROUNDCUBEMAIL_DB_NAME=roundcube ROUNDCUBEMAIL_DB_USER=roundcube ROUNDCUBEMAIL_SKIN=elastic -ROUNDCUBEMAIL_DEFAULT_HOST=tls://zathura.leene.dev -ROUNDCUBEMAIL_SMTP_SERVER=tls://zathura.leene.dev ROUNDCUBEMAIL_ASPELL_DICTS=en ## NGINX Reverse Proxy - -NGINX_HOST=zathura.leene.dev NGINX_PROXY_CONTAINER=nginx-proxy LETSENCRYPT_RESTART_CONTAINER=true -DEFAULT_EMAIL=lieuwe@leene.dev From 8d85d5b10be49bc7125c0a76346264ce71c626b0 Mon Sep 17 00:00:00 2001 From: Lieuwe Leene Date: Sun, 13 Nov 2022 11:46:27 +0100 Subject: [PATCH 14/19] WIP --- TODO.md | 4 ++++ docker-compose.yaml | 20 ++++++++++---------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/TODO.md b/TODO.md index f361f7a..d8d2918 100644 --- a/TODO.md +++ b/TODO.md @@ -1,3 +1,7 @@ +# Config + + - Set correct domain-names in config/nginx locations + # Startup - Update accounts diff --git a/docker-compose.yaml b/docker-compose.yaml index ac42762..12543fd 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -120,16 +120,6 @@ services: depends_on: - ddnsgd - ddnsgd: - <<: *defaults - container_name: "ddnsgd" - image: "ghcr.io/dominickbrasileiro/ddnsgd" - restart: "always" - environment: - - HOSTNAME=${NGINX_HOST} - - USERNAME=${DNS_USERNAME} - - PASSWORD=${DNS_PASSWORD} - acme-companion: <<: *defaults image: nginxproxy/acme-companion @@ -143,6 +133,16 @@ services: depends_on: - ddnsgd + ddnsgd: + <<: *defaults + container_name: "ddnsgd" + image: "ghcr.io/dominickbrasileiro/ddnsgd" + restart: "always" + environment: + - HOSTNAME=${NGINX_HOST} + - USERNAME=${DNS_USERNAME} + - PASSWORD=${DNS_PASSWORD} + volumes: acme-state: From ef88c67176b0609a1def8138f48b8aa87f04e5c5 Mon Sep 17 00:00:00 2001 From: Lieuwe Leene Date: Mon, 14 Nov 2022 16:02:40 +0100 Subject: [PATCH 15/19] WIP adding hugo page --- config/hugo/configure | 13 +++++++++++++ docker-compose.yaml | 34 +++++++++++++++++++++++----------- 2 files changed, 36 insertions(+), 11 deletions(-) create mode 100644 config/hugo/configure diff --git a/config/hugo/configure b/config/hugo/configure new file mode 100644 index 0000000..95296d3 --- /dev/null +++ b/config/hugo/configure @@ -0,0 +1,13 @@ +server { + listen ${VIRTUAL_PORT}; + listen [::]:${VIRTUAL_PORT}; + server_name ${VIRTUAL_HOST}; + location / { + root /usr/share/nginx/html; + index index.html index.htm; + } + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } +} diff --git a/docker-compose.yaml b/docker-compose.yaml index 12543fd..bb0979d 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -14,6 +14,22 @@ x-mail: &defaults services: + hugo-site: + <<: *defaults + container_name: hugo-site + image: nginx:alpine + environment: + - VIRTUAL_HOST=lieuwe.${NGINX_HOST} + - VIRTUAL_PORT=6262 + - VIRTUAL_PROTO=http + - LETSENCRYPT_HOST=lieuwe.${NGINX_HOST} + volumes: + - ./config/hugo/public:/usr/share/nginx/html:ro,z + - ./config/hugo/configure:/etc/nginx/templates/default.conf.template:ro,z + restart: always + expose: + - "6262" + pgsqlserver: <<: *defaults container_name: pgsqlserver @@ -23,7 +39,7 @@ services: - POSTGRES_PASSWORD=${SQL_PSWD} volumes: - sql_data:/var/lib/postgresql/data/:z - - ./config/pg-init-scripts:/docker-entrypoint-initdb.d:ro + - ./config/pg-init-scripts:/docker-entrypoint-initdb.d:ro,z restart: always expose: - "5432" @@ -39,8 +55,6 @@ services: - LETSENCRYPT_HOST=git.${NGINX_HOST} volumes: - gitea_data:/data:z - - /etc/timezone:/etc/timezone:ro - - /etc/localtime:/etc/localtime:ro expose: - "3000" ports: @@ -87,11 +101,10 @@ services: - "587:587" - "993:993" volumes: - - nginx_certs:/etc/letsencrypt/live:ro + - nginx_certs:/etc/letsencrypt/live/:ro,z - mail_data:/var/mail/:z - mail_state:/var/mail-state/:z - mail_config:/tmp/docker-mailserver/:z - - /etc/localtime:/etc/localtime:ro cap_add: - NET_ADMIN depends_on: @@ -109,14 +122,14 @@ services: - "80:80" - "443:443" volumes: + - nginx_html:/usr/share/nginx/html:z + - nginx_conf:/etc/nginx/conf.d/:z - nginx_dhparam:/etc/nginx/dhparam:z - nginx_certs:/etc/nginx/certs/:z - - nginx_conf:/etc/nginx/conf.d/:z - nginx_vhost:/etc/nginx/vhost.d/:z - - nginx_html:/usr/share/nginx/html:z - mail_html:/var/www/roundcube:z - - ./config/nginx/inbox_location:/etc/nginx/vhost.d/inbox.${NGINX_HOST}_location:z - - /var/run/docker.sock:/tmp/docker.sock:z + - ./config/nginx/inbox_location:/etc/nginx/vhost.d/inbox.${NGINX_HOST}_location:ro,z + - /var/run/docker.sock:/tmp/docker.sock:ro,z depends_on: - ddnsgd @@ -129,7 +142,7 @@ services: - reverse-proxy volumes: - acme-state:/etc/acme.sh - - /var/run/docker.sock:/var/run/docker.sock:z + - /var/run/docker.sock:/var/run/docker.sock:ro,z depends_on: - ddnsgd @@ -143,7 +156,6 @@ services: - USERNAME=${DNS_USERNAME} - PASSWORD=${DNS_PASSWORD} - volumes: acme-state: gitea_data: From e26aff43bc0e13f32de934646fb5cb897576269c Mon Sep 17 00:00:00 2001 From: Lieuwe Leene Date: Sat, 19 Nov 2022 14:44:58 +0100 Subject: [PATCH 16/19] Working setup v1 --- config/hugo/Dockerfile | 30 +++++++++++ config/hugo/configure | 2 +- config/mail/Dockerfile | 14 ----- config/mail/config.php | 19 +++++++ config/nginx/header_default | 17 ++++++ config/nginx/nextcloud_location | 94 +++++++++++++++++++++++++++++++++ docker-compose.yaml | 72 +++++++++++++++++++------ 7 files changed, 216 insertions(+), 32 deletions(-) create mode 100644 config/hugo/Dockerfile delete mode 100644 config/mail/Dockerfile create mode 100644 config/mail/config.php create mode 100644 config/nginx/header_default create mode 100644 config/nginx/nextcloud_location diff --git a/config/hugo/Dockerfile b/config/hugo/Dockerfile new file mode 100644 index 0000000..91b1d97 --- /dev/null +++ b/config/hugo/Dockerfile @@ -0,0 +1,30 @@ +FROM alpine + +LABEL description="Hugo static build process." +LABEL maintainer="Lieuwe Leene " + +ARG HUGO_BASE="localhost" +ARG SSL_ALGO=secp521r1 + +RUN wget -O - "https://github.com/gohugoio/hugo/releases/download/$(wget -O - https://api.github.com/repos/gohugoio/hugo/releases/latest | grep -om 1 "/v[0-9.]*/hugo_[0-9.]*_Linux-64bit.tar.gz")" | tar -xz -C /tmp \ + && mkdir -p /usr/local/sbin \ + && mv /tmp/hugo /usr/local/sbin/hugo \ + && rm -rf /tmp/${HUGO_ID}_linux_amd64 \ + && rm -rf /tmp/LICENSE.md \ + && rm -rf /tmp/README.md + +RUN apk add --update git asciidoctor libc6-compat libstdc++ \ + && apk upgrade \ + && apk add --no-cache ca-certificates \ + && git clone https://github.com/lleene/hugo-site.git /src \ + && git clone https://github.com/lleene/hermit.git /src/themes/hermit \ + && /usr/local/sbin/hugo -b ${BASE_URL}/ -s /src -d /public --minify + +RUN apk update && \ + apk add --no-cache openssl && \ + rm -rf /var/cache/apk/* + +RUN mkdir -p /etc/letsencrypt/live + +RUN openssl ecparam -name ${SSL_ALGO} -genkey | openssl pkey -out /etc/letsencrypt/live/ecprivkey.pem && \ + openssl pkey -in /etc/letsencrypt/live/ecprivkey.pem -pubout -out /etc/letsencrypt/live/ecpubkey.pem diff --git a/config/hugo/configure b/config/hugo/configure index 95296d3..1ed6f47 100644 --- a/config/hugo/configure +++ b/config/hugo/configure @@ -3,7 +3,7 @@ server { listen [::]:${VIRTUAL_PORT}; server_name ${VIRTUAL_HOST}; location / { - root /usr/share/nginx/html; + root /var/www/html; index index.html index.htm; } error_page 500 502 503 504 /50x.html; diff --git a/config/mail/Dockerfile b/config/mail/Dockerfile deleted file mode 100644 index d45ff34..0000000 --- a/config/mail/Dockerfile +++ /dev/null @@ -1,14 +0,0 @@ -FROM alpine - -MAINTAINER Lieuwe Leene - -ARG SSL_ALGO=secp521r1 - -RUN apk update && \ - apk add --no-cache openssl && \ - rm -rf /var/cache/apk/* - -RUN mkdir -p /etc/letsencrypt/live - -RUN openssl ecparam -name ${SSL_ALGO} -genkey | openssl pkey -out /etc/letsencrypt/live/ecprivkey.pem && \ - openssl pkey -in /etc/letsencrypt/live/ecprivkey.pem -pubout -out /etc/letsencrypt/live/ecpubkey.pem diff --git a/config/mail/config.php b/config/mail/config.php new file mode 100644 index 0000000..255a148 --- /dev/null +++ b/config/mail/config.php @@ -0,0 +1,19 @@ + array( + 'verify_peer' => false, + 'verify_peer_name' => false, + 'allow_self_signed' => true, + ), + ); + + $config['smtp_conn_options'] = array( + 'ssl' => array( + 'verify_peer' => false, + 'verify_peer_name' => false, + 'allow_self_signed' => true, + ), + ); \ No newline at end of file diff --git a/config/nginx/header_default b/config/nginx/header_default new file mode 100644 index 0000000..53a7e80 --- /dev/null +++ b/config/nginx/header_default @@ -0,0 +1,17 @@ +## Start of configuration add by letsencrypt container +location ^~ /.well-known/acme-challenge/ { + auth_basic off; + auth_request off; + allow all; + root /usr/share/nginx/html; + try_files $uri =404; + break; +} +## End of configuration add by letsencrypt container +add_header Referrer-Policy "no-referrer" always; +add_header X-Content-Type-Options "nosniff" always; +add_header X-Download-Options "noopen" always; +add_header X-Frame-Options "SAMEORIGIN" always; +add_header X-Permitted-Cross-Domain-Policies "none" always; +add_header X-Robots-Tag "none" always; +add_header X-XSS-Protection "1; mode=block" always; \ No newline at end of file diff --git a/config/nginx/nextcloud_location b/config/nginx/nextcloud_location new file mode 100644 index 0000000..aa6ec63 --- /dev/null +++ b/config/nginx/nextcloud_location @@ -0,0 +1,94 @@ +root /var/www/nextcloud; +index index.php index.html index.htm; + +# set max upload size +client_max_body_size 512M; +fastcgi_buffers 64 4K; + +# Enable gzip but do not remove ETag headers +gzip on; +gzip_vary on; +gzip_comp_level 4; +gzip_min_length 256; +gzip_proxied expired no-cache no-store private no_last_modified no_etag auth; +gzip_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy; + +location = /robots.txt { + allow all; + log_not_found off; + access_log off; +} + +location = /.well-known/carddav { + return 301 $scheme://$host:$server_port/remote.php/dav; +} +location = /.well-known/caldav { + return 301 $scheme://$host:$server_port/remote.php/dav; +} + +location / { + rewrite ^ /index.php; +} + +location ~ ^\/(?:build|tests|config|lib|3rdparty|templates|data)\/ { + deny all; +} +location ~ ^\/(?:\.|autotest|occ|issue|indie|db_|console) { + deny all; +} + +location ~ ^\/(?:index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|oc[ms]-provider\/.+|.+\/richdocumentscode\/proxy)\.php(?:$|\/) { + fastcgi_split_path_info ^(.+?\.php)(\/.*|)$; + set $path_info $fastcgi_path_info; + try_files $fastcgi_script_name =404; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param PATH_INFO $path_info; + fastcgi_param HTTPS on; + # Avoid sending the security headers twice + fastcgi_param modHeadersAvailable true; + # Enable pretty urls + fastcgi_param front_controller_active true; + fastcgi_pass nextcloud.zathura.leene.dev; + fastcgi_intercept_errors on; + fastcgi_request_buffering off; +} + +location ~ ^\/(?:updater|oc[ms]-provider)(?:$|\/) { + try_files $uri/ =404; + index index.php; +} + +# Adding the cache control header for js, css and map files +# Make sure it is BELOW the PHP block +location ~ \.(?:css|js|woff2?|svg|gif|map)$ { + try_files $uri /index.php$request_uri; + add_header Cache-Control "public, max-age=15778463"; + # Add headers to serve security related headers (It is intended to + # have those duplicated to the ones above) + # Before enabling Strict-Transport-Security headers please read into + # this topic first. + #add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;" always; + # + # WARNING: Only add the preload option once you read about + # the consequences in https://hstspreload.org/. This option + # will add the domain to a hardcoded list that is shipped + # in all major browsers and getting removed from this list + # could take several months. + add_header Referrer-Policy "no-referrer" always; + add_header X-Content-Type-Options "nosniff" always; + add_header X-Download-Options "noopen" always; + add_header X-Frame-Options "SAMEORIGIN" always; + add_header X-Permitted-Cross-Domain-Policies "none" always; + add_header X-Robots-Tag "none" always; + add_header X-XSS-Protection "1; mode=block" always; + + # Optional: Don't log access to assets + access_log off; +} + +location ~ \.(?:png|html|ttf|ico|jpg|jpeg|bcmap|mp4|webm)$ { + try_files $uri /index.php$request_uri; + # Optional: Don't log access to other assets + access_log off; +} \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml index bb0979d..035eb66 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -3,52 +3,89 @@ version: "3.8" networks: internalnet: - driver: bridge - enable_ipv6: false + # driver: bridge + # enable_ipv6: false x-mail: &defaults + restart: always env_file: local.env networks: - internalnet services: + hugo-html: + container_name: hugo-html + build: + context: ./config/hugo + args: + HUGO_BASE: lieuwe.${NGINX_HOST} + volumes: + - hugo_data:/public:z + - nginx_certs:/etc/letsencrypt/live:z hugo-site: <<: *defaults container_name: hugo-site image: nginx:alpine environment: - - VIRTUAL_HOST=lieuwe.${NGINX_HOST} - VIRTUAL_PORT=6262 - VIRTUAL_PROTO=http + - VIRTUAL_HOST=lieuwe.${NGINX_HOST} - LETSENCRYPT_HOST=lieuwe.${NGINX_HOST} volumes: - - ./config/hugo/public:/usr/share/nginx/html:ro,z + - hugo_data:/var/www/html:ro,z - ./config/hugo/configure:/etc/nginx/templates/default.conf.template:ro,z - restart: always - expose: - - "6262" + ports: + - "6262:6262" pgsqlserver: <<: *defaults container_name: pgsqlserver image: postgres:15 environment: - - POSTGRES_MULTIPLE_DATABASES=gitea, roundcube + - POSTGRES_MULTIPLE_DATABASES=gitea, roundcube, nextcloud - POSTGRES_PASSWORD=${SQL_PSWD} volumes: - sql_data:/var/lib/postgresql/data/:z - ./config/pg-init-scripts:/docker-entrypoint-initdb.d:ro,z - restart: always + ports: + - "5432:5432" + + nextcloud: + <<: *defaults + image: nextcloud:fpm + container_name: nextcloud + environment: + - VIRTUAL_HOST=nextcloud.${NGINX_HOST} + - VIRTUAL_PORT=9000 + - LETSENCRYPT_HOST=nextcloud.${NGINX_HOST} + - POSTGRES_HOST=pgsqlserver + - POSTGRES_PORT=5432 + - POSTGRES_DB=nextcloud + - POSTGRES_USER=nextcloud + - POSTGRES_PASSWORD=${SQL_PSWD} + - NEXTCLOUD_TRUSTED_DOMAINS=nextcloud.${NGINX_HOST} + - NEXTCLOUD_ADMIN_USER=penny + - NEXTCLOUD_ADMIN_PASSWORD=${SQL_PSWD} + - SMTP_HOST=mailserver + - SMTP_SECURE=tls + - SMTP_NAME=admin@${NGINX_HOST} + - SMTP_PASSWORD=${SQL_PSWD} + depends_on: + - pgsqlserver + links: + - pgsqlserver expose: - - "5432" + - "9000" + volumes: + - nextcloud_data:/var/www/html:z + - nextcloud_data:/var/www/nextcloud:z gitea: <<: *defaults container_name: gitea image: gitea/gitea - restart: always environment: - VIRTUAL_HOST=git.${NGINX_HOST} - VIRTUAL_PORT=3000 @@ -85,9 +122,9 @@ services: volumes: - mail_html:/var/www/html:z - mail_html:/var/www/roundcube:z + - ./config/mail/config.php:/var/roundcube/config/${NGINX_HOST}.php:ro,z mailserver: - build: ./config/mail <<: *defaults image: mailserver/docker-mailserver:latest container_name: mailserver @@ -101,7 +138,7 @@ services: - "587:587" - "993:993" volumes: - - nginx_certs:/etc/letsencrypt/live/:ro,z + - nginx_certs:/etc/letsencrypt/live:ro,z - mail_data:/var/mail/:z - mail_state:/var/mail-state/:z - mail_config:/tmp/docker-mailserver/:z @@ -109,13 +146,11 @@ services: - NET_ADMIN depends_on: - ddnsgd - restart: always reverse-proxy: <<: *defaults image: nginxproxy/nginx-proxy container_name: nginx-proxy - restart: always environment: - DEFAULT_EMAIL=admin@${NGINX_HOST} ports: @@ -128,7 +163,10 @@ services: - nginx_certs:/etc/nginx/certs/:z - nginx_vhost:/etc/nginx/vhost.d/:z - mail_html:/var/www/roundcube:z + - nextcloud_data:/var/www/nextcloud:z - ./config/nginx/inbox_location:/etc/nginx/vhost.d/inbox.${NGINX_HOST}_location:ro,z + - ./config/nginx/nextcloud_location:/etc/nginx/vhost.d/nextcloud.${NGINX_HOST}_location:ro,z + - ./config/nginx/header_default:/etc/nginx/vhost.d/default:z - /var/run/docker.sock:/tmp/docker.sock:ro,z depends_on: - ddnsgd @@ -137,7 +175,6 @@ services: <<: *defaults image: nginxproxy/acme-companion container_name: nginx-proxy-acme - restart: always volumes_from: - reverse-proxy volumes: @@ -150,7 +187,6 @@ services: <<: *defaults container_name: "ddnsgd" image: "ghcr.io/dominickbrasileiro/ddnsgd" - restart: "always" environment: - HOSTNAME=${NGINX_HOST} - USERNAME=${DNS_USERNAME} @@ -159,6 +195,8 @@ services: volumes: acme-state: gitea_data: + hugo_data: + nextcloud_data: nginx_certs: nginx_dhparam: nginx_html: From 1d08397182ab1c24e5fc9d27b22a470442a7f3e7 Mon Sep 17 00:00:00 2001 From: Lieuwe Leene Date: Sat, 19 Nov 2022 14:47:46 +0100 Subject: [PATCH 17/19] WIP: minor update --- TODO.md | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/TODO.md b/TODO.md index d8d2918..2c86692 100644 --- a/TODO.md +++ b/TODO.md @@ -1,13 +1,6 @@ -# Config - - Set correct domain-names in config/nginx locations +# Startup after docker compose -# Startup + - Create admin email account + - Update dkim and DNS records - - Update accounts - - Update dkim - -# Compose - - - Include Hugo in build - - Include nextcloud in build From 9c56e5359c158b4f616ffad7cd2ea2478dee6e39 Mon Sep 17 00:00:00 2001 From: Lieuwe Leene Date: Sat, 19 Nov 2022 18:55:06 +0100 Subject: [PATCH 18/19] WIP: need to include SMTP relay --- config/nginx/header_default | 10 ---------- docker-compose.yaml | 19 +++++++++++++++++++ local.env | 4 +++- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/config/nginx/header_default b/config/nginx/header_default index 53a7e80..971b5d0 100644 --- a/config/nginx/header_default +++ b/config/nginx/header_default @@ -1,13 +1,3 @@ -## Start of configuration add by letsencrypt container -location ^~ /.well-known/acme-challenge/ { - auth_basic off; - auth_request off; - allow all; - root /usr/share/nginx/html; - try_files $uri =404; - break; -} -## End of configuration add by letsencrypt container add_header Referrer-Policy "no-referrer" always; add_header X-Content-Type-Options "nosniff" always; add_header X-Download-Options "noopen" always; diff --git a/docker-compose.yaml b/docker-compose.yaml index 035eb66..e3efdba 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -192,6 +192,25 @@ services: - USERNAME=${DNS_USERNAME} - PASSWORD=${DNS_PASSWORD} + autodiscover: + image: monogramm/autodiscover-email-settings:latest + container_name: autodiscover + environment: + - VIRTUAL_HOST=autodiscover.${NGINX_HOST},autoconfig.${NGINX_HOST} + - VIRTUAL_PORT=8000 + - DOMAIN=${NGINX_HOST} + - IMAP_HOST=mail.${NGINX_HOST} + - IMAP_PORT=993 + - IMAP_SOCKET=SSL + - POP_HOST=mail.${NGINX_HOST} + - POP_PORT=995 + - POP_SOCKET=SSL + - SMTP_HOST=mail.${NGINX_HOST} + - SMTP_PORT=587 + - SMTP_SOCKET=STARTTLS + expose: + - "8000" + volumes: acme-state: gitea_data: diff --git a/local.env b/local.env index 1d03bf8..1074543 100644 --- a/local.env +++ b/local.env @@ -10,7 +10,6 @@ TZ=Europe/Berlin ENABLE_SPAMASSASSIN=1 SPAMASSASSIN_SPAM_TO_INBOX=1 ENABLE_CLAMAV=1 -ENABLE_DNSBL=1 ENABLE_FAIL2BAN=1 ENABLE_POSTGREY=1 ENABLE_SASLAUTHD=0 @@ -18,6 +17,9 @@ ONE_DIR=1 TLS_LEVEL=modern ENABLE_UPDATE_CHECK=1 SSL_TYPE=letsencrypt +SPOOF_PROTECTION=1 +ENABLE_POP3=1 +ENABLE_DNSBL=1 ## SQL Server Env POSTGRES_USER="pgadmin" From 3f24bbeca4a332c67d371ef5c4333d2823ed4a73 Mon Sep 17 00:00:00 2001 From: Lieuwe Leene Date: Sun, 20 Nov 2022 13:53:21 +0100 Subject: [PATCH 19/19] Working autoconfig setup with SMTP relay --- .env.example | 7 +++++-- config/nginx/header_default | 10 ++++++++++ docker-compose.yaml | 13 +++++++++---- local.env | 9 ++++++++- 4 files changed, 32 insertions(+), 7 deletions(-) diff --git a/.env.example b/.env.example index 97ac53c..5b058a6 100644 --- a/.env.example +++ b/.env.example @@ -2,8 +2,11 @@ NGINX_HOST="" # GOOGLE DNS API TOKEN -DNS_USERNAME="" -DNS_PASSWORD="" +GDNS_USERNAME="" +GDNS_PASSWORD="" # COMMON DB PASSWORD SQL_PSWD="" + +# SENDGRID Relay API Key +SENDGRID_APIKEY="" diff --git a/config/nginx/header_default b/config/nginx/header_default index 971b5d0..53a7e80 100644 --- a/config/nginx/header_default +++ b/config/nginx/header_default @@ -1,3 +1,13 @@ +## Start of configuration add by letsencrypt container +location ^~ /.well-known/acme-challenge/ { + auth_basic off; + auth_request off; + allow all; + root /usr/share/nginx/html; + try_files $uri =404; + break; +} +## End of configuration add by letsencrypt container add_header Referrer-Policy "no-referrer" always; add_header X-Content-Type-Options "nosniff" always; add_header X-Download-Options "noopen" always; diff --git a/docker-compose.yaml b/docker-compose.yaml index e3efdba..24278e0 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -3,8 +3,8 @@ version: "3.8" networks: internalnet: - # driver: bridge - # enable_ipv6: false + driver: bridge + enable_ipv6: false x-mail: &defaults @@ -15,6 +15,8 @@ x-mail: &defaults services: hugo-html: + networks: + - internalnet container_name: hugo-html build: context: ./config/hugo @@ -132,6 +134,7 @@ services: domainname: ${NGINX_HOST} environment: - POSTMASTER_ADDRESS=admin@${NGINX_HOST} + - RELAY_PASSWORD=${SENDGRID_APIKEY} ports: - "25:25" - "143:143" @@ -189,15 +192,17 @@ services: image: "ghcr.io/dominickbrasileiro/ddnsgd" environment: - HOSTNAME=${NGINX_HOST} - - USERNAME=${DNS_USERNAME} - - PASSWORD=${DNS_PASSWORD} + - USERNAME=${GDNS_USERNAME} + - PASSWORD=${GDNS_PASSWORD} autodiscover: + <<: *defaults image: monogramm/autodiscover-email-settings:latest container_name: autodiscover environment: - VIRTUAL_HOST=autodiscover.${NGINX_HOST},autoconfig.${NGINX_HOST} - VIRTUAL_PORT=8000 + - LETSENCRYPT_HOST=autodiscover.${NGINX_HOST},autoconfig.${NGINX_HOST} - DOMAIN=${NGINX_HOST} - IMAP_HOST=mail.${NGINX_HOST} - IMAP_PORT=993 diff --git a/local.env b/local.env index 1074543..6514343 100644 --- a/local.env +++ b/local.env @@ -19,7 +19,14 @@ ENABLE_UPDATE_CHECK=1 SSL_TYPE=letsencrypt SPOOF_PROTECTION=1 ENABLE_POP3=1 -ENABLE_DNSBL=1 +POSTSCREEN_ACTION=ignore +ENABLE_DNSBL=0 +ENABLE_QUOTAS=0 + +RELAY_HOST=smtp.sendgrid.net +RELAY_PORT=587 +RELAY_USER=apikey + ## SQL Server Env POSTGRES_USER="pgadmin"