dunglas / frankenphp

🧟 The modern PHP app server
https://frankenphp.dev
MIT License
7.01k stars 243 forks source link

Runing Franken in docker on different port doesnt work #935

Closed jmail closed 4 months ago

jmail commented 4 months ago

What happened?

Hey guys. I tried to deploy my Laravel app into the docker container with Franken and it doesnt work.

Background:

I got docker composed services runing on one machine - each service is separate compose project connected with same local docker network - that is preparation for the Kubernetes in long term. Ther is a need to serve multiple services on the same domain name so we decided to use KongAPI in front and split traffic when needed. That is why I need to have only http port enabled. I do not want for now to complicate communicaton with https communication between kong and services - it will happen maybe in some distant future. So the requirements are:

And I failed. Help help please

When I start docker and try to wget I got:

`wget http://DOMAIN_NAME:8000 --2024-07-24 05:19:34-- http://DOMAIN_NAME:8000/ Resolving DOMAIN_NAME (DOMAIN_NAME)... 127.0.1.1 Connecting to DOMAIN_NAME (DOMAIN_NAME)|127.0.1.1|:8000... connected. HTTP request sent, awaiting response... Read error (Connection reset by peer) in headers. Retrying.

--2024-07-24 05:19:35-- (try: 2) http://DOMAIN_NAME:8000/ Connecting to DOMAIN_NAME (DOMAIN_NAME)|127.0.1.1|:8000... connected. HTTP request sent, awaiting response... Read error (Connection reset by peer) in headers. Retrying.

--2024-07-24 05:19:37-- (try: 3) http://DOMAIN_NAME:8000/ Connecting to DOMAIN_NAME (DOMAIN_NAME)|127.0.1.1|:8000... connected. HTTP request sent, awaiting response... Read error (Connection reset by peer) in headers. Retrying.

`

Logs from franken

docker logs emotivo.pim.product 2024/07/23 11:48:24.614 INFO using config from file {"file": "/etc/caddy/Caddyfile"} 2024/07/23 11:48:24.616 INFO adapted config to JSON {"adapter": "caddyfile"} 2024/07/23 11:48:24.616 WARN Caddyfile input is not formatted; run 'caddy fmt --overwrite' to fix inconsistencies {"adapter": "caddyfile", "file": "/etc/caddy/Caddyfile", "line": 2} 2024/07/23 11:48:24.617 INFO admin admin endpoint started {"address": "localhost:2019", "enforce_origin": false, "origins": ["//[::1]:2019", "//127.0.0.1:2019", "//localhost:2019"]} 2024/07/23 11:48:24.617 INFO http.auto_https automatic HTTPS is completely disabled for server {"server_name": "srv0"} 2024/07/23 11:48:24.618 INFO tls.cache.maintenance started background certificate maintenance {"cache": "0xc0003a9b80"} 2024/07/23 11:48:24.618 INFO FrankenPHP started 🐘 {"php_version": "8.3.9", "num_threads": 4} 2024/07/23 11:48:24.618 INFO http enabling HTTP/3 listener {"addr": ":443"} 2024/07/23 11:48:24.619 INFO http.log server running {"name": "srv0", "protocols": ["h1", "h2", "h3"]} 2024/07/23 11:48:24.619 INFO autosaved config (load with --resume flag){"file": "/config/caddy/autosave.json"} 2024/07/23 11:48:24.619 INFO serving initial configuration 2024/07/23 11:48:24.621 INFO tls cleaning storage unit {"storage": "FileStorage:/data/caddy"} 2024/07/23 11:48:24.621 INFO tls finished cleaning storage units

Caddyfile

`{ {$CADDY_GLOBAL_OPTIONS} auto_https off http_port 8000 frankenphp {

worker /path/to/your/worker.php

            {$FRANKENPHP_CONFIG}
    }

}

{$CADDY_EXTRA_CONFIG}

{$SERVER_NAME:localhost} {

log {

    #       # Redact the authorization query parameter that can be set by Mercure
    #       format filter {
    #               request>uri query {
    #                       replace authorization REDACTED
    #               }
    #       }
    #}

    root * public/
    encode zstd br gzip

    # Uncomment the following lines to enable Mercure and Vulcain modules
    #mercure {
    #       # Transport to use (default to Bolt)
    #       transport_url {$MERCURE_TRANSPORT_URL:bolt:///data/mercure.db}
    #       # Publisher JWT key
    #       publisher_jwt {env.MERCURE_PUBLISHER_JWT_KEY} {env.MERCURE_PUBLISHER_JWT_ALG}
    #       # Subscriber JWT key
    #       subscriber_jwt {env.MERCURE_SUBSCRIBER_JWT_KEY} {env.MERCURE_SUBSCRIBER_JWT_ALG}
    #       # Allow anonymous subscribers (double-check that it's what you want)
    #       anonymous
    #       # Enable the subscription API (double-check that it's what you want)
    #       subscriptions
    #       # Extra directives
    #       {$MERCURE_EXTRA_DIRECTIVES}
    #}
    #vulcain

    {$CADDY_SERVER_EXTRA_DIRECTIVES}
    php_server

} `

docker compose file

`services: app.name: image: registry.gitlab.com/company.name/app.name:test container_name: app.name hostname: app.name stdin_open: true tty: true restart: always privileged: true ports:

networks: new_arch_stack-local: external: true`

Docker file

`FROM dunglas/frankenphp

COPY . /app`

Build Type

Docker (Debian Bookworm)

Worker Mode

Yes

Operating System

GNU/Linux

CPU Architecture

x86_64

PHP configuration

I didnt get to this point yet to have issues with PHP :D

Relevant log output

No response

withinboredom commented 4 months ago

You have to set the port to serve on, ie: SERVER_NAME=DOMAIN_NAME:8000.