Skip to content

Commit 49fcb7d

Browse files
Merge pull request #46 from jeremymefford/build-fix-2
[PATCH] docker build fix
2 parents 8287b35 + f9205f6 commit 49fcb7d

File tree

4 files changed

+24
-7
lines changed

4 files changed

+24
-7
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ coverage
99
.nyc_output
1010

1111
docs
12+
!docs/static/img/logo.svg
1213
tests
1314

1415
*.log

.github/workflows/release.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,10 @@ jobs:
151151
environment:
152152
name: prod
153153
steps:
154-
- name: Checkout
154+
- name: Checkout release commit
155155
uses: actions/checkout@v4
156156
with:
157+
ref: main
157158
fetch-depth: 0
158159

159160
- name: Set up Node.js
@@ -190,9 +191,10 @@ jobs:
190191
environment:
191192
name: prod
192193
steps:
193-
- name: Checkout
194+
- name: Checkout release commit
194195
uses: actions/checkout@v4
195196
with:
197+
ref: main
196198
fetch-depth: 0
197199

198200
- name: Set up Node.js
@@ -225,9 +227,10 @@ jobs:
225227
environment:
226228
name: prod
227229
steps:
228-
- name: Checkout
230+
- name: Checkout release commit
229231
uses: actions/checkout@v4
230232
with:
233+
ref: main
231234
fetch-depth: 0
232235

233236
- name: Set up Node.js
@@ -261,9 +264,10 @@ jobs:
261264
environment:
262265
name: prod
263266
steps:
264-
- name: Checkout
267+
- name: Checkout release commit
265268
uses: actions/checkout@v4
266269
with:
270+
ref: main
267271
fetch-depth: 0
268272

269273
- name: Set up Node.js
@@ -368,9 +372,10 @@ jobs:
368372
if: needs.prepare-release.outputs.should_release == 'true'
369373
runs-on: ubuntu-latest
370374
steps:
371-
- name: Checkout
375+
- name: Checkout release commit
372376
uses: actions/checkout@v4
373377
with:
378+
ref: main
374379
fetch-depth: 0
375380

376381
- name: Set up QEMU (multi-arch)

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ ENV NODE_ENV=production \
5757
COPY --from=prod-deps --chown=node:node /app/node_modules ./node_modules
5858
COPY --from=builder --chown=node:node /app/package*.json ./
5959
COPY --from=builder --chown=node:node /app/dist ./dist
60+
COPY --from=builder --chown=node:node /app/docs/static/img/logo.svg ./docs/static/img/logo.svg
6061

6162
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
6263
CMD ["node", "-e", "const p=(process.env.PORT||'4000'); const u='http://127.0.0.1:'+p+'/health'; fetch(u).then(r=>r.ok?r.json():Promise.reject()).then(j=>{if(!(j&&j.status==='ok'))process.exit(1)}).catch(()=>process.exit(1))"]

src/server/index.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import Fastify, {
55
type FastifyReply,
66
type FastifyRequest,
77
} from "fastify";
8+
import { existsSync } from "node:fs";
89
import path from "node:path";
910
import { loadBundledAsset } from "./assetLoader";
1011
import fastifyCors from "@fastify/cors";
@@ -30,8 +31,17 @@ import { graphiqlLandingPagePlugin } from "./graphiqlPlugin";
3031
/**
3132
* Initialize and start the Apollo GraphQL server (standalone HTTP/HTTPS server).
3233
*/
33-
/** Project root — two levels up from src/server/ (or dist/server/). */
34-
const projectRoot = path.resolve(__dirname, "..", "..");
34+
/** Project root — walks up from __dirname until we find package.json. */
35+
const projectRoot = (() => {
36+
let dir = __dirname;
37+
for (let i = 0; i < 5; i++) {
38+
if (existsSync(path.join(dir, "package.json"))) return dir;
39+
const parent = path.dirname(dir);
40+
if (parent === dir) break;
41+
dir = parent;
42+
}
43+
return dir;
44+
})();
3545

3646
export async function startServer(): Promise<void> {
3747
const armor = new ApolloArmor({

0 commit comments

Comments
 (0)