You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docker.md
+35-2
Original file line number
Diff line number
Diff line change
@@ -408,9 +408,13 @@ volumes:
408
408
name: nest-prisma-docker-db
409
409
```
410
410
411
-
After create docker-compose file, run this command: `docker compose up -d`
411
+
After create docker-compose file, run this command: `docker compose up -d`. This command Starts your services in detached mode (running in the background) and build the images if they don't exist. Otherwise, it uses existing images
412
412
413
-
**Wait for db run first**:
413
+
You can also use `docker compose up -d --build` to forces a rebuild of the images regardless of whether an image already exists. It ensures that any changes in your Dockerfile or build context are incorporated into the new image.
414
+
415
+
Using --build is particularly useful when you've updated your code or Dockerfile and want to make sure your containers are running the latest version.
416
+
417
+
### Wait for db run first
414
418
415
419
App can run already while db needs time to set up => we need to wait for db run first before running app
416
420
@@ -434,6 +438,35 @@ mysql:
434
438
retries: 20
435
439
```
436
440
441
+
## ENTRYPOINT
442
+
443
+
The purpose of
444
+
445
+
```Dockerfile
446
+
ENTRYPOINT ["./entrypoint.sh"]
447
+
```
448
+
449
+
is to set entrypoint.sh as the entry point for the container. This means when the container starts, it will always execute `entrypoint.sh` first before running any command specified in CMD or provided at runtime.
450
+
451
+
Why Use ENTRYPOINT?
452
+
453
+
1. Ensures a Script Runs Before Anything Else
454
+
-`entrypoint.sh` can be used to prepare the environment before the main process starts, such as:
455
+
- Replacing environment variables in configuration files
456
+
- Running database migrations
457
+
- Checking for required services (e.g., waiting for a database to be ready)
458
+
2. Allows Custom Commands While Keeping the Default Behavior
459
+
If you define:
460
+
461
+
```
462
+
ENTRYPOINT ["./entrypoint.sh"]
463
+
CMD ["nginx", "-g", "daemon off;"]
464
+
```
465
+
466
+
- The container will always execute entrypoint.sh first.
467
+
- After entrypoint.sh finishes, it will run nginx -g 'daemon off;' (from CMD).
468
+
- You can override CMD at runtime, but ENTRYPOINT will still execute first.
- singleton: true → Ensures only one instance of React is used across all apps.
155
159
- requiredVersion → Ensures a compatible version is used.
156
160
157
-
Then inside host app, we import the module like this: `import remoteAppContainer/Button`
161
+
Then inside host app, we import the module like this: `import remoteAppContainer/Button`. You can think of other remote container as a package and `remoteAppContainer` is the name of the package. Inside remote container, there are lots of exported modules. In this example, the module is `Button`.
0 commit comments