This repository has been archived by the owner on Jun 20, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
103 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
# Development with docker | ||
|
||
|
||
There is a trick on how to make docker listen to file changes. | ||
Based on the [issue](https://github.com/fuse-box/fuse-box/issues/1041) | ||
|
||
|
||
## Configuring | ||
Working task: | ||
|
||
```js | ||
task('start:dev', async (ctx) => { | ||
const fuseConfig = ctx.getConfig(); | ||
|
||
fuseConfig | ||
.bundle('app') | ||
.instructions('> client.tsx') | ||
.watch() | ||
.hmr(); | ||
|
||
fuseConfig.dev({ | ||
port: 4444, | ||
httpServer: true, | ||
root: 'public' | ||
}); | ||
|
||
return await fuseConfig.run({ | ||
chokidar: { | ||
usePolling: true | ||
} | ||
}); | ||
}); | ||
``` | ||
|
||
docker-compose.yml: | ||
``` | ||
version: "3" | ||
services: | ||
gridplus-takehome-web: | ||
restart: always | ||
container_name: gridplus-takehome | ||
build: | ||
context: . | ||
dockerfile: ./Dockerfile.dev | ||
ports: | ||
- 4444:4444 | ||
volumes: | ||
- .:/usr/app | ||
``` | ||
|
||
For anyone else that uses bot docker and non-docker environments, here are the task that I made so that I can still take advantage of non-polling environments: | ||
```js | ||
task('init:dev', async (ctx) => { | ||
const fuseConfig = ctx.getConfig(); | ||
|
||
fuseConfig | ||
.bundle('app') | ||
.instructions('> client.tsx') | ||
.watch() | ||
.hmr(); | ||
|
||
fuseConfig.dev({ | ||
port: 4444, | ||
httpServer: true, | ||
root: 'public' | ||
}); | ||
}); | ||
|
||
task('start:dev', ['init:dev'], async (ctx) => { | ||
const fuseConfig = ctx.getConfig(); | ||
|
||
return await fuseConfig.run(); | ||
}); | ||
|
||
task('start-docker:dev', ['init:dev'], async (ctx) => { | ||
const fuseConfig = ctx.getConfig(); | ||
|
||
return await fuseConfig.run({ | ||
// https://github.com/paulmillr/chokidar | ||
chokidar: { | ||
persistent: true, | ||
|
||
ignored: '*.txt', | ||
ignoreInitial: false, | ||
followSymlinks: true, | ||
cwd: '.', | ||
disableGlobbing: false, | ||
|
||
usePolling: true, | ||
interval: 75, | ||
binaryInterval: 300, | ||
alwaysStat: false, | ||
depth: 99, | ||
awaitWriteFinish: false, | ||
|
||
ignorePermissionErrors: false, | ||
atomic: true | ||
} | ||
}); | ||
}); | ||
``` |