|
| 1 | +# Angular & Node.js |
| 2 | + |
| 3 | +[](https://portal.defang.dev/redirect?url=https%3A%2F%2Fgithub.com%2Fnew%3Ftemplate_name%3Dsample-angular-express-template%26template_owner%3DDefangSamples) |
| 4 | + |
| 5 | +This sample demonstrates how to deploy a full-stack Angular and Node.js application with Defang. It uses Socket.IO for real-time communication. The Docker setup ensures the app can be easily built and deployed. |
| 6 | + |
| 7 | +## Prerequisites |
| 8 | + |
| 9 | +1. Download [Defang CLI](https://github.com/DefangLabs/defang) |
| 10 | +2. (Optional) If you are using [Defang BYOC](https://docs.defang.io/docs/concepts/defang-byoc) authenticate with your cloud provider account |
| 11 | +3. (Optional for local development) [Docker CLI](https://docs.docker.com/engine/install/) |
| 12 | +4. Install [Node.js](https://nodejs.org/en/download/package-manager/) |
| 13 | +5. Install [Angular CLI](https://angular.io/cli) |
| 14 | + |
| 15 | +## Development |
| 16 | +For development, we use two local containers, one for the frontend Angular service and one for the backend service in Express. It also uses Caddy as a web server for serving static files. |
| 17 | + |
| 18 | +To run the application locally, you can use the following command: |
| 19 | + |
| 20 | +```bash |
| 21 | +docker compose -f compose.dev.yaml up --build |
| 22 | +``` |
| 23 | + |
| 24 | +## Configuration |
| 25 | + |
| 26 | +For this sample, you will not need to provide [configuration](https://docs.defang.io/docs/concepts/configuration). |
| 27 | + |
| 28 | +If you wish to provide configuration, see below for an example of setting a configuration for a value named `API_KEY`. |
| 29 | + |
| 30 | +```bash |
| 31 | +defang config set API_KEY |
| 32 | +``` |
| 33 | + |
| 34 | +## Deployment |
| 35 | + |
| 36 | +> [!NOTE] |
| 37 | +> Download [Defang CLI](https://github.com/DefangLabs/defang) |
| 38 | +
|
| 39 | +### Defang Playground |
| 40 | + |
| 41 | +Deploy your application to the Defang Playground by opening up your terminal and typing: |
| 42 | +```bash |
| 43 | +defang compose up |
| 44 | +``` |
| 45 | + |
| 46 | +### BYOC (AWS) |
| 47 | + |
| 48 | +If you want to deploy to your own cloud account, you can use Defang BYOC: |
| 49 | + |
| 50 | +1. [Authenticate your AWS account](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html), and check that you have properly set your environment variables like `AWS_PROFILE`, `AWS_REGION`, `AWS_ACCESS_KEY_ID`, and `AWS_SECRET_ACCESS_KEY`. |
| 51 | +2. Run in a terminal that has access to your AWS environment variables: |
| 52 | + ```bash |
| 53 | + defang --provider=aws compose up |
| 54 | + ``` |
| 55 | + |
| 56 | +--- |
| 57 | + |
| 58 | +Title: Angular & Node.js |
| 59 | + |
| 60 | +Short Description: A full-stack application using Angular for the frontend and Node.js with Socket.IO for the backend, containerized with Docker. |
| 61 | + |
| 62 | +Tags: Angular, Node.js, Socket.IO, TypeScript, JavaScript |
| 63 | + |
| 64 | +Languages: nodejs |
0 commit comments