inovector / mixpost

Mixpost - Self-hosted social media management software (Buffer alternative)
https://mixpost.app
MIT License
905 stars 145 forks source link

Message": "no app for hostname" #43

Closed ovizii closed 1 year ago

ovizii commented 1 year ago

Detailed description

Hi there,

trying to get started with this app, I am trying to get it runnign via docker-compose.yml

My latest try gives this error message in the browser when accessing it:

{
    "Message": "no app for hostname",
    "Host": "sub.domain.tld",
    "Detail": "Check the outpost settings and make sure 'sub.domain.tld' is included."
}

which seems weird as my docker compose seems to contain that: sub.domain.tld

    mixpost:                                                                                                                                         
        image: inovector/mixpost:latest                                                                                                              
        container_name: mixpost                                                                                                                      
        hostname: mixpost                                                                                                                            
        environment:                                                                                                                                 
            - APP_NAME=Mixpost                                                                                                                       
            - APP_KEY=${APP_KEY}                                                                                                                     
            - APP_URL=https://sub.domain.tld                                                                                                       
            - DB_DATABASE=${DB_DATABASE} 

Any ideas what could be wrong here?

lao9s commented 1 year ago

It does not seem to be an error from the application. It's probably an error from your server. Can you provide more details about the server?

ovizii commented 1 year ago

Thanks for the pointer, it was indeed my fault. I made a mistake when routing from the reverse proxy.

I corrected it, restarted the stack and made it to the mixpost login screen. I then realized, I have to find the login admin password from the container logs and couldn't spot anything in the logs.

So I emptied all volumes of the stack and started the stack up again and kept watch on the logs but now the stack doesn't come up again even though all I did was empty the volumes and restart.

If you have any ideas please let me know, I'll keep trying to figure it out on my end. While typing this, "things happened" and I see the login screen again but still nothing about any admin password to be seen in the logs.

I can share my final docker-compose.yml and .env file if you like? It looks like it can't find the database.

wait-for-it.sh: waiting 60 seconds for mysql:3306
wait-for-it.sh: timeout occurred after waiting 60 seconds for mysql:3306
   INFO  Configuration cached successfully.  
   INFO  Application cache cleared successfully.  
   INFO  Routes cached successfully.  
wait-for-it.sh: waiting 60 seconds for mysql:3306
wait-for-it.sh: timeout occurred after waiting 60 seconds for mysql:3306
   Illuminate\Database\QueryException 
  SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo for mysql failed: Name or service not known (Connection: mysql, SQL: select * from information_schema.tables where table_schema = mixpost and table_name = migrations and table_type = 'BASE TABLE')
  at vendor/laravel/framework/src/Illuminate/Database/Connection.php:760
    756▕         // If an exception occurs when attempting to run a query, we'll format the error
    757▕         // message to include the bindings with SQL, which will make this exception a
    758▕         // lot more helpful to the developer instead of just the database's errors.
    759▕         catch (Exception $e) {
  ➜ 760▕             throw new QueryException(
    761▕                 $this->getName(), $query, $this->prepareBindings($bindings), $e
    762▕             );
    763▕         }
    764▕     }
      +38 vendor frames 
  39  artisan:35
      Illuminate\Foundation\Console\Kernel::handle()
   Illuminate\Database\QueryException 
  SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo for mysql failed: Name or service not known (Connection: mysql, SQL: select exists(select * from `users` where `email` = admin@admin.com) as `exists`)
  at vendor/laravel/framework/src/Illuminate/Database/Connection.php:760
    756▕         // If an exception occurs when attempting to run a query, we'll format the error
    757▕         // message to include the bindings with SQL, which will make this exception a
    758▕         // lot more helpful to the developer instead of just the database's errors.
    759▕         catch (Exception $e) {
  ➜ 760▕             throw new QueryException(
    761▕                 $this->getName(), $query, $this->prepareBindings($bindings), $e
    762▕             );
    763▕         }
    764▕     }
      +31 vendor frames 
  32  artisan:35
      Illuminate\Foundation\Console\Kernel::handle()
 * Starting periodic command scheduler cron
   ...done.
Mixpost has started!
2023-04-05 18:29:47,601 INFO Set uid to user 0 succeeded
2023-04-05 18:29:47,603 INFO supervisord started with pid 62
2023-04-05 18:29:48,605 INFO spawned: 'mixpost_horizon_00' with pid 64
2023-04-05 18:29:48,606 INFO spawned: 'nginx' with pid 65
2023-04-05 18:29:48,608 INFO spawned: 'php-fpm' with pid 66
2023-04-05 18:29:49,656 INFO success: mixpost_horizon_00 entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2023-04-05 18:29:49,657 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2023-04-05 18:29:49,657 INFO success: php-fpm entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2023-04-05 18:29:56,839 INFO exited: mixpost_horizon_00 (exit status 0; expected)
2023-04-05 18:29:57,842 INFO spawned: 'mixpost_horizon_00' with pid 85
2023-04-05 18:29:58,843 INFO success: mixpost_horizon_00 entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2023-04-05 18:30:06,056 INFO exited: mixpost_horizon_00 (exit status 0; expected)
2023-04-05 18:30:07,058 INFO spawned: 'mixpost_horizon_00' with pid 103
2023-04-05 18:30:08,060 INFO success: mixpost_horizon_00 entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2023-04-05 18:30:15,274 INFO exited: mixpost_horizon_00 (exit status 0; expected)
2023-04-05 18:30:16,277 INFO spawned: 'mixpost_horizon_00' with pid 108
2023-04-05 18:30:17,278 INFO success: mixpost_horizon_00 entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2023-04-05 18:30:24,499 INFO exited: mixpost_horizon_00 (exit status 0; expected)
2023-04-05 18:30:25,521 INFO spawned: 'mixpost_horizon_00' with pid 113
2023-04-05 18:30:26,522 INFO success: mixpost_horizon_00 entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2023-04-05 18:30:33,744 INFO exited: mixpost_horizon_00 (exit status 0; expected)
2023-04-05 18:30:34,747 INFO spawned: 'mixpost_horizon_00' with pid 118
2023-04-05 18:30:35,748 INFO success: mixpost_horizon_00 entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2023-04-05 18:30:42,957 INFO exited: mixpost_horizon_00 (exit status 0; expected)
2023-04-05 18:30:43,960 INFO spawned: 'mixpost_horizon_00' with pid 123
ovizii commented 1 year ago

While writing all of this I found the error :-( I forgot to add the DB_HOST variable. I'm so sorry to waste your time.

I'll leave the details below as it shows how to use .env and keep passwords out of the docker-compose.yml as well as an example of running mixpost behind traefik as reverse proxy.

my .env file

APP_KEY=sekretapikey
DB_DATABASE=mixpost                                                                                                                                  
DB_HOST=mixpost-mysql                                                                                                                                
DB_USERNAME=mixpost                                                                                                                                  
DB_PASSWORD=secretdbpassw
REDIS_PASSWORD=secretredispw
REDIS_HOST=mixpost-redis 

my docker-compose.yml

version: '3.9'
# https://inovector.notion.site/Install-Mixpost-Lite-with-Docker-857c3c2abedd4b69a641556c16b7da35

services:

    mixpost:
        image: inovector/mixpost:latest
        container_name: mixpost
        hostname: mixpost
        environment:
            - APP_NAME=Mixpost
            - APP_KEY=${APP_KEY}
            - APP_URL=https://sub.domain.tld
            - DB_DATABASE=${DB_DATABASE}
            - DB_USERNAME=${DB_USERNAME}
            - DB_PASSWORD=${DB_PASSWORD}
            - REDIS_PASSWORD=${REDIS_PASSWORD}
        volumes:
            - ./mixpost-storage:/var/www/html/storage/app
            - ./mixpost-logs:/var/www/html/storage/logs
        depends_on:
            - mixpost-mysql
            - mixpost-redis  
        networks:                                                                                                                                    
          - traefik                                                                                                                                  
          - mixpost
        labels:                                                                                                                                      
          - "traefik.enable=true"                                                                                                                    
          - "traefik.docker.network=traefik"                                                                                                         
          - "traefik.http.routers.mixpost.tls=true"                                                                 
          - "traefik.http.routers.mixpost.entrypoints=websecure"                                                         
          - "traefik.http.routers.mixpost.rule=Host(`sub.domain.tld`)"                                     
          - "traefik.http.routers.mixpost.middlewares=secHeaders@file,localIPsOnly@file"
          - "traefik.http.routers.mixpost.service=mixpost" 
          - "traefik.http.services.mixpost.loadbalancer.server.port=80"

    mixpost-mysql:
        image: mysql/mysql-server:8.0
        container_name: mixpost-mysql
        hostname: mixpost-mysql
        environment:
            - MYSQL_DATABASE=${DB_DATABASE}
            - MYSQL_USER=${DB_USERNAME}
            - MYSQL_PASSWORD=${DB_PASSWORD}
        volumes:
            - ./mixpost-mysql:/var/lib/mysql
        healthcheck:
            test: ["CMD", "mysqladmin", "ping", "-p ${DB_PASSWORD}"]
            retries: 3
            timeout: 5s
        networks:                                                                                                                                    
          - mixpost

    mixpost-redis:
        image: redis:latest
        container_name: mixpost-redis
        hostname: mixpost-redis
        command: redis-server --appendonly yes --replica-read-only no --requirepass "${REDIS_PASSWORD}"
        volumes:
            - ./mixpost-redis:/data
        healthcheck:
            test: ["CMD", "redis-cli", "ping"]
            retries: 3
            timeout: 5s
        networks:                                                                                                                                    
          - mixpost                                                                                                  

networks:                                                                                                                                            
  traefik:                                                                                                                                           
    external: true                                                                                                                                   
    name: traefik                                                                                                                                    
  mixpost:                                                                                                                                            
    external: true                                                                                                                                   
    name: mixpost