Test Setups and Examples

We do not suggest that you use the containers and setups provided on this page for your local PhraseApp Enterprise setup without thoroughly reviewing them. They could not comply with your organization’s infrastructure standards and are purely meant as an inspiration for potential setups or for test setups within your development team.

Installing Docker

Please refer to the Docker documentation for installation guides specific for your host system.

If available for your OS, you may be able to use docker-machine for testing.

Retrieving the local Docker host IP

When the docker host is running, you should be able to list running containers:

docker ps

If this is not possible and you’re using docker-machine, try:

docker-machine ls

And start the default docker-machine:

docker-machine start default

After setting the environment:

eval "$(docker-machine env default)"

You should be able to retrieve your DOCKER_IP by taking the IP from the $DOCKER_HOST environment variable:

echo $DOCKER_HOST

Or, if Ruby is at hand:

export DOCKER_IP=$(env|grep DOCKER_HOST|ruby -pe '$_=$_.split("://").last.split(":").first')

Make sure that neither $DOCKER_HOST nor $DOCKER_IP are empty:

echo $DOCKER_HOST
// e.g. tcp://192.168.99.100:2376
echo $DOCKER_IP
// e.g. 192.168.99.100

Providing external services on the same Docker host

If any of these commands is stuck for a longer period (no progress in downloading image from docker.io or similar): Try to verify that you can access docker.io.

  1. Install Elasticsearch and run inside container

     docker run -d --name=elasticsearch -p 9200:9200 \
       -v /data/docker/elasticsearch:/data elasticsearch:1.7.2
    
  2. Install MySQL and run inside container with mounted directory on Docker host

     docker run -d --name mysql -v /data/docker/mysql:/var/lib/mysql \
       -e MYSQL_ALLOW_EMPTY_PASSWORD=true -p 3306:3306 mysql:5.6.27
    

    Signing in to the MySQL:

     mysql -u root -h $DOCKER_IP
    

    Creating a database for PhraseApp Enterprise:

     CREATE DATABASE phraseapp DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
    

    The new DATABASE_URL for PhraseApp Enterprise running on the same Docker host is:

     mysql2://root@$DOCKER_IP:3306/phraseapp?local_infile=1
    
  3. Install Redis server and run inside container

     docker run -d --name=redis -p 6379:6379 \
       -v /data/docker/redis:/data redis:3.0.4
    

Set up a local testing environment for email sending

  1. Clone Mailcatcher Repository

     git clone https://github.com/sj26/mailcatcher
    
  2. Go into mailcatcher directory and build Docker image

     cd mailcatcher
     docker build -t mailcatcher:20160101 .
    

    Note $IMAGE_ID of created Docker image.

  3. Run mailcatcher in local Docker container

     docker run -d -p 1080:1080 -p 1025:1025 $IMAGE_ID
    

    You can now use this for testing of mail delivery through PhraseApp Enterprise with the following environment variables (replace $DOCKER_IP with your actual Docker IP:

     MAIL_RAISE_DELIVERY_ERRORS=0
     MAIL_ADDRESS=$DOCKER_IP
     MAIL_PORT=1025
     MAIL_ENABLE_STARTTLS_AUTO=0
     MAIL_USER_NAME=
     MAIL_PASSWORD=
     MAIL_AUTHENTICATION=plain
     MAIL_DEFAULT_SENDER_ADDRESS=phraseapp@mycompany.tld
     MAIL_DOMAIN=mycompany.tld
    

    You can see the mails sent to this test SMTP server by pointing your web browser to http://$DOCKER_IP:1080.

Using a web server as proxy on the Docker host

This is only meant as an illustration and is not necessary for local testing.

  1. Install nginx

     apt-get update
     apt-get install nginx
    
  2. Add a similar nginx.conf to this one:

     upstream phraseapp_upstream{
         server 0.0.0.0:8080;
     }
    	
     server {
         listen 80;
         server_name phraseapp.mycompany.tld;
    		
         location / {
                 proxy_http_version 1.1;
                 proxy_set_header Host $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;
                 proxy_pass http://phraseapp_upstream;
         }
     }
    

SSL Termination

  1. Install nginx as in web server proxy guide above

  2. Create a local private key and purchase a SSL certificate for the domain name you want to use

  3. Adapt your nginx.conf similar to this one:

     upstream phraseapp_upstream{
         server 0.0.0.0:8080;
     }
    	
     server {
         listen 80;
         server_name phraseapp.mycompany.tld
         return 301 https://phraseapp.mycompany.tld/$request_uri;
     }
    	
     server {
         listen 443 ssl;
         server_name phraseapp.mycompany.tld;
    		
         ssl_certificate phraseapp.mycompany.tld.crt;
         ssl_certificate_key phraseapp.mycompany.tld.key;
         ssl_prefer_server_ciphers On;
         ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
         ssl_ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS;
    		
         location / {
                 proxy_http_version 1.1;
                 proxy_set_header Host $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;
                 proxy_pass http://phraseapp_upstream;
         }
     }
    

    For more information on a web server setup with SSL termination, see Nginx documentation.