I cannot run shopify nodejs app inside a docker container using the CLI

Alex778
Shopify Partner
1 0 1

Hi!

I'm building nodejs shopify app from scratch, so far I have followed the getting started and I would like to run this inside a docker container. And whenever I run it inside a container I get this message

 

shopify-app  | To run this command, log in to Shopify Partners.
shopify-app  | 👉 Press any key to open the login page on your browser
shopify-app  | ╭─ error ──────────────────────────────────────────────────────────────────────╮
shopify-app  | │                                                                              │
shopify-app  | │  process.stdin.setRawMode is not a function                                  │
shopify-app  | │                                                                              │
shopify-app  | │  To investigate the issue, examine this stack trace:                         │
shopify-app  | │    at (@shopify/cli-kit/src/public/node/ui.tsx:543)                          │
shopify-app  | │      process.stdin.setRawMode(true)                                          │
shopify-app  | │    at new Promise                                                            │
shopify-app  | │    at keypress (@shopify/cli-kit/src/public/node/ui.tsx:528)                 │
shopify-app  | │      return new Promise((resolve, reject) => {                               │
shopify-app  | │    at authorize (@shopify/cli-kit/src/private/node/session/authorize.ts:42)  │
shopify-app  | │      await keypress()                                                        │
shopify-app  | │    at processTicksAndRejections (node:internal/process/task_queues:95)       │
shopify-app  | │    at async executeCompleteFlow                                              │
shopify-app  | │    (@shopify/cli-kit/src/private/node/session.ts:183)                        │
shopify-app  | │      const code = await authorize(scopes)                                    │
shopify-app  | │    at async ensureAuthenticated                                              │
shopify-app  | │    (@shopify/cli-kit/src/private/node/session.ts:119)                        │
shopify-app  | │      newSession = await executeCompleteFlow(applications, fqdn)              │
shopify-app  | │    at async ensureAuthenticatedPartners                                      │
shopify-app  | │    (@shopify/cli-kit/src/public/node/session.ts:34)                          │
shopify-app  | │      const tokens = await ensureAuthenticated({partnersApi: {scopes}})       │
shopify-app  | │    at async dev (@shopify/app/src/cli/services/dev.ts:88)                    │
shopify-app  | │      const token = await ensureAuthenticatedPartners()                       │
shopify-app  | │    at run (@shopify/app/src/cli/commands/app/dev.ts:106)                     │
shopify-app  | │      await dev({                                                             │
shopify-app  | │                                                                              │
shopify-app  | ╰──────────────────────────────────────────────────────────────────────────────╯

 

The error is clear, the CLI uses stdin which isn't supported when running inside docker. Is there a different way to input these credentials and also the settings questionnaire following this?

I did have a look inside the CLI code and found that it's using https://github.com/sindresorhus/env-paths this library to get a file path to store the settings. And I found these files in my ~/.config folder

 

// Inside: ~/.config/shopify-cli-app-nodejs/config.json
{
	"/home/alex/Dev/shopify-app": {
		"directory": "/home/alex/Dev/shopify-app",
		"appId": "****************************",
		"title": "************",
		"storeFqdn": "************.myshopify.com",
		"orgId": "*******",
		"updateURLs": true
	},
}

// And inside: ~/.config/shopify-cli-kit-nodejs/config.json
{
	"__internal__": {
		"migrations": {
			"version": "3.11.0"
		}
	},
	"sessionStore": "**"
  "cache": {
		"identity-introspection-url-accounts.shopify.com": {
			"value": "https://accounts.shopify.com/oauth/introspection",
			"timestamp": 1687867961362
		}
	}
}

 

I might be totally off, but I'm guessing these files are needed to login and store the settings, so I tried adding them to docker, for the first file there is an absolute path so I duplicated it and changed it to the app directory of the app inside docker container. But still, I get the same error 😕. Has anyone got this to work? If so please let me know how, I need help with figuring this one out.

Replies 0 (0)