Skip to content

Building static binary broken on Linux #559

Closed

Description

@HolgerDoerner

https://github.com/dunglas/frankenphp/blob/5da805d9ee28d8124c6f83ce2b82c08bdfa920a2/build-static.sh#L126

When executing build-static.sh an error occours saying md5 could not be found. The error also appears when using the Docker image.

Could be a typo or even MacOS specific. The standard util to generate/check md5 hashes on linux is md5sum, but that doesn't support the -q flag.

Activity

  1. dunglas commented on Feb 6, 2024

    @dunglas
    Member

    Good catch, that's a BSD/Mac command. Don't hesitate to open a PR. I'll do it ASAP otherwise.

  2. HolgerDoerner commented on Feb 7, 2024

    @HolgerDoerner
    ContributorAuthor

    Hi Kevin, I opened a PR to address this issue.

  3. changed the title [-]Building static binary broken[/-] [+]Building static binary broken on Linux[/+] on Feb 7, 2024
  4. dunglas commented on Feb 7, 2024

    @dunglas
    Member

    Thank you Holger!

  5. alexhackney commented on Feb 9, 2024

    @alexhackney

    @HolgerDoerner I'm running in to this as well trying to build on a m3 mac. Is there a way around it for now un til this is merged? Trying to get my buiild process done.

  6. alexhackney commented on Feb 9, 2024

    @alexhackney

    Actually this seems to work ok

    # Install sed
    RUN apk add --no-cache sed
    
    # Modify the build-static.sh script
    RUN sed -i 's/md5 -q/md5sum/' /go/src/app/build-static.sh
    
  7. HolgerDoerner commented on Feb 10, 2024

    @HolgerDoerner
    ContributorAuthor

    @alexhackney This would still leave the build script broken when run on Your local machine, this will ONLY work in inside of the Docker Container.

  8. dunglas commented on Feb 10, 2024

    @dunglas
    Member

    Fixed by #562, thanks to Holger!

  9. marsderp commented on Feb 25, 2024

    @marsderp

    Hi sorry to necro this issue, I am having this issue in my Dockerfile.

    Could I be missing something?

    #15 [builder 6/6] RUN EMBED=dist/app/     ./build-static.sh
    #15 0.245 ./build-static.sh: line 126: md5: not found
    #15 ERROR: process "/bin/ash -eo pipefail -c EMBED=dist/app/     ./build-static.sh" did not complete successfully: exit code: 127
    ------
     > [builder 6/6] RUN EMBED=dist/app/     ./build-static.sh:
    0.245 ./build-static.sh: line 126: md5: not found
    ------
    Dockerfile:11
    --------------------
      10 |     WORKDIR /go/src/app/
      11 | >>> RUN EMBED=dist/app/ \
      12 | >>>     ./build-static.sh
      13 |     
    --------------------
    FROM --platform=linux/amd64 dunglas/frankenphp:static-builder-1.1 as builder
    
    # Copy your app
    WORKDIR /go/src/app/dist/app
    COPY . .
    
    RUN composer install --ignore-platform-reqs --no-dev -a
    
    # Build the static binary, be sure to select only the PHP extensions you want
    WORKDIR /go/src/app/
    RUN EMBED=dist/app/ \
        ./build-static.sh
    
    
    FROM alpine:latest
    
    WORKDIR /app
    
    COPY --from=builder /go/src/app/dist/frankenphp-linux-x86_64 exampleapp
    
    EXPOSE 80
    
    CMD ["./exampleapp", "php-server"]
  10. withinboredom commented on Feb 25, 2024

    @withinboredom
    Member
  11. juancamunoz commented on Feb 25, 2024

    @juancamunoz

    Same issue here 😞

    @withinboredom looks like the image is not updated with this changes. It's trying to do a md5 instead of md5sum

  12. withinboredom commented on Feb 25, 2024

    @withinboredom
    Member

    It looks like an image update was pushed two days ago, is that the same image you are seeing an issue with?

  13. marsderp commented on Feb 25, 2024

    @marsderp

    Looks like you are somehow hitting this line? https://github.com/dunglas/frankenphp/pull/562/files#diff-548dba7efda4c2f29f4eeb946db1da090e10308817056d55077d71146f8ad0ebR15

    Can you test that?

    Getting the same error building locally from my WSL2 and running it on Github actions.

    However when I run the following commands they seem to be returning the correct responses.

    ❯ docker run -it dunglas/frankenphp:static-builder-1.1 /bin/bash
    
    644f6b4df145:/go/src/app# arch="$(uname -m)"
    os="$(uname -s | tr '[:upper:]' '[:lower:]')"
    md5binary="md5sum"
    644f6b4df145:/go/src/app# echo $arch
    x86_64
    644f6b4df145:/go/src/app# echo $os
    linux
    644f6b4df145:/go/src/app# echo $md5binary
    md5sum
    644f6b4df145:/go/src/app# uname -a
    Linux 644f6b4df145 5.15.133.1-microsoft-standard-WSL2 #1 SMP Thu Oct 5 21:02:42 UTC 2023 x86_64 Linux

    Also note that frankenphp:static-builder-1.1 does have the updated script.

  14. withinboredom commented on Feb 25, 2024

    @withinboredom
    Member

    That's a mystery...

    As a work around, can you try alias md5=md5sum before running the script in the container. That should (theoretically) allow it to at least build until the mystery is resolved.

  15. HolgerDoerner commented on Feb 25, 2024

    @HolgerDoerner
    ContributorAuthor

    @marsderp The image dunglas/frankenphp:static-builder-1.1 does not have the updated build-static.sh script, that's why the error still pops up. @dunglas any idea why?

    $ docker run dunglas/frankenphp:static-builder-1.1 head -n15 build-static.sh
    #!/bin/sh
    
    set -o errexit
    
    if ! type "git" > /dev/null; then
        echo "The \"git\" command must be installed."
        exit 1
    fi
    
    arch="$(uname -m)"
    os="$(uname -s | tr '[:upper:]' '[:lower:]')"
    if [ "${os}" = "darwin" ]; then
        os="mac"
    fi

    @withinboredom

    That's a mystery...

    As a work around, can you try alias md5=md5sum before running the script in the container. That should (theoretically) allow it to at least build until the mystery is resolved.

    That will not work because md5 is run with -c, which md5sum doesn't know. A more proper workaround for this case was posted earlier: #559 (comment)

  16. dunglas commented on Feb 26, 2024

    @dunglas
    Member

    That's just because we need to create a new tag, the patch is currently only available in main: b60fc5c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions