Skip to content

Commit 00473eb

Browse files
Add docker documentation
1 parent be6513d commit 00473eb

File tree

4 files changed

+374
-92
lines changed

4 files changed

+374
-92
lines changed

14/umbraco-cms/fundamentals/setup/install/install-umbraco-with-templates.md

Lines changed: 90 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -37,54 +37,98 @@ From that command's output, you will get a better understanding of what are the
3737
Umbraco Project (C#)
3838
Author: Umbraco HQ
3939
Description: An empty Umbraco project ready to get started.
40-
Options:
41-
-v|--version The version of Umbraco.Cms to add as PackageReference.
42-
string - Optional
43-
Default: 10.0.0
44-
45-
--use-https-redirect Adds code to Program.cs to redirect HTTP to HTTPS and enables the UseHttps setting.
46-
bool - Optional
47-
Default: false
48-
49-
--no-restore If specified, skips the automatic restore of the project on create.
50-
bool - Optional
51-
Default: false
52-
53-
--exclude-gitignore Whether to exclude .gitignore from the generated template.
54-
bool - Optional
55-
Default: false
56-
57-
--minimal-gitignore Whether to only include minimal (Umbraco specific) rules in the .gitignore.
58-
bool - Optional
59-
Default: false
60-
61-
--connection-string Database connection string used by Umbraco.
62-
string - Optional
6340
64-
--connection-string-provider-name Database connection string provider name used by Umbraco.
65-
string - Optional
66-
Default: Microsoft.Data.SqlClient
41+
Usage:
42+
dotnet new umbraco [options] [template options]
6743
68-
--development-database-type Database type used by Umbraco for development.
69-
None - Do not configure a database for development.
70-
SQLite - Use embedded SQLite database.
71-
LocalDB - Use embedded LocalDB database (requires SQL Server Express with Advanced Services).
72-
Default: None
73-
74-
--friendly-name Used to specify the name of the default admin user when using unattended install on development (stored as plain text).
75-
string - Optional
76-
77-
--email Used to specify the email of the default admin user when using unattended install on development (stored as plain text).
78-
string - Optional
79-
80-
--password Used to specify the password of the default admin user when using unattended install on development (stored as plain text).
81-
string - Optional
82-
83-
--no-nodes-view-path Path to a custom view presented with the Umbraco installation contains no published content.
84-
string - Optional
85-
86-
-p|--PackageTestSiteName The name of the package project this should be a test site for.
87-
string - Optional
44+
Options:
45+
-n, --name <name> The name for the output being created. If no name is specified, the name of the output directory is used.
46+
-o, --output <output> Location to place the generated output.
47+
--dry-run Displays a summary of what would happen if the given command line were run if it would result in a template
48+
creation.
49+
--force Forces content to be generated even if it would change existing files.
50+
--no-update-check Disables checking for the template package updates when instantiating a template.
51+
--project <project> The project that should be used for context evaluation.
52+
-lang, --language <C#> Specifies the template language to instantiate.
53+
--type <project> Specifies the template type to instantiate.
54+
55+
Template options:
56+
-r, --release <Latest|LTS> The Umbraco release to use, either latest or latest long term supported
57+
Type: choice
58+
Latest The latest umbraco release
59+
LTS The most recent long term supported version
60+
Default: Latest
61+
--use-https-redirect Adds code to Startup.cs to redirect HTTP to HTTPS and enables the UseHttps setting.
62+
Type: bool
63+
Default: false
64+
-da, --use-delivery-api Enables the Delivery API
65+
Type: bool
66+
Default: false
67+
--add-docker Adds a docker file to the project.
68+
Type: bool
69+
Default: false
70+
--no-restore If specified, skips the automatic restore of the project on create.
71+
Type: bool
72+
Default: false
73+
--exclude-gitignore Whether to exclude .gitignore from the generated template.
74+
Type: bool
75+
Default: false
76+
--minimal-gitignore Whether to only include minimal (Umbraco specific) rules in the .gitignore.
77+
Type: bool
78+
Default: false
79+
--connection-string <connection-string> Database connection string used by Umbraco.
80+
Type: string
81+
--connection-string-provider-name Database connection string provider name used by Umbraco.
82+
<connection-string-provider-name> Type: string
83+
Default: Microsoft.Data.SqlClient
84+
--development-database-type <choice> Database type used by Umbraco for development.
85+
Type: choice
86+
None Do not configure a database for development.
87+
SQLite Use embedded SQLite database.
88+
LocalDB Use embedded LocalDB database (requires SQL Server Express with Advanced
89+
Services).
90+
Default: None
91+
--friendly-name <friendly-name> Used to specify the name of the default admin user when using unattended install on
92+
development (stored as plain text).
93+
Type: string
94+
--email <email> Used to specify the email of the default admin user when using unattended install on
95+
development (stored as plain text).
96+
Type: string
97+
--password <password> Used to specify the password of the default admin user when using unattended install on
98+
development (stored as plain text).
99+
Type: string
100+
--no-nodes-view-path <no-nodes-view-path> Path to a custom view presented with the Umbraco installation contains no published
101+
content.
102+
Type: string
103+
-dm, --development-mode <choice> Choose the development mode to use for the project.
104+
Type: choice
105+
BackofficeDevelopment Enables backoffice development, allowing you to develop from
106+
within the backoffice, this is the default behaviour.
107+
IDEDevelopment Configures appsettings.Development.json to Development runtime
108+
mode and SourceCodeAuto models builder mode, and configures appsettings.json to
109+
Production runtime mode, Nothing models builder mode, and enables UseHttps
110+
Default: BackofficeDevelopment
111+
-mm, --models-mode <choice> Choose the models builder mode to use for the project. When development mode is set to
112+
IDEDevelopment this only changes the models builder mode appsetttings.development.json
113+
Type: choice
114+
Default Let DevelopmentMode determine the models builder mode.
115+
InMemoryAuto Generate models in memory, automatically updating when a content
116+
type change, this means no need for app rebuild, however models are only available in
117+
views.
118+
SourceCodeManual Generate models as source code, only updating when requested
119+
manually, this means a interaction and rebuild is required when content type(s) change,
120+
however models are available in code.
121+
SourceCodeAuto Generate models as source code, automatically updating when a
122+
content type change, this means a rebuild is required when content type(s) change,
123+
however models are available in code.
124+
Nothing No models are generated, this is recommended for production assuming
125+
generated models are used for development.
126+
Default: Default
127+
-sk, --starter-kit <choice> Choose a starter kit to install.
128+
Type: choice
129+
None No starter kit.
130+
Umbraco.TheStarterKit The Umbraco starter kit.
131+
Default: None
88132
```
89133

90134
## Create an Umbraco project
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
---
2+
description: "Running Umbraco on docker locally using docker compose"
3+
---
4+
5+
# Running Umbraco in Docker using Docker Compose
6+
7+
To aid in developing Umbraco with additional services, the templates can provide the requisite files to run Umbraco with a SQL Server database in Docker.
8+
This setup is designed to be used for local development, and not for production.
9+
10+
## Prerequisites
11+
12+
Before you can run Umbraco in Docker, you need to have the following installed:
13+
* Version 14.3.0 or higher of the Umbraco Templates
14+
* Docker Desktop
15+
16+
## Installing
17+
18+
Installing Umbraco with the Docker file and Docker Compose file is a two-step process.
19+
20+
First, create a folder to hold your project and enter that folder.
21+
22+
```bash
23+
mkdir MyDockerProject
24+
cd MyDockerProject
25+
```
26+
Next create your Umbraco project using the Umbraco Templates, and remember to use the `--add-docker` flag to include the Docker files.
27+
Conventionally this is named the same as the folder, but is not a requirement.
28+
29+
```bash
30+
dotnet new umbraco -n MyDockerProject --add-docker
31+
```
32+
33+
Now we need to add some additional files to make docker compose work. We can do this using the `umbraco-compose` template, passing the project name wwe just specified to the `-P` parameter:
34+
35+
```bash
36+
dotnet new umbraco-compose -P "MyDockerProject"
37+
```
38+
39+
The `-P` flag is required to specify the correct paths in the docker-compose file. The project is now ready to run with docker compose.
40+
41+
The final folder structure looks like this:
42+
43+
* MyDockerProject
44+
* MyDockerProject
45+
* Typical project files
46+
* DockerFile
47+
* .dockerignore
48+
* .env
49+
* Database
50+
* DockerFile
51+
* healthcheck.sh
52+
* setup.sql
53+
* startup.sh
54+
* docker-compose.yml
55+
56+
As you can see the project now includes docker files for both Umbraco itself and the SQL server database, as well as some additional scripts to launch and configure the database.
57+
58+
It also includes a .env file with the password for the database.
59+
60+
## Running
61+
62+
To run the project run the `docker compose up` command from the root of the project, same folder as `docker-compose.yml`.
63+
64+
This command will build both the Umbraco and Sql Server images and launch them in the correct order, after a while the site will have booted and you can navigate to it in your browser like nomral on `http://localhost:44372/`
65+
66+
### Useful commands
67+
68+
There is some useful commands you can use to manage the docker containers:
69+
70+
* `docker compose down --volumes` This will delete your containers AND the volumes they use, this is useful if you want to start from scratch.
71+
72+
{% hint style="warning" %}
73+
This delete your database and all data in it, so be careful with this command.
74+
{% endhint %}
75+
76+
* `docker compose up --build` This will rebuild the images and start the containers, this is useful if you have made changes to the project and want to see them reflected in the running site.
77+
* `docker compose watch` This will start the containers and watch the default models folder, this means that if the project uses source code models builder the images automatically rebuilds and restarts when you change the models.
78+
79+
## Details
80+
81+
The docker compose file uses bind mounts for the following folders:
82+
83+
* /wwwroot/media
84+
* /wwwroot/scripts
85+
* /wwwroot/css
86+
* /Views
87+
* /models
88+
89+
This is bad for production, however, for local development this means that the files necessary for development are available from outside the container in your IDE allowing you to effectively develop even though the project is running in docker.
90+
91+
## Template options
92+
93+
The `umbraco-compose` template has a few options that can be used to customize the setup:
94+
95+
* -P or --project-name: The name of the project, this is required and used to set the correct paths in the docker-compose file.
96+
* -dbpw or --DatabasePasswor: Used to specify the database password, this is stored in the .env file, defaults to: Password1234
97+
* -p or --Port: Used to specify the port the site will run on, defaults to 44372

0 commit comments

Comments
 (0)