github.com/tommi2day/gomodules@v1.13.2-0.20240423190010-b7d55d252a27/test/docker/mail/start_mailserver.sh (about)

     1  #!/bin/bash
     2  
     3  WD=$(pwd)
     4  
     5  NAME=mailserver
     6  DOMAIN=test.local
     7  HOSTNAME=mail
     8  
     9  docker rm -f  $NAME
    10  rm -rf config ssl
    11  mkdir config ssl
    12  # '--user' is to keep ownership of the files written to
    13  # the local volume to use your systems User and Group ID values.
    14  docker run --rm -it \
    15    --user "$(id -u):$(id -g)" \
    16    --volume "${WD}/gen_certs.sh:/tmp/gen_certs.sh:ro" \
    17    --volume "${WD}:/tmp/step-ca/" \
    18    --workdir "/tmp/step-ca/" \
    19    -e SERVER=$HOSTNAME \
    20    -e DOMAIN=$DOMAIN \
    21    -e SSLDIR=ssl \
    22    --entrypoint "/tmp/gen_certs.sh" \
    23    smallstep/step-ca
    24  
    25  
    26  docker run -d \
    27    --name $NAME \
    28    --hostname $HOSTNAME \
    29    --domainname $DOMAIN \
    30    -e PERMIT_DOCKER=network \
    31    -e LOG_LEVEL=debug \
    32    -e ONE_FILE=1 \
    33    -e TZ=UTC \
    34    -e ENABLE_OPENDKIM=0 \
    35    -e ENABLE_OPENDMARC=0 \
    36    -e ENABLE_AMAVIS=0 \
    37    -e SSL_TYPE=manual \
    38    -e SSL_CERT_PATH=/tmp/dms/custom-certs/${HOSTNAME}.${DOMAIN}-full.crt\
    39    -e SSL_KEY_PATH=/tmp/dms/custom-certs/${HOSTNAME}.${DOMAIN}.key \
    40    -v $WD/ssl:/tmp/dms/custom-certs/:ro \
    41    -v $WD/config:/tmp/docker-mailserver/ \
    42    -p 1025:25 \
    43    -p 1110:110 \
    44    -p 1143:143 \
    45    -p 1465:465 \
    46    -p 1587:587 \
    47    -p 1993:993 \
    48    docker.io/mailserver/docker-mailserver:latest
    49  
    50  docker exec -it mailserver setup email add root@$DOMAIN testpass
    51  docker exec -it mailserver setup email add info@$DOMAIN testpass
    52  docker exec -it mailserver setup alias add postmaster@$DOMAIN root@$DOMAIN