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
ServiceStack templates now support deployment using Kamal, a CLI tool from the BaseCamp team that simplifies containerized application deployments. Kamal wraps SSH and Docker to streamline self-hosting while maintaining GitHub Actions as the CI runner.
5
+
All project templates includes the necessary GitHub Actions for CI/CD with automatic Docker image builds and
6
+
production deployment with Kamal to any Linux server with SSH. Kamal is a CLI tool from the BaseCamp team that simplifies containerized application deployments, wrapping SSH and Docker to streamline self-hosting while maintaining GitHub Actions as the CI runner.
Kamal enables simple commands to deploy containerized applications to Linux hosts, handling:
12
-
- Bootstrap configuration
13
-
- Reverse proxy setup
14
-
- SSL certificate provisioning
15
-
- Zero-downtime deployments
16
-
- Health checks on deploy
17
-
- Rolling back changes
13
+
-**Docker containerization** with optimized .NET images
14
+
-**Bootstrap configuration**
15
+
-**Reverse proxy setup**
16
+
-**SSL auto-certification** via Let's Encrypt
17
+
-**Zero-downtime deployments**
18
+
-**Health checks on deploy**
19
+
-**Rolling back changes**
20
+
-**Volume persistence** for App_Data including any SQLite database
21
+
-**GitHub Container Registry** integration
18
22
19
23
::: info
20
-
Kamal is built by the BaseCamp team, developers of Hey email service and BaseCamp project management tool. For comprehensive documentation on all Kamal features, visit [https://kamal-deploy.org/](https://kamal-deploy.org/)
24
+
Kamal is built by the BaseCamp team, developers of Hey.com and BaseCamp.com. For comprehensive documentation on all Kamal features, visit [https://kamal-deploy.org](https://kamal-deploy.org)
21
25
:::
22
26
27
+
### Hosting Recommendation
28
+
29
+
If you don't have a Linux Server, we recommend Hetzner
4. Configure GitHub Secrets for Kamal to access your deployment server:
48
60
49
-
The template includes a GitHub Actions workflow that is broken up into 3 steps that trigger on push to the `main` branch, and then on successful build and test, it will deploy the application to your server.
61
+
- SSH private key to access the server: ssh-rsa ...
62
+
:::sh
63
+
gh secret set SSH_PRIVATE_KEY < ~/deploy-key
64
+
:::
50
65
51
-
Once you create your GitHub repository, add the `SSH_PRIVATE_KEY` secret to your repository settings with the contents of your private key file.
66
+
- IP address of the server to deploy to: 100.100.100.100
These variables are inferred from the GitHub Action context and don't need to be configured.
132
+
133
+
| Variable | Source | Description |
134
+
|----------|--------|-------------|
135
+
|`GITHUB_REPOSITORY`|`${{github.repository}}`|`acme/example.org` - used for service name and image |
136
+
|`KAMAL_REGISTRY_USERNAME`|`${{github.actor}}`| GitHub username for container registry |
137
+
|`KAMAL_REGISTRY_PASSWORD`|`${{secrets.GITHUB_TOKEN}}`| GitHub token for container registry auth |
138
+
139
+
### GitHub Actions
140
+
141
+
The template includes a GitHub Actions workflow that is broken up into 3 steps that trigger on push to the `main` branch, and then on successful build and test, it will deploy the application to your server.
142
+
57
143
### Structure
58
144
59
145
The deployment scripts are embedded in the templates [/.github/workflows](https://github.com/NetCoreTemplates/blazor-vue/tree/main/.github/workflows):
@@ -64,6 +150,8 @@ The deployment scripts are embedded in the templates [/.github/workflows](https:
64
150
build-container.yml
65
151
release.yml
66
152
/.kamal
153
+
/hooks
154
+
secrets
67
155
/config
68
156
deploy.yml
69
157
```
@@ -80,59 +168,91 @@ Your App's Kamal deployment is configured in [config/deploy.yml](https://github.
80
168
81
169
### Configuration
82
170
83
-
Update `config/deploy.yml` with your deployment settings:
171
+
The [/config/deploy.yml](https://github.com/NetCoreTemplates/next-static/blob/main/config/deploy.yml) configuration
172
+
is designed to be reusable across projects as it dynamically derives service names, image paths, and volume mounts
173
+
from environment variables, so you only need to configure your server's IP and hostname using GitHub Action secrets.
174
+
175
+
Once you make these changes, commit and push to your repository to trigger the GitHub Actions workflow.
176
+
177
+
Kamal will deploy the required services including Docker and Kamal Proxy if your server doesn't already have them installed.
178
+
179
+
:::info
180
+
When using ASP.NET Core applications with Kamal-Proxy, ensure your application is running with the environment variable `ASPNETCORE_FORWARDEDHEADERS_ENABLED` set to `true`.
181
+
The template has this by default, but if you are getting errors with 302 redirects, ensure this is set.
182
+
:::
183
+
184
+
The authentication between GitHub Container Registry (ghcr.io) and your server is handled by the GitHub Actions workflow, the `deploy.yml` and [Kamal Secrets](https://kamal-deploy.org/docs/configuration/environment-variables/#secrets).
185
+
186
+
### Using Kamal Locally
187
+
188
+
To also be able to use kamal locally to inspect logs or deploy from your own server you can add the GitHub Action
189
+
Secrets into a local `.env` file, e.g:
190
+
191
+
```bash
192
+
# Required for Kamal deploy.yml template processing
The `image` value should match your GitHub repository path on ghcr.io. For example: `ghcr.io/username/repository`
208
+
You can then load the environment variables into your shell with:
209
+
210
+
:::sh
211
+
source ./load-env.sh
100
212
:::
101
213
102
-
Once you make these changes, commit and push to your repository to trigger the GitHub Actions workflow.
103
214
104
-
Kamal will deploy the required services including Docker and Kamal Proxy if you server doesn't already have them installed.
215
+
Which will allow you to use kamal locally to access your deployment server, e.g:
105
216
106
-
:::info
107
-
When using ASP.NET Core applications with Kamal-Proxy, ensure your application is running with the environment variable `ASPNETCORE_FORWARDEDHEADERS_ENABLED` set to `true`.
108
-
The template has this by default, but if you are getting errors with 302 redirects, ensure this is set.
217
+
:::sh
218
+
kamal app logs -f
109
219
:::
110
220
111
-
The authentication between GitHub Container Registry (ghcr.io) and your server is handled by the GitHub Actions workflow, the `deploy.yml` and [Kamal Secrets](https://kamal-deploy.org/docs/configuration/environment-variables/#secrets).
112
-
113
221
:::info
114
222
You can still use the Kamal CLI locally, but if you want to directly push deployments with `kamal deploy`, you will need to locally populate `KAMAL_REGISTRY_USER` and `KAMAL_REGISTRY_PASSWORD` with your GitHub username and a GitHub Personal Access Token with `read:packages` scope.
115
223
:::
116
224
225
+
### Hard code App specific variables
226
+
227
+
Alternatively if you don't want to maintain a `.env` with GitHub Action Secrets you can hard-code all
228
+
App-specific variables in your `deploy.yml` file so it doesn't need to perform any template processing
229
+
for its Environment Variable substitutions.
230
+
117
231
## Common Kamal Commands
118
232
119
233
Kamal provides several useful commands for managing your deployment:
120
234
121
-
```bash
122
-
# View deployment details
235
+
- View deployment details
236
+
:::sh
123
237
kamal details
238
+
:::
124
239
125
-
# Check application logs
126
-
kamal app logs
240
+
- Check application logs
241
+
:::sh
242
+
kamal app logs -f
243
+
:::
127
244
128
-
# Deploy new version
245
+
- Deploy new version
246
+
:::sh
129
247
kamal deploy
248
+
:::
130
249
131
-
# Restart application
250
+
- Restart application
251
+
:::sh
132
252
kamal app boot
133
-
```
253
+
:::
134
254
135
-
:::info
255
+
:::info
136
256
Kamal commands are context-aware and will use the configuration from your current application directory. This makes managing multiple applications across different servers a lot easier as more applications are added.
137
257
:::
138
258
@@ -151,6 +271,6 @@ Delete the `.<app-name>` file in your deployment user's home directory and re-ru
151
271
152
272
If you are getting:
153
273
154
-
Image ghcr.io/netcoreapps/northwindauto:latest is missing the 'service' label
274
+
Image ghcr.io/netcoreapps/northwindauto:latest is missing the 'service' label
155
275
156
-
Ensure that your AppHost csproj file has `ContainerLabel` with the value matching the `service` in your `deploy.yml` file.
276
+
Ensure your AppHost **csproj**has `ContainerLabel` with the value matching the `service` in your `deploy.yml`.
Copy file name to clipboardExpand all lines: MyApp/_pages/templates/index.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ slug: templates-overview
5
5
6
6
ServiceStack accelerates .NET development with battle-tested templates for building modern applications - from high-performance Web APIs and backend services to full-stack web apps, microservices, and cloud-native solutions. Whether you're building a Jamstack site, a Blazor application, or a serverless API, ServiceStack provides the foundation to ship faster.
7
7
8
-
:::copy
8
+
:::sh
9
9
npx create-net ls
10
10
:::
11
11
@@ -23,10 +23,10 @@ Where it will display all repositories in [.NET 10](https://github.com/NetCoreTe
23
23
$ npx create-net `<template>``<name>`
24
24
```
25
25
26
-
For example to create a new **Vue Single Page App**, run:
26
+
For example to create a new **Next.js statically generated React App**, run:
27
27
28
28
:::sh
29
-
npx create-net vue-spa ProjectName
29
+
npx create-net next-static ProjectName
30
30
:::
31
31
32
32
Or download a customized project template from our Getting Started Page:
description="A feature-rich React Single Page Application powered by Vite. Includes Blog functionality, Todos, shadcn/ui components, API Keys management, AI Chat capabilities, and Swagger UI - all integrated with a robust .NET backend."
0 commit comments