Yossi

    Yossi

    2 months ago
    we are a group of 3 developers and we have a shared server/driver that runs the prefect server (its ip is
    10.10.10.255
    ) I am using the following docker-compose.yml (which I got and revised a bit by doing
    prefect server config > docker-compose.yml
    networks:
      prefect-server:
        name: prefect-server
    services:
      apollo:
        command: bash -c "./post-start.sh && npm run serve"
        depends_on:
        - graphql
        - hasura
        environment:
          GRAPHQL_SERVICE_HOST: <http://graphql>
          GRAPHQL_SERVICE_PORT: 4201
          HASURA_API_URL: <http://hasura:3000/v1alpha1/graphql>
          PREFECT_API_HEALTH_URL: <http://graphql:4201/health>
          PREFECT_API_URL: <http://graphql:4201/graphql/>
          PREFECT_SERVER__TELEMETRY__ENABLED: "true"
        healthcheck:
          interval: 10s
          retries: 60
          start_period: 1s
          test: curl --fail --silent "<http://apollo:4200/.well-known/apollo/server-health>"
            &> /dev/null || exit 1
          timeout: 2s
        image: prefecthq/apollo:core-1.2.2
        networks:
          prefect-server: null
        ports:
        - 0.0.0.0:4200:4200/tcp
        restart: always
      graphql:
        command: bash -c "prefect-server database upgrade -y && python src/prefect_server/services/graphql/server.py"
        depends_on:
        - hasura
        environment:
          PREFECT_CORE_VERSION: 1.2.2
          PREFECT_SERVER_DB_CMD: prefect-server database upgrade -y
          PREFECT_SERVER__DATABASE__CONNECTION_URL: <postgresql://prefect>:test-password@postgres:5432/prefect_server
          PREFECT_SERVER__HASURA__ADMIN_SECRET: hasura-secret-admin-secret
          PREFECT_SERVER__HASURA__HOST: hasura
        healthcheck:
          interval: 20s
          retries: 60
          start_period: 1s
          test: curl --fail --silent "<http://graphql:4201/health>" &> /dev/null || exit
            1
          timeout: 2s
        image: prefecthq/server:core-1.2.2
        networks:
          prefect-server: null
        ports:
        - 0.0.0.0:4201:4201/tcp
        restart: always
      hasura:
        command: graphql-engine serve
        depends_on:
        - postgres
        environment:
          HASURA_GRAPHQL_DATABASE_URL: <postgresql://prefect>:test-password@postgres:5432/prefect_server
          HASURA_GRAPHQL_ENABLE_CONSOLE: "true"
          HASURA_GRAPHQL_LOG_LEVEL: warn
          HASURA_GRAPHQL_QUERY_PLAN_CACHE_SIZE: 100
          HASURA_GRAPHQL_SERVER_PORT: '3000'
          HASURA_GRAPHQL_V1_BOOLEAN_NULL_COLLAPSE: "true"
        healthcheck:
          interval: 10s
          retries: 60
          start_period: 1s
          test: wget -O - <http://hasura>:$${HASURA_GRAPHQL_SERVER_PORT}/healthz &>/dev/null
            || exit 1
          timeout: 2s
        image: hasura/graphql-engine:v2.1.1
        init: true
        networks:
          prefect-server: null
        ports:
        - 0.0.0.0:3000:3000/tcp
        restart: always
      postgres:
        command:
        - postgres
        - -c
        - max_connections=150
        environment:
          POSTGRES_DB: prefect_server
          POSTGRES_PASSWORD: test-password
          POSTGRES_USER: prefect
        healthcheck:
          interval: 10s
          retries: 60
          start_period: 2s
          test: pg_isready -q -d $${POSTGRES_DB} -U $${POSTGRES_USER} || exit 1
          timeout: 2s
        image: postgres:11
        networks:
          prefect-server: null
        ports:
        - 0.0.0.0:5432:5432/tcp
        restart: always
      towel:
        command: python src/prefect_server/services/towel/__main__.py
        depends_on:
        - graphql
        environment:
          PREFECT_SERVER__HASURA__ADMIN_SECRET: hasura-secret-admin-secret
          PREFECT_SERVER__HASURA__HOST: hasura
        image: prefecthq/server:core-1.2.2
        networks:
          prefect-server: null
        restart: always
      ui:
        command: /intercept.sh
        depends_on:
        - apollo
        environment:
          PREFECT_SERVER__APOLLO_URL: <http://10.10.10.255:4200/graphql>
        healthcheck:
          interval: 30s
          retries: 3
          test: curl --fail --silent --head "<http://ui:8080/>" &> /dev/null || exit 1
          timeout: 5s
        image: prefecthq/ui:core-1.2.2
        networks:
          prefect-server: null
        ports:
        - 0.0.0.0:8080:8080/tcp
        restart: always
    version: '3.7'
    The issue is that the UI when accessed from developer browser can't access the graphql endpoint. How can I tell the server to look for the API elsewhere? Currently it tries to access it on http://localhost:4200/graphql by default I saw on this github thread some mentioning of
    VUE_APP_SERVER_URL
    but I am not certain how to fit it in.
    docker exec -ti 76dda821912bash
    nginx@76dda821912:/$ ls
    bin  boot  dev	docker-entrypoint.d  docker-entrypoint.sh  etc	home  intercept.sh  lib  lib64	media  mnt  opt  proc  root  run  sbin	srv  start_server.sh  sys  tmp	usr  var
    nginx@76dda821912:/$ ls -a
    .  ..  .dockerenv  bin	boot  dev  docker-entrypoint.d	docker-entrypoint.sh  etc  home  intercept.sh  lib  lib64  media  mnt  opt  proc  root	run  sbin  srv	start_server.sh  sys  tmp  usr	var
    nginx@76dda821912:/$ cat start_server.sh 
    #!/usr/bin/env bash
    
    # Set default prefect_ui_settings if
    # env vars not present
    if [[ -z ${PREFECT_SERVER__APOLLO_URL} ]]
    then
        echo "Missing the PREFECT_SERVER__APOLLO_URL environment variable.  Using default"
        PREFECT_SERVER__APOLLO_URL="<http://localhost:4200/graphql>"
    fi
    
    if [[ -z ${PREFECT_SERVER__BASE_URL} ]]
    then
        echo "Missing the PREFECT_SERVER__BASE_URL environment variable.  Using default"
        PREFECT_SERVER__BASE_URL="/"
    fi
    
    sed -i "s,PREFECT_SERVER__APOLLO_URL,$PREFECT_SERVER__APOLLO_URL," /var/www/settings.json 
    sed -i "s,PREFECT_SERVER__BASE_URL,$PREFECT_SERVER__BASE_URL," /var/www/settings.json
    
    echo "๐Ÿ‘พ๐Ÿ‘พ๐Ÿ‘พ UI running at localhost:8080 ๐Ÿ‘พ๐Ÿ‘พ๐Ÿ‘พ"
    
    nginx -g "daemon off;"
    Kevin Kho

    Kevin Kho

    2 months ago
    You need to set it
    [server]
      
      [server.ui]
        
        apollo_url = "<http://YOUR_MACHINES_PUBLIC_IP:4200/graphql>"
    before you start the server in the config.toml or under UI to point to the API
    I think what you have looks right. Maybe what you need is:
    [server]
    endpoint = "YOUR_MACHINES_PUBLIC_IP:4200/graphql"
    from local?
    Yossi

    Yossi

    2 months ago
    @Kevin Kho thanks, where are those .toml files located?
    Kevin Kho

    Kevin Kho

    2 months ago
    you can create the config.toml if it doesnt exist
    Yossi

    Yossi

    2 months ago
    not sure where though as I have the docker-compose.yml and I can't see any volume or any external dirs it depends on
    The full picture isn't clear to me. I have the docker-compose.ymland I start Prefect this way:
    docker-compose up
    I am not sure how to inject/change the .toml files. The only thing I have done is to change 127.0.0.1 to 0.0.0.0 and changing APOLLO_URL:
    environment:
          PREFECT_SERVER__APOLLO_URL: <http://YOUR_MACHINES_PUBLIC_IP:4200/graphql>
    which isn't sufficient as the UI tries to reach graphql at localhost
    Kevin Kho

    Kevin Kho

    2 months ago
    Ah yeah you are right itโ€™s the UI URL seeming to not stick. Are you making other changes that you need to start from
    docker-compose
    yourself rather than using
    prefect server start
    ?
    Are you not able to use Prefect Cloud instead? The free tier has 20k free task runs per month and you can have 3 users in a tenant
    Maybe you can try something like shown here also