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

Demo a local daemonized cache with turborepo #475

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
12 changes: 12 additions & 0 deletions .env.turbo
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
PORT=12123
TURBO_TOKEN=example-token-for-turbo

# can also be s3
STORAGE_PROVIDER=local
STORAGE_PATH=/tmp/limber-turbo

# required of STORAGE_PROVIDER is s3
S3_ACCESS_KEY=
S3_SECRET_KEY=
S3_REGION=
S3_ENDPOINT=
2 changes: 1 addition & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
registry = https://registry.npmjs.org
ignore-scripts = false
ignore-scripts=true


public-hoist-pattern[]=*@types*
Expand Down
5 changes: 5 additions & 0 deletions .turbo/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"teamId": "team_my-fake-but-local-team",
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

per the docs, the teamId must begin with team_

"apiUrl": "http://localhost:12123"
}

19 changes: 19 additions & 0 deletions launch-daemon.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh

# On my test system, I didn't feel like setting up docker
# docker run \
# --env-file=.env.turbo \
# -p 3000:13000 \
# fox1t/turborepo-remote-cache
#
# We must provide a shell script to pm2,
# because pm2 doesn't fallback to trying shell eecution
# when the script doesn't happen to be js.
#
# maybe there are better daemon tools than pm2 out there.

(\
set -a \
&& . ./.env.turbo \
&& ./node_modules/.bin/turborepo-remote-cache \
)
12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@
"tests"
],
"scripts": {
"daemon": ". ./.env.turbo && (pm2 start ./launch-daemon.sh 2> /dev/null || true)",
"daemon:status": "pm2 ls",
"daemon:stop": "pm2 ./launch-daemon.sh",
"reset": "git clean -Xfd && pnpm install",
Copy link
Owner Author

@NullVoxPopuli NullVoxPopuli May 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reset, before I learned rm -rf node_modules/.cache was sufficient for testing turbo's cache

"predeploy": "turbo run build --filter=limber",
"build": "turbo run build --filter=limber^...",
"build": "pnpm daemon; set -a; . ./.env.turbo && turbo run build --filter=limber^...",
"lint": "turbo run lint",
"lint:fix": "turbo run lint:fix",
"start": "turbo run start --filter=limber"
"start": "pnpm daemon; set -a; . ./.env.turbo && turbo run start --filter=limber"
},
"volta": {
"node": "16.14.1",
Expand All @@ -21,7 +25,9 @@
},
"devDependencies": {
"concurrently": "^7.0.0",
"turbo": "^1.2.5"
"pm2": "^5.2.0",
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"turbo": "^1.2.9",
"turborepo-remote-cache": "^1.1.1"
},
"resolutions": {
"ember-auto-import": "^2.4.0",
Expand Down
Loading