Skip to content

Commit

Permalink
Switched to esbuild and bundle code into single file
Browse files Browse the repository at this point in the history
ref https://linear.app/ghost/issue/AP-550/overhaul-docker-testing-setup

- with this change, we do away with `tsx` in favor of straight
  `esbuild`, as `tsx` was proving to be problematic with our boot time
- we can just compile this to a single JS file to keep this fast
- this also changes the Docker workflow to use this and concurrently to
  watch and reload the files
  • Loading branch information
daniellockyer committed Nov 11, 2024
1 parent ec8d64f commit f6009df
Show file tree
Hide file tree
Showing 5 changed files with 173 additions and 152 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,6 @@ typings/

# Activitypub V 3 Final Custom
.direnv

# Build
dist/
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ COPY tsconfig.json .
COPY src ./src

ENV NODE_ENV=production
RUN yarn build

EXPOSE 8080

CMD ["node", "--import", "tsx", "src/app.ts"]
CMD ["node", "dist/app.js"]
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ services:
- NODE_ENV=testing
- ALLOW_PRIVATE_ADDRESS=true
- SKIP_SIGNATURE_VERIFICATION=true
command: node --import tsx --watch src/app.ts
command: yarn build:watch
depends_on:
mysql:
condition: service_healthy
Expand Down Expand Up @@ -96,7 +96,7 @@ services:
- SKIP_SIGNATURE_VERIFICATION=true
- ALLOW_PRIVATE_ADDRESS=true
- NODE_TLS_REJECT_UNAUTHORIZED=0
command: node --import tsx --watch src/app.ts
command: yarn build:watch
depends_on:
mysql-testing:
condition: service_healthy
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
"main": "src/app.ts",
"type": "module",
"scripts": {
"dev": "docker compose up activitypub nginx -d --no-recreate",
"build": "esbuild src/app.ts --platform=neutral --packages=external --bundle --outfile=dist/app.js",
"build:watch": "concurrently \"yarn build --watch\" \"node --watch dist/app.js\"",
"dev": "docker compose up activitypub nginx -d",
"stop": "docker compose stop",
"db": "docker compose exec mysql mysql -uroot -proot activitypub",
"fix": "docker compose rm activitypub nginx -sf && docker compose build activitypub nginx",
Expand All @@ -33,7 +35,8 @@
"@types/sinon": "17.0.3",
"@types/uuid": "10.0.0",
"@vitest/coverage-v8": "2.1.4",
"tsx": "4.19.2",
"concurrently": "9.1.0",
"esbuild": "0.24.0",
"typescript": "5.6.3",
"vitest": "2.1.4",
"wiremock-captain": "3.5.0"
Expand Down
Loading

0 comments on commit f6009df

Please sign in to comment.