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

Commit 4b15d6a

Browse files
committed
breadcrumbs and nav info
1 parent ff3c8c1 commit 4b15d6a

File tree

503 files changed

+39937
-7
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

503 files changed

+39937
-7
lines changed

docs/reference/cli.mdx

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
export const description = 'Reference docs for the Nitric CLI'
2+
3+
# Nitric CLI
4+
5+
The Nitric CLI allows you to build, develop, and deploy your serverless application.
6+
7+
To verify your [installation](/getting-started/installation) run `nitric version`. If a version is printed, the CLI is installed correctly.
8+
9+
To get a list of the available commands, run the `nitric help` command and you will see the following:
10+
11+
```text file=<rootDir>/src/assets/cli-usage.txt
12+
13+
```
14+
15+
## Common Commands
16+
17+
There are a few common commands that you will use frequently:
18+
19+
- `nitric new` creates a new project
20+
- `nitric stack new` creates a new stack within a project
21+
- `nitric start` runs the Nitric server locally
22+
- `nitric up` deploys your stack to the cloud
23+
- `nitric down` destroys your stack from the cloud
24+
25+
## Getting Started
26+
27+
### Projects
28+
29+
To start a new project with nitric, run the `nitric new` command.
30+
31+
```
32+
nitric new
33+
```
34+
35+
This will walk through creating the project, including the name and what template you want to start from.
36+
37+
The command will also create a `nitric.yaml` file. This file contains the configuration for your project. The services key is list of globs for your services. The services should point to all services you want to run or deploy.
38+
39+
```yaml
40+
name: my-project
41+
services:
42+
- match: services/*.ts
43+
start: ts-node $SERVICE_PATH
44+
```
45+
46+
If you want to specify a specific type of service that matches your stack config, you can use this syntax instead:
47+
48+
```yaml
49+
name: my-project
50+
services:
51+
- match: services/*.ts
52+
start: ts-node $SERVICE_PATH
53+
type: default
54+
- match: custom/*.ts
55+
start: ts-node $SERVICE_PATH
56+
type: memory-optimized
57+
```
58+
59+
### Stacks
60+
61+
Creating a new stack will create a configuration for a particular cloud. You can have multiple stacks for one project.
62+
63+
```
64+
nitric stack new
65+
```
66+
67+
This will create a `nitric.stackName.yaml` file that contains the configuration for deploying to the cloud. Some providers will have different config, here's an example of an aws stack:
68+
69+
```yaml
70+
# nitric.my-aws-stack.yaml
71+
provider: nitric/[email protected]
72+
region: us-east-1
73+
```
74+
75+
<Note>The cloud configuration is separate to the cloud credentials.</Note>
76+
77+
<Note>
78+
You will still have to set your cloud credentials on your first deployment by
79+
following the guide in the cloud's section in the reference documentation.
80+
</Note>
81+
82+
If you want to specify different configuration for your services you can use the following syntax:
83+
84+
```yaml
85+
# nitric.my-aws-stack.yaml
86+
provider: nitric/[email protected]
87+
region: us-east-1
88+
telemetry: 10
89+
config:
90+
default:
91+
lambda:
92+
memory: 1024
93+
memory-optimized:
94+
lambda:
95+
memory: 4096
96+
```
97+
98+
## Development
99+
100+
When you are ready to test your application and you want to run it locally, you can use the `nitric start` command.
101+
102+
```
103+
nitric start
104+
```
105+
106+
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.
107+
108+
For more information on local development, see the [local development](/reference/cli/local-development) docs.
109+
110+
## Deployment
111+
112+
### Deploying the Stack
113+
114+
Once you have tested your application locally and you're ready to deploy, you can do `nitric up`. This command can be optionally supplied with the name of a stack with the `-s` or `--stack` argument. However, the stack will be auto-detected if there is only one or options will be presented if there are multiple. This will set the cloud configuration for that particular deployment.
115+
116+
If this is your first deployment, you will have to set up your cloud credentials before deploying to the cloud. You can find the guides for these in the cloud's section in the reference documentation. The AWS guide is [here](/reference/providers/aws).
117+
118+
```bash
119+
nitric up
120+
```
121+
122+
<Note>
123+
Each of the cloud provider's deployments take different amounts of time.
124+
</Note>
125+
126+
### Destroying the Deployment
127+
128+
If you make changes and want to redeploy, you don't have to take the application down, you can just redeploy and it will find the difference. However, if you do want to destroy the application completely, you can use the `nitric down` command.
129+
130+
```
131+
nitric down
132+
```
133+
134+
<Note>This will prompt you again before destroying the stack.</Note>
135+
136+
### Listing Stacks
137+
138+
To get information about your stacks, use the `nitric stack list` command.
139+
140+
This will provide give information about its name, its deployment status, when it was last updated, the resource count, and a url to view the deployment on the pulumi console (will require a pulumi account).
141+
142+
## Info
143+
144+
To get information about the CLI version you are using, you can use:
145+
146+
```
147+
nitric version
148+
```
149+
150+
For information regarding individual commands, use the `--help` argument on any of the CLI commands. Alternatively you can run:
151+
152+
```
153+
nitric help
154+
```
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
export const description = 'Basic installation instructions for the Nitric CLI'
2+
3+
# CLI Installation
4+
5+
## Prerequisites
6+
7+
Nitric relies on functionality from the following projects to help retrieve plugins, containerize and deploy your application.
8+
9+
Please follow these links to the official installation steps for each.
10+
11+
- [Git](https://git-scm.com/)
12+
- [Docker](https://docs.docker.com/get-docker/)
13+
- [Docker Buildx](https://github.com/docker/buildx/)
14+
- [Pulumi](https://www.pulumi.com/docs/cli/) _(for deployments, only needed if using the default providers)_
15+
16+
<Note>
17+
When setting up docker on Linux be sure to follow the [post-installation
18+
steps](https://docs.docker.com/engine/install/linux-postinstall/) so you can
19+
run docker as a non-root user.
20+
</Note>
21+
22+
## Installing the Nitric CLI
23+
24+
<CodeGroup>
25+
26+
```bash {{ title: 'macOS' }}
27+
brew install nitrictech/tap/nitric
28+
```
29+
30+
```bash {{ title: 'Windows' }}
31+
scoop bucket add nitric https://github.com/nitrictech/scoop-bucket.git
32+
scoop install nitric
33+
```
34+
35+
```bash {{ title: 'Linux' }}
36+
curl -L https://nitric.io/install?version=latest | bash
37+
```
38+
39+
</CodeGroup>
40+
41+
### Manual Install
42+
43+
You can download pre-compiled binaries from the [releases](https://github.com/nitrictech/cli/releases) page and copy them into your desired location
44+
45+
## Update to the latest version
46+
47+
<CodeGroup>
48+
49+
```bash {{ title: 'macOS' }}
50+
brew upgrade nitric
51+
```
52+
53+
```bash {{ title: 'Windows' }}
54+
scoop update nitric
55+
```
56+
57+
```bash {{ title: 'Linux' }}
58+
curl -L https://nitric.io/install?version=latest | bash
59+
```
60+
61+
</CodeGroup>
62+
63+
You can easily check which version you're on by running `nitric version`.
64+
65+
## Release notes
66+
67+
You can view the CLI release notes on our [CLI GitHub Releases page](https://github.com/nitrictech/cli/releases).
68+
69+
## What's next
70+
71+
Checkout out our [concepts](/concepts/how-nitric-works) page for a quick overview of Nitric.
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 to 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)