withastro/astro

๐Ÿ› BUG: fails to build when running in Docker

danramteke opened this issue ยท 11 comments

What version of astro are you using?

0.25.3 (astro@next)

What package manager are you using?

yarn

What operating system are you using?

Mac, Linux with GitHub Actions

Describe the Bug

Simple astro site does not build in Docker, even when using astro@next and --experimental-static-build.

Build output of docker build . from https://github.com/danramteke/docker-astro-slow-build/actions/runs/1853840061

#15 [builder 7/7] RUN yarn build
[202](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:202)
#15 0.420 yarn run v1.22.17
[203](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:203)
#15 0.438 warning package.json: No license field
[204](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:204)
#15 0.449 $ astro build --verbose --experimental-static-build
[205](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:205)
#15 1.558 2022-02-16T16:03:49.281Z astro:cli --verbose flag enabled! Enabling: DEBUG="*,-babel"
[206](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:206)
#15 1.558 2022-02-16T16:03:49.282Z astro:cli Tip: Set the DEBUG env variable directly for more control. Example: "DEBUG=astro:*,vite:* astro build".
[207](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:207)
#15 1.630 04:03 PM [config] Set "buildOptions.site" to generate correct canonical URLs and sitemap
[208](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:208)
#15 1.716 2022-02-16T16:03:49.440Z vite:vite-plugin-svelte no svelte config found at /
[209](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:209)
#15 1.716 2022-02-16T16:03:49.440Z vite:vite-plugin-svelte findSvelteDependencies: searching svelte dependencies in /
[210](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:210)
#15 1.718 2022-02-16T16:03:49.442Z vite:vite-plugin-svelte adding bare svelte packages to optimizeDeps.include: svelte/animate, svelte/easing, svelte/internal, svelte/motion, svelte/store, svelte/transition, svelte 
[211](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:211)
#15 1.718 2022-02-16T16:03:49.442Z vite:vite-plugin-svelte automatically excluding found svelte dependencies: 
[212](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:212)
#15 1.719 2022-02-16T16:03:49.442Z vite:vite-plugin-svelte reincluding transitive dependencies of excluded svelte dependencies []
[213](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:213)
#15 1.721 2022-02-16T16:03:49.443Z vite:vite-plugin-svelte additional vite config {
[214](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:214)
#15 1.721   resolve: {
[215](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:215)
#15 1.721     mainFields: [ 'svelte', 'module', 'jsnext:main', 'jsnext' ],
[216](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:216)
#15 1.721     dedupe: [
[217](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:217)
#15 1.721       'svelte/animate',
[218](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:218)
#15 1.721       'svelte/easing',
[219](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:219)
#15 1.721       'svelte/internal',
[220](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:220)
#15 1.721       'svelte/motion',
[221](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:221)
#15 1.721       'svelte/ssr',
[222](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:222)
#15 1.721       'svelte/store',
[223](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:223)
#15 1.721       'svelte/transition',
[224](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:224)
#15 1.721       'svelte',
[225](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:225)
#15 1.721       'svelte-hmr/runtime/hot-api-esm.js',
[226](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:226)
#15 1.721       'svelte-hmr/runtime/proxy-adapter-dom.js',
[227](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:227)
#15 1.721       'svelte-hmr'
[228](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:228)
#15 1.721     ]
[229](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:229)
#15 1.721   },
[230](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:230)
#15 1.721   optimizeDeps: {
[231](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:231)
#15 1.721     include: [
[232](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:232)
#15 1.721       'svelte/animate',
[233](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:233)
#15 1.721       'svelte/easing',
[234](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:234)
#15 1.721       'svelte/motion',
[235](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:235)
#15 1.721       'svelte/store',
[236](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:236)
#15 1.721       'svelte/transition'
[237](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:237)
#15 1.721     ],
[238](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:238)
#15 1.721     exclude: [ 'svelte-hmr' ]
[239](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:239)
#15 1.721   },
[240](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:240)
#15 1.721   ssr: { noExternal: [] }
[241](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:241)
#15 1.721 }
[242](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:242)
#15 1.726 2022-02-16T16:03:49.449Z vite:vite-plugin-svelte resolved options {
[243](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:243)
#15 1.726   hot: false,
[244](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:244)
#15 1.726   compilerOptions: { css: false, dev: false, format: 'esm', hydratable: true },
[245](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:245)
#15 1.726   extensions: [ '.svelte' ],
[246](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:246)
#15 1.726   emitCss: true,
[247](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:247)
#15 1.726   preprocess: [
[248](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:248)
#15 1.726     {
[249](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:249)
#15 1.726       defaultLanguages: [Object],
[250](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:250)
#15 1.726       markup: [AsyncFunction: markup],
[251](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:251)
#15 1.726       script: [AsyncFunction: script],
[252](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:252)
#15 1.726       style: [AsyncFunction: style]
[253](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:253)
#15 1.726     }
[254](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:254)
#15 1.726   ],
[255](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:255)
#15 1.726   experimental: {},
[256](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:256)
#15 1.726   root: '/',
[257](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:257)
#15 1.726   isBuild: false,
[258](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:258)
#15 1.726   isServe: true,
[259](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:259)
#15 1.726   isDebug: true,
[260](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:260)
#15 1.726   isProduction: true
[261](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:261)
#15 1.726 }
[262](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:262)
#15 2.260 2022-02-16T16:03:49.984Z astro:build Vite started   625ms
[263](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:263)
#15 6.286 2022-02-16T16:03:54.010Z astro:build โ”œโ”€โ”€ โœ” src/pages/index.astro โ†’ /index.html
[264](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:264)
#15 161.7 
[265](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:265)
#15 161.7 <--- Last few GCs --->
[266](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:266)
#15 161.7 
[267](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:267)
#15 161.7 [28:0x55c26f0]   158063 ms: Scavenge (reduce) 2029.5 (2081.8) -> 2029.0 (2081.8) MB, 11.7 / 0.0 ms  (average mu = 0.122, current mu = 0.006) allocation failure 
[268](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:268)
#15 161.7 [28:0x55c26f0]   158081 ms: Scavenge (reduce) 2029.6 (2081.8) -> 2029.1 (2082.1) MB, 5.3 / 0.0 ms  (average mu = 0.122, current mu = 0.006) allocation failure 
[269](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:269)
#15 161.7 [28:0x55c26f0]   158113 ms: Scavenge (reduce) 2029.9 (2082.1) -> 2029.2 (2082.3) MB, 5.3 / 0.0 ms  (average mu = 0.122, current mu = 0.006) allocation failure 
[270](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:270)
#15 161.7 
[271](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:271)
#15 161.7 
[272](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:272)
#15 161.7 <--- JS stacktrace --->
[273](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:273)
#15 161.7 
[274](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:274)
#15 161.7 FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
[275](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:275)
#15 161.7  1: 0xb2e750 node::Abort() [/usr/local/bin/node]
[276](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:276)
#15 161.7  2: 0xa40252 node::FatalError(char const*, char const*) [/usr/local/bin/node]
[277](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:277)
#15 161.7  3: 0xd1f99e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
[278](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:278)
#15 161.7  4: 0xd1fd17 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
[279](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:279)
#15 161.7  5: 0xed9145  [/usr/local/bin/node]
[280](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:280)
#15 161.7  6: 0xed9c26  [/usr/local/bin/node]
[281](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:281)
#15 161.7  7: 0xee989c  [/usr/local/bin/node]
[282](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:282)
#15 161.7  8: 0xeea310 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/usr/local/bin/node]
[283](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:283)
#15 161.7  9: 0xeed2be v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/bin/node]
[284](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:284)
#15 161.7 10: 0xeaeb4f v8::internal::Factory::AllocateRawWithAllocationSite(v8::internal::Handle<v8::internal::Map>, v8::internal::AllocationType, v8::internal::Handle<v8::internal::AllocationSite>) [/usr/local/bin/node]
[285](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:285)
#15 161.7 11: 0xeb653c v8::internal::Factory::NewJSObjectFromMap(v8::internal::Handle<v8::internal::Map>, v8::internal::AllocationType, v8::internal::Handle<v8::internal::AllocationSite>) [/usr/local/bin/node]
[286](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:286)
#15 161.7 12: 0x10b8305 v8::internal::JSObject::New(v8::internal::Handle<v8::internal::JSFunction>, v8::internal::Handle<v8::internal::JSReceiver>, v8::internal::Handle<v8::internal::AllocationSite>) [/usr/local/bin/node]
[287](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:287)
#15 161.7 13: 0x10c2238 v8::internal::JSDate::New(v8::internal::Handle<v8::internal::JSFunction>, v8::internal::Handle<v8::internal::JSReceiver>, double) [/usr/local/bin/node]
[288](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:288)
#15 161.7 14: 0xd95a57 v8::internal::Builtin_DateConstructor(int, unsigned long*, v8::internal::Isolate*) [/usr/local/bin/node]
[289](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:289)
#15 161.7 15: 0x16326b9  [/usr/local/bin/node]
[290](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:290)
#15 173.0 Aborted (core dumped)
[291](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:291)
#15 173.1 error Command failed with exit code 134.
[292](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:292)
#15 173.1 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
[293](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:293)
#15 ERROR: executor failed running [/bin/sh -c yarn build]: exit code: 134
[294](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:294)
------
[295](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:295)
 > [builder 7/7] RUN yarn build:
[296](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:296)
#15 161.7  9: 0xeed2be v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/bin/node]
[297](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:297)
#15 161.7 10: 0xeaeb4f v8::internal::Factory::AllocateRawWithAllocationSite(v8::internal::Handle<v8::internal::Map>, v8::internal::AllocationType, v8::internal::Handle<v8::internal::AllocationSite>) [/usr/local/bin/node]
[298](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:298)
#15 161.7 11: 0xeb653c v8::internal::Factory::NewJSObjectFromMap(v8::internal::Handle<v8::internal::Map>, v8::internal::AllocationType, v8::internal::Handle<v8::internal::AllocationSite>) [/usr/local/bin/node]
[299](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:299)
#15 161.7 12: 0x10b8305 v8::internal::JSObject::New(v8::internal::Handle<v8::internal::JSFunction>, v8::internal::Handle<v8::internal::JSReceiver>, v8::internal::Handle<v8::internal::AllocationSite>) [/usr/local/bin/node]
[300](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:300)
#15 161.7 13: 0x10c2238 v8::internal::JSDate::New(v8::internal::Handle<v8::internal::JSFunction>, v8::internal::Handle<v8::internal::JSReceiver>, double) [/usr/local/bin/node]
[301](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:301)
#15 161.7 14: 0xd95a57 v8::internal::Builtin_DateConstructor(int, unsigned long*, v8::internal::Isolate*) [/usr/local/bin/node]
[302](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:302)
#15 161.7 15: 0x16326b9  [/usr/local/bin/node]
[303](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:303)
#15 173.0 Aborted (core dumped)
[304](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:304)
#15 173.1 error Command failed with exit code 134.
[305](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:305)
#15 173.1 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
[306](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:306)
------
[307](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:307)
error: failed to solve: executor failed running [/bin/sh -c yarn build]: exit code: 134
[308](https://github.com/danramteke/docker-astro-slow-build/runs/5219165788?check_suite_focus=true#step:3:308)
Error: buildx failed with: error: failed to solve: executor failed running [/bin/sh -c yarn build]: exit code: 134

Link to Minimal Reproducible Example

https://github.com/danramteke/docker-astro-slow-build

Thanks for opening an issue and sorry for the inconvenience! We're currently investigating a potential memory leak related to the recent release of @astrojs/compiler@0.11.0. Will share any updates as soon as we have them.

Thanks for the trying the update! We definitely fixed some memory issues in this release, but we'll have to look into this one more.

@danramteke any chance you can re-try with Astro v0.24.0?

@FredKSchott still fails with 0.25.3, on both Buildah and Docker.

One notable output is

 src/pages/post.md is taking a bit longer to import. This is common for larger "Astro.glob(...)" or "import.meta.globEager(...)" calls, for instance. Hang tight!

This doesn't make much sense to me since that file is so small. Is there something else going on?

Hey @danramteke sorry for the delay on this! I just re-ran your example on the latest astro@1.0.0-beta.27 and everything seems to be working! https://github.com/natemoo-re/docker-astro-slow-build/actions/runs/2303549191 ๐ŸŽ‰

Please re-open if you're still running into trouble, bit it looks like we finally tracked down the memory problem.

@natemoo-re just tested my self with 1.0.0-beta.42 ๐Ÿฅณ build completes, and in a reasonable amount of time! ๐Ÿ’œ

@natemoo-re wanted to share the good news that Astro now successfully builds using buildah as well https://github.com/danramteke/docker-astro-slow-build/runs/6802544323

This issue is still happens to me (javascript heap out of memory) when using docker inside a 2GB Ram server

I just followed (add NODE_OPTIONS=--max-old_space_size=2048)

astro version: 4.4.10