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

Typescript docker build pass but fail to start #1520

Open
bright-coder opened this issue Oct 25, 2024 · 9 comments
Open

Typescript docker build pass but fail to start #1520

bright-coder opened this issue Oct 25, 2024 · 9 comments

Comments

@bright-coder
Copy link

I use hello world template typescript

When i command docker run …. Its it failed

log show “cannot find module encore.dev

@fredr
Copy link
Member

fredr commented Oct 25, 2024

Hey, what operating system are you running?

Could you also give some more context regarding how you set up the app? Did you create it as part of a npm workspace, or is it standalone?

@crorvigvp
Copy link

crorvigvp commented Oct 25, 2024

docker-inspect.json
This happens on Windows 11 with standalone setup using encore create app on 1.43.2. The encore library path looks strange in the docker output layer, although this may be a red herring.
image
image

@bright-coder
Copy link
Author

@crorvigvp yeah that it’s. How to fix it ?

@lpkobamn
Copy link

lpkobamn commented Nov 17, 2024

I ran into a similar problem and it's crazy that no one fixed it for a few weeks!

I made an app with the command

encore app create --example=ts/uptime

Then I tried to build with the command encore

build docker b2b --skip-config

I tried to run with the command

docker run -e PORT=8081 -p 8081:8081 b2b

but there was an error:

C:\Windows\System32>docker run -e PORT=8081 -p 8081:8081 b2b
node:internal/modules/esm/resolve:857
  throw new ERR_MODULE_NOT_FOUND(packageName, fileURLToPath(base), null);
        ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'encore.dev' imported from /artifacts/0/build/combined/combined/main.mjs
    at packageResolve (node:internal/modules/esm/resolve:857:9)
    at moduleResolve (node:internal/modules/esm/resolve:926:18)
    at defaultResolve (node:internal/modules/esm/resolve:1056:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:650:12)
    at #cachedDefaultResolve (node:internal/modules/esm/loader:599:25)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:582:38)
    at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:241:38)
    at ModuleJob._link (node:internal/modules/esm/module_job:132:49) {
  code: 'ERR_MODULE_NOT_FOUND'
}

Node.js v23.1.0

Encore version is v1.43.12, and I'm on Windows 10 Pro 22H2 19045.2604 with service pack 120.2212.4190.

Docker version

Client:
 Version:           27.3.1
 API version:       1.47
 Go version:        go1.22.7
 Git commit:        ce12230
 Built:             Fri Sep 20 11:42:27 2024
 OS/Arch:           windows/amd64
 Context:           desktop-linux

Server: Docker Desktop 4.35.1 (173168)
 Engine:
  Version:          27.3.1
  API version:      1.47 (minimum version 1.24)
  Go version:       go1.22.7
  Git commit:       41ca978
  Built:            Fri Sep 20 11:41:11 2024
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.7.21
  GitCommit:        472731909fa34bd7bc9c087e4c27943f9835f111
 runc:
  Version:          1.1.13
  GitCommit:        v1.1.13-0-g58aa920
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

@lpkobamn
Copy link

Can anyone help?

@eandre
Copy link
Member

eandre commented Nov 23, 2024

We're going to look into this in the near future. It appears to be due to how symlinks work on windows. Until then you can build Docker images using WSL or a macOS/Linux machine.

@lpkobamn
Copy link

lpkobamn commented Nov 23, 2024

Not better on linux
I don't understand

/artifacts/0/node_modules/encore.dev/internal/runtime/mod.ts:8
export const RT = new Runtime({
                  ^


Error: failed to initialize runtime: unable to parse runtime config

Caused by:
    environment variable not present
    at <anonymous> (/artifacts/0/node_modules/encore.dev/internal/runtime/mod.ts:8:19)
    at ModuleJob.run (node:internal/modules/esm/module_job:271:25)
    at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:547:26)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:116:5) {
  code: 'GenericFailure'
}

Node.js v23.3.0

@fredr
Copy link
Member

fredr commented Nov 27, 2024

@lpkobamn you need to provide a infra config, see https://encore.dev/docs/ts/self-host/configure-infra

@fredr
Copy link
Member

fredr commented Dec 11, 2024

If you update to encore v1.45.1 it should now work to run on windows, try it out with encore version update

There are a few edge cases still on windows that we are hunting down, but this particular issue should now be solved. Let me know how it works

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

No branches or pull requests

5 participants