Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

statamic new requires tty to run #65

Open
amiuhle opened this issue Oct 26, 2023 · 3 comments · May be fixed by #66
Open

statamic new requires tty to run #65

amiuhle opened this issue Oct 26, 2023 · 3 comments · May be fixed by #66

Comments

@amiuhle
Copy link

amiuhle commented Oct 26, 2023

I'm trying to create a new statamic site in an automated process using a docker image. It works using the -it flags when running the docker image, but without an interactive tty terminal, Statamic fails right after printing the title art:

In Process.php line 1023:
                                                   
  TTY mode requires /dev/tty to be read/writable.

Statamic site generation should not require an interactive shell if the --no-interaction flag is passed from the command line.

@jasonvarga
Copy link
Member

Please provide a way for us to reproduce this, or feel free to open a PR.

Also, what does composer global show | grep prompts output?

@amiuhle
Copy link
Author

amiuhle commented Oct 30, 2023

Below is a docker demo image built with Nix.

It can be built using

nix build && docker load < result

When it's run using the -it flag, it works but the second line without -it fails with the error message above.

docker run -it -v .:/project statamic-demo-image
docker run -v .:/project statamic-demo-image

Also, what does composer global show | grep prompts output?

The output is

laravel/prompts                  v0.1.12
# flake.nix
{
  description = "A flake to build a Statamic docker image";

  inputs = {
    nixpkgs.url = "nixpkgs/nixos-unstable";
  };


  outputs = { self, nixpkgs }: {
    packages."x86_64-linux" =
      let
        pkgs = import nixpkgs { system = "x86_64-linux"; };
      in
      rec {
        default =
          pkgs.dockerTools.buildLayeredImage (
            let
              COMPOSER_HOME = "/tmp/composer";
            in
            rec {
              name = "statamic-demo-image";
              tag = "latest";

              contents = with pkgs; [
                dockerTools.usrBinEnv
                dockerTools.binSh
                dockerTools.caCertificates

                coreutils
                gnugrep
                git

                php81
                php81Packages.composer

                (writeTextDir "etc/passwd" ''
                  root:x:0:0::/root:${runtimeShell}
                '')
                (writeTextDir "root/.ssh/config" ''
                  Host *
                    StrictHostKeyChecking no
                '')

                (writeScriptBin "entrypoint" ''
                  #!${dockerTools.binSh}/bin/sh

                  ${pkgs.php81Packages.composer}/bin/composer global require statamic/cli

                  ${COMPOSER_HOME}/vendor/bin/statamic new -f -n -- test01
                  ${pkgs.php81Packages.composer}/bin/composer global show | grep prompts
                  ${dockerTools.binSh}/bin/sh
                '')
              ];

              config = {
                Entrypoint = [ "entrypoint" ];
                WorkingDir = "/project";
                Env = [
                  "COMPOSER_HOME=${COMPOSER_HOME}"
                  "COMPOSER_ALLOW_SUPERUSER=1"
                ];
                Volumes = {
                  "/project" = { };
                };
              };
            }
          );
      };
  };
}

@amiuhle amiuhle linked a pull request Nov 16, 2023 that will close this issue
@amiuhle
Copy link
Author

amiuhle commented Nov 16, 2023

I found a way to reproduce this without a docker image, see my PR comment here: #66 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants