Skip to content

Commit 7def177

Browse files
committed
[NDH-301] add i18next dependency, address frontend dependency confusion
1 parent 2f4c890 commit 7def177

File tree

5 files changed

+68
-8
lines changed

5 files changed

+68
-8
lines changed

backend/docker-compose.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ services:
6565
- '8000:8000'
6666
volumes:
6767
- '.:/app'
68-
- ./artifacts:/app/artifacts
68+
- ./artifacts:/app/artifacts:rw
69+
- ./provider_directory/static:/app/provider_directory/static:rw
6970
depends_on:
7071
- db
7172

frontend/.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
**/node_modules
2+

frontend/README.md

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,35 @@ From the `npd` project root:
3434

3535
1. Ensure that a suitable docker service is running
3636
1. Run `docker compose up --build` to launch the backend and frontend applications
37+
- If you want to run the application backend and frontend separately, you can do that with:
38+
```console
39+
~/npd $ docker compose up -d django-web
40+
~/npd $ docker compose up -d web
41+
```
42+
1. Happy coding!
3743

38-
- If you want to run the application backend and frontend separately, you can do that with:
39-
```console
40-
~/npd $ docker compose up -d django-web
41-
~/npd $ docker compose up -d web
42-
```
44+
### Adding Dependencies
4345

44-
1. Happy coding!
46+
Because of our current frontend docker compose setup, new dependencies **MUST** be installed with `docker compose run web npm install`. They will not be picked up by `docker compose build web` or `docker compose up --build web`.
47+
48+
The reason is that we are mounting a virtual docker compose volume in place of the container's `/app/node_modules` directory, but `docker compose build` doesn't know about _runtime_ volume mounts, only _host_ and _base image_ mounts, so it cannot update the docker compose virtual volume, only the directory which is present inside the image during the build process.
49+
50+
For us, this means that if you are running in docker containers with `docker compose` and want to add a frontend dependency, you'll need to make sure they are added inside the running container with `docker compose run npm install`, as well as outside (on your host machine) if you need that for editor support or to run `npm` commands on host.
51+
52+
```sh
53+
# install and save a new dependency on host, to make the editor tooling happy
54+
cd frontend
55+
npm install --save i18next
56+
57+
# in docker, to make the image happy
58+
docker compose run --rm web npm install
59+
```
60+
61+
Likewise, if `package.json` has been updated since you last fetched project updates, you'll need to run:
62+
63+
```sh
64+
# after `git pull` when frontend/package.json has been updated
65+
docker compse run --rm web npm install
66+
```
67+
68+
to refresh your local frontend docker compose `web` service.

frontend/package-lock.json

Lines changed: 33 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"@cmsgov/design-system": "^13.0.0",
1919
"@uswds/uswds": "3.13.0",
2020
"classnames": "^2.5.1",
21+
"i18next": "^25.6.0",
2122
"react": "^19.1.1",
2223
"react-dom": "^19.1.1",
2324
"react-router": "^7.9.4"

0 commit comments

Comments
 (0)