Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit 288ea14

Browse files
jyecuschdavemooreuwstjholm
authored
docs: add local dev documentations (#589)
Co-authored-by: David Moore <[email protected]> Co-authored-by: Tim Holm <[email protected]>
1 parent f952d48 commit 288ea14

File tree

5 files changed

+59
-1
lines changed

5 files changed

+59
-1
lines changed

dictionary.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ todo
196196
todos
197197
transpiling
198198
ARN
199+
HTTPS
199200
monorepos
200201

201202
^.+[-:_]\w+$
613 KB
Loading

src/nav.config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2943,6 +2943,10 @@ const fullNav: FullNav = {
29432943
title: 'Installation',
29442944
href: '/reference/cli/installation',
29452945
},
2946+
{
2947+
title: 'Local Development',
2948+
href: '/reference/cli/local-development',
2949+
},
29462950
{
29472951
title: 'Stacks',
29482952
href: '/reference/cli/stacks',

src/pages/reference/cli.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,16 @@ config:
9797
9898
## Development
9999
100-
When you are done developing your application and you want to run and test it locally, you can use the `nitric start` command.
100+
When you are ready to test your application and you want to run it locally, you can use the `nitric start` command.
101101

102102
```
103103
nitric start
104104
```
105105
106106
This will run the Nitric server for local testing. This will output local endpoints for your apis and open the [local dashboard](/getting-started/local-dashboard) for testing.
107107
108+
For more information on local development, see the [local development](/reference/cli/local-development) docs.
109+
108110
## Deployment
109111
110112
### Deploying the Stack
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
export const description = 'Local development with Nitric'
2+
3+
# Local Development
4+
5+
One of the key features of the Nitric CLI is the ability to run your application locally, using an environment that closely resembles what would be run in the cloud. This allows you to test your application locally before deploying it to the cloud.
6+
7+
Nitric is able to run a local environment that can serve your application, as well as any other services that your application may depend on such as queues, buckets, secrets, etc. This is done by using the `nitric start` command to run your application directly or by using `nitric run` to use Docker to run your application in containers, in both cases any other services that your application may depend on are either hosted by the CLI directly or by using Docker containers.
8+
9+
## Running your application directly
10+
11+
To run your application, you can use the `nitric start` command. This command starts your application and any other services it depends on. This is the recommended way to run your application locally as it is the simplest way to run your application, starts the fastest and makes attaching other tools like debuggers easier.
12+
13+
```bash
14+
nitric start
15+
```
16+
17+
Once the command starts, you'll be presented with a list of your running APIs and other services. You'll also see a link to the [local development dashboard](/getting-started/local-dashboard) where you can view a live architecture diagram of your running application and interact with various services for testing.
18+
19+
<img
20+
src="/docs/images/docs/dashboard-architecture.png"
21+
style={{ maxWidth: 800, width: '100%' }}
22+
alt="screen shot of the local development dashboard"
23+
/>
24+
25+
## Running your application in Containers
26+
27+
If you prefer to run your application in containers, you can use the `nitric run` command. This command builds and runs your application in Docker containers (one per service), along with any other services it depends on. This is useful if you want to run your application in an environment that more closely resembles the cloud, or if you want to run your application in a containerized environment. That said, this method is slower to start and may require more resources than running your application directly, it also makes attaching other tools like debuggers more difficult.
28+
29+
```bash
30+
nitric run
31+
```
32+
33+
The output for this command will be similar to the `nitric start` command.
34+
35+
## Stopping your application
36+
37+
In either case you can stop your application by pressing `Esc` or `Ctrl+C` in the terminal where you started your application.
38+
39+
## Enabling Https for local development
40+
41+
By default, Nitric will run your application's APIs and HTTP Proxies over HTTP to avoid common issues with self-signed certificates. In most cases, this is sufficient for local development. However, if you need to test your application over HTTPS, the `nitric start` command supports enabling HTTPS using the `--https-preview` flag.
42+
43+
This command will generate a self-signed certificate and key for your application and use them to serve your application over HTTPS. This is useful if you need to test your application over HTTPS locally, but keep in mind that self-signed certificates are not trusted by browsers and may cause security warnings.
44+
45+
```bash
46+
nitric start --https-preview
47+
```
48+
49+
If you need use a custom certificate and key, you can place them in the `.nitric/tls` directory in your project and Nitric will use them to serve your application over HTTPS. The files must be named `cert.pem` and `key.pem` respectively.
50+
51+
<Note>This feature is experimental and may change in future releases.</Note>

0 commit comments

Comments
 (0)