|
1 | 1 | # CarRental
|
2 |
| - |
3 |
| -<a alt="Nx logo" href="https://nx.dev" target="_blank" rel="noreferrer"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-logo.png" width="45"></a> |
4 |
| - |
5 |
| -✨ Your new, shiny [Nx workspace](https://nx.dev) is almost ready ✨. |
6 |
| - |
7 |
| -[Learn more about this workspace setup and its capabilities](https://nx.dev/getting-started/tutorials/angular-monorepo-tutorial?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) or run `npx nx graph` to visually explore what was created. Now, let's get you up to speed! |
8 |
| - |
9 |
| -## Finish your CI setup |
10 |
| - |
11 |
| -[Click here to finish setting up your workspace!](https://cloud.nx.app/connect/kbaIff4u91) |
12 |
| - |
13 |
| - |
14 |
| -## Run tasks |
15 |
| - |
16 |
| -To run the dev server for your app, use: |
17 |
| - |
18 |
| -```sh |
19 |
| -npx nx serve car-rental |
20 |
| -``` |
21 |
| - |
22 |
| -To create a production bundle: |
| 2 | +## Docker Compose Setup |
| 3 | + |
| 4 | +This project uses Docker Compose to manage the development environment. The setup includes three services: `db`, `backend`, and `frontend`. |
| 5 | + |
| 6 | +### Services |
| 7 | + |
| 8 | +#### Database (`db`) |
| 9 | + |
| 10 | +- **Image**: `mysql:8.0` |
| 11 | +- **Ports**: `3306:3306` |
| 12 | +- **Container Name**: `car_rental_db` |
| 13 | +- **Environment Variables**: |
| 14 | + - `MYSQL_ROOT_PASSWORD` |
| 15 | + - `MYSQL_DATABASE` |
| 16 | + - `MYSQL_CHARSET`: `utf8mb4` |
| 17 | + - `MYSQL_COLLATION`: `utf8mb4_unicode_ci` |
| 18 | +- **Volumes**: |
| 19 | + - `./my.cnf:/etc/mysql/conf.d/my.cnf` |
| 20 | + - `./mysql:/var/lib/mysql` |
| 21 | + - `./scripts:/docker-entrypoint-initdb.d:ro` |
| 22 | + |
| 23 | +#### Backend (`backend`) |
| 24 | + |
| 25 | +- **Build Context**: `./apps/car-rental-backend` |
| 26 | +- **Dockerfile**: `./apps/car-rental-backend/Dockerfile` |
| 27 | +- **Command**: `npm run serve:car-rental-backend` |
| 28 | +- **Container Name**: `car_rental_backend` |
| 29 | +- **Expose**: `3000` |
| 30 | +- **Ports**: `3000:3000` |
| 31 | +- **Depends On**: `db` |
| 32 | +- **Environment Variables**: |
| 33 | + - `DATABASE_HOST`: `db` |
| 34 | + - `DATABASE_PORT`: `3306` |
| 35 | + - `DATABASE_USER` |
| 36 | + - `DATABASE_PASSWORD` |
| 37 | + - `DATABASE_NAME` |
| 38 | +- **Volumes**: |
| 39 | + - `.:/app` |
| 40 | + - `/app/node_modules` |
| 41 | + |
| 42 | +#### Frontend (`frontend`) |
| 43 | + |
| 44 | +- **Build Context**: `./apps/car-rental` |
| 45 | +- **Dockerfile**: `./apps/car-rental/Dockerfile` |
| 46 | +- **Command**: `npm run serve:car-rental -- --host 0.0.0.0` |
| 47 | +- **Container Name**: `car_rental_frontend` |
| 48 | +- **Ports**: `4200:4200` |
| 49 | +- **Depends On**: `backend` |
| 50 | +- **Volumes**: |
| 51 | + - `.:/app` |
| 52 | + - `/app/node_modules` |
| 53 | + |
| 54 | +### Networks |
| 55 | + |
| 56 | +- **Default Network**: `car_rental_network` |
| 57 | + - **Driver**: `bridge` |
| 58 | + |
| 59 | +### Usage |
| 60 | + |
| 61 | +To start the services, run: |
23 | 62 |
|
24 | 63 | ```sh
|
25 |
| -npx nx build car-rental |
| 64 | +docker-compose up |
26 | 65 | ```
|
27 | 66 |
|
28 |
| -To see all available targets to run for a project, run: |
| 67 | +To stop the services, run: |
29 | 68 |
|
30 | 69 | ```sh
|
31 |
| -npx nx show project car-rental |
| 70 | +docker-compose down |
32 | 71 | ```
|
33 | 72 |
|
34 |
| -These targets are either [inferred automatically](https://nx.dev/concepts/inferred-tasks?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) or defined in the `project.json` or `package.json` files. |
35 |
| - |
36 |
| -[More about running tasks in the docs »](https://nx.dev/features/run-tasks?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) |
37 |
| - |
38 |
| -## Add new projects |
39 |
| - |
40 |
| -While you could add new projects to your workspace manually, you might want to leverage [Nx plugins](https://nx.dev/concepts/nx-plugins?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) and their [code generation](https://nx.dev/features/generate-code?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) feature. |
41 |
| - |
42 |
| -Use the plugin's generator to create new projects. |
43 |
| - |
44 |
| -To generate a new application, use: |
45 |
| - |
46 |
| -```sh |
47 |
| -npx nx g @nx/angular:app demo |
48 |
| -``` |
49 |
| - |
50 |
| -To generate a new library, use: |
51 |
| - |
52 |
| -```sh |
53 |
| -npx nx g @nx/angular:lib mylib |
54 |
| -``` |
55 |
| - |
56 |
| -You can use `npx nx list` to get a list of installed plugins. Then, run `npx nx list <plugin-name>` to learn about more specific capabilities of a particular plugin. Alternatively, [install Nx Console](https://nx.dev/getting-started/editor-setup?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) to browse plugins and generators in your IDE. |
57 |
| - |
58 |
| -[Learn more about Nx plugins »](https://nx.dev/concepts/nx-plugins?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) | [Browse the plugin registry »](https://nx.dev/plugin-registry?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) |
59 |
| - |
60 |
| - |
61 |
| -[Learn more about Nx on CI](https://nx.dev/ci/intro/ci-with-nx#ready-get-started-with-your-provider?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) |
62 |
| - |
63 |
| -## Install Nx Console |
64 |
| - |
65 |
| -Nx Console is an editor extension that enriches your developer experience. It lets you run tasks, generate code, and improves code autocompletion in your IDE. It is available for VSCode and IntelliJ. |
66 |
| - |
67 |
| -[Install Nx Console »](https://nx.dev/getting-started/editor-setup?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) |
68 |
| - |
69 |
| -## Useful links |
70 |
| - |
71 |
| -Learn more: |
72 |
| - |
73 |
| -- [Learn more about this workspace setup](https://nx.dev/getting-started/tutorials/angular-monorepo-tutorial?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) |
74 |
| -- [Learn about Nx on CI](https://nx.dev/ci/intro/ci-with-nx?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) |
75 |
| -- [Releasing Packages with Nx release](https://nx.dev/features/manage-releases?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) |
76 |
| -- [What are Nx plugins?](https://nx.dev/concepts/nx-plugins?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) |
77 |
| - |
78 |
| -And join the Nx community: |
79 |
| -- [Discord](https://go.nx.dev/community) |
80 |
| -- [Follow us on X](https://twitter.com/nxdevtools) or [LinkedIn](https://www.linkedin.com/company/nrwl) |
81 |
| -- [Our Youtube channel](https://www.youtube.com/@nxdevtools) |
82 |
| -- [Our blog](https://nx.dev/blog?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) |
| 73 | +For more information on Docker Compose, refer to the [official documentation](https://docs.docker.com/compose/). |
0 commit comments