johnHackworth / goblin

GNU Affero General Public License v3.0
46 stars 4 forks source link

Dockerfile v2 #41

Closed analytik closed 5 months ago

analytik commented 6 months ago

Once again I'm changing way too many files because someone's gotta run the linter around here!

I don't care if we drop it or change its settings or keep it, but if it exists, it should be used, and it should be required to run before PR merge.

analytik commented 5 months ago

Image registry.stopdelaying.com/mb/goblin:16 is now publicly accessible, and running on https://goblin.stopdelaying.com/

I think I'm done with this PR for now, can/will improve the guide later.

johnHackworth commented 5 months ago

ok, I merged this to main so I could test it properly on my local, and then my local dev environment went down the drain, so I reverted created and pushed a docker branch with the merge and reverted it in main, so I can check what's going on, fix it and then merge this PR back to main

analytik commented 5 months ago

Thanks for looking into it! It's probably some mess around the npm package upgrades - or possibly a badly resolved merge conflict either by my hand or by auto-merge. I will also try to re-merge the latest main and see if it builds and runs successfully

analytik commented 5 months ago

Re-running docker build on my last merge commit, 898a372492648decc30e68782ef8aa2c6b84a1e2 with --no-cache succeeds correctly.

Current commit d108a5d295c20303087058a1f22e5000cd468f84: docker build --no-cache -t registry.stopdelaying.com/mb/goblin:17test1 .

<snip>
 => [build 22/28] RUN corepack install -g pnpm@8.15.4                                                                                                                                                                                                                    0.7s
 => [build 23/28] RUN pnpm i --frozen-lockfile     && pnpm prune                                                                                                                                                                                                        52.5s
 => [build 24/28] COPY --chown=goblin:goblin packages/backend/native-utils packages/backend/native-utils/                                                                                                                                                                0.2s
 => [build 25/28] RUN pnpm run --filter native-utils build                                                                                                                                                                                                               0.6s
 => [build 26/28] COPY --chown=goblin:goblin . ./                                                                                                                                                                                                                        0.5s
 => ERROR [build 27/28] RUN env NODE_ENV=production sh -c "pnpm run --filter '!native-utils' build && pnpm run gulp"                                                                                                                                                     3.6s
------
 > [build 27/28] RUN env NODE_ENV=production sh -c "pnpm run --filter '!native-utils' build && pnpm run gulp":
0.569 No projects matched the filters "native-utils" in "/goblin"
0.570 Scope: 5 of 6 workspace projects
0.573 packages/firefish-js build$ pnpm swc src -d built -D
0.573 packages/megalodon build$ tsc -p ./
0.850 packages/firefish-js build: Successfully compiled: 8 files with swc (34.45ms)
0.861 packages/firefish-js build: Done
2.554 packages/megalodon build: Done
2.555 packages/backend build$ pnpm swc src -d built -D
2.556 packages/client build$ pnpm vite build
2.556 packages/sw build$ webpack
2.980 packages/backend build:   x 'import', and 'export' cannot be used outside of module code
2.981 packages/backend build:     ,-[src/server/api/endpoints/notes/ancestors.ts:49:1]
2.981 packages/backend build:  49 |     return null;
2.981 packages/backend build:  50 | };
2.981 packages/backend build:  51 |
2.981 packages/backend build:  52 | export default define(meta, paramDef, async (ps, user) => {
2.982 packages/backend build:     : ^^^^^^
2.982 packages/backend build:  53 |     const note = await getNote(ps.noteId, user).catch((err) => {
2.982 packages/backend build:  54 |             if (err.id === "9725d0ce-ba28-4dde-95a7-2cbb2c15de24")
2.982 packages/backend build:  55 |                     throw new ApiError(meta.errors.noSuchNote);
2.982 packages/backend build:     `----
2.982 packages/backend build: Caused by:
2.982 packages/backend build:     Syntax Error
3.378 packages/sw build: Done
3.548 packages/backend build: Successfully compiled: 879 files, copied 21 files with swc (755.83ms)
3.548 packages/backend build: Failed to compile 1 file with swc.
3.549 packages/backend build: Error: Failed to compile:
3.549 packages/backend build: src/server/api/endpoints/notes/ancestors.ts
3.549 packages/backend build:     at initialCompilation (/goblin/node_modules/.pnpm/@swc+cli@0.1.63_@swc+core@1.3.100_chokidar@3.5.3/node_modules/@swc/cli/lib/swc/dir.js:163:19)
3.549 packages/backend build:     at async dir (/goblin/node_modules/.pnpm/@swc+cli@0.1.63_@swc+core@1.3.100_chokidar@3.5.3/node_modules/@swc/cli/lib/swc/dir.js:228:5)
3.561 packages/backend build: Failed
3.562 /goblin/packages/backend:
3.562  ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL  backend@ build: `pnpm swc src -d built -D`
3.562 Exit status 1
------
Dockerfile:73
--------------------
  71 |     # Copy in the rest of the files to compile
  72 |     COPY --chown=goblin:goblin . ./
  73 | >>> RUN env NODE_ENV=production sh -c "pnpm run --filter '!native-utils' build && pnpm run gulp"
  74 |
  75 |     # Trim down the dependencies to only those for production
--------------------
ERROR: failed to solve: process "/bin/sh -c env NODE_ENV=production sh -c \"pnpm run --filter '!native-utils' build && pnpm run gulp\"" did not complete successfully: exit code: 1
analytik commented 5 months ago

I don't see anything in the main branch that would immediately give away the cause, but it's probably some combination of changes in ancestors.ts (which seem OK to me) and my changes in packages/backend/.swcrc

To be fair I know next to nothing about swc and its configuration options besides from what I duckduckgoed around. The current firefish source is the same - https://firefish.dev/firefish/firefish/-/blob/develop/packages/backend/.swcrc?ref_type=heads