From 7a2b9b56d48050f51e4f6f48b76f157aa233bfb1 Mon Sep 17 00:00:00 2001 From: Gabe Petersen Date: Tue, 24 Oct 2023 21:14:08 -0400 Subject: [PATCH 1/7] Add exclusive DB container directories This will add a .env file to each Docker project that specifies a DB_DIRECTORY. This environment variable will specify a new directory on /var/opt/mssql/host_data/ within the container so that the DB may persist when adding other docker projects of type mssql/server:2019-latest. --- templates/Alloy.Mvc/.env | 4 ++++ templates/Alloy.Mvc/Docker/create-db.sh | 6 ++++-- templates/Alloy.Mvc/docker-compose.yml | 9 +++++---- templates/Cms.Empty/.env | 4 ++++ templates/Cms.Empty/Docker/create-db.sh | 6 ++++-- templates/Cms.Empty/docker-compose.yml | 9 +++++---- templates/Commerce.Empty/.env | 5 +++++ templates/Commerce.Empty/Docker/create-db.sh | 8 +++++--- templates/Commerce.Empty/docker-compose.yml | 13 +++++++------ 9 files changed, 43 insertions(+), 21 deletions(-) create mode 100644 templates/Alloy.Mvc/.env create mode 100644 templates/Cms.Empty/.env create mode 100644 templates/Commerce.Empty/.env diff --git a/templates/Alloy.Mvc/.env b/templates/Alloy.Mvc/.env new file mode 100644 index 0000000..14c1c83 --- /dev/null +++ b/templates/Alloy.Mvc/.env @@ -0,0 +1,4 @@ +# These variables are used for passing values into docker-compose.yml and the containers +SA_PASSWORD=Qwerty12345! +DB_NAME=alloy_mvc_cms +DB_DIRECTORY=alloy-mvc diff --git a/templates/Alloy.Mvc/Docker/create-db.sh b/templates/Alloy.Mvc/Docker/create-db.sh index c3f11cc..404d15f 100644 --- a/templates/Alloy.Mvc/Docker/create-db.sh +++ b/templates/Alloy.Mvc/Docker/create-db.sh @@ -1,7 +1,9 @@ #!/bin/bash +echo "Creating database..." + for i in {1..100}; do - /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "$SA_PASSWORD" -Q "IF NOT EXISTS (SELECT * FROM sys.databases WHERE name = '${DB_NAME}') CREATE DATABASE ${DB_NAME} ON (NAME=${DB_NAME}_data, FILENAME='/var/opt/mssql/host_data/${DB_NAME}.mdf') LOG ON (NAME=${DB_NAME}_log, FILENAME='/var/opt/mssql/host_data/${DB_NAME}.ldf')" + /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "$SA_PASSWORD" -Q "IF NOT EXISTS (SELECT * FROM sys.databases WHERE name = '${DB_NAME}') CREATE DATABASE ${DB_NAME} ON (NAME=${DB_NAME}_data, FILENAME='/var/opt/mssql/host_data/${DB_DIRECTORY}/${DB_NAME}.mdf') LOG ON (NAME=${DB_NAME}_log, FILENAME='/var/opt/mssql/host_data/${DB_DIRECTORY}/${DB_NAME}.ldf')" if [ $? -eq 0 ]; then echo "Creating database completed" break @@ -9,4 +11,4 @@ for i in {1..100}; do echo "Creating database. Not ready yet..." sleep 1 fi -done \ No newline at end of file +done diff --git a/templates/Alloy.Mvc/docker-compose.yml b/templates/Alloy.Mvc/docker-compose.yml index 8444742..8bdd2f9 100644 --- a/templates/Alloy.Mvc/docker-compose.yml +++ b/templates/Alloy.Mvc/docker-compose.yml @@ -6,12 +6,13 @@ services: dockerfile: ./Docker/db.dockerfile context: . environment: - SA_PASSWORD: Qwerty12345! - DB_NAME: cms + SA_PASSWORD: ${SA_PASSWORD} + DB_NAME: ${DB_NAME} + DB_DIRECTORY: ${DB_DIRECTORY} ports: - 6000:1433 volumes: - - ./App_Data:/var/opt/mssql/host_data + - ./App_Data:/var/opt/mssql/host_data/${DB_DIRECTORY} image: Alloy.Mvc.1/db web: depends_on: @@ -22,7 +23,7 @@ services: environment: ASPNETCORE_URLS: http://*:80 ASPNETCORE_ENVIRONMENT: Development - CONNECTIONSTRINGS__EPISERVERDB: Server=db;Database=cms;User Id=sa;Password=Qwerty12345!;Encrypt=False; + CONNECTIONSTRINGS__EPISERVERDB: Server=db;Database=${DB_NAME};User Id=sa;Password=${SA_PASSWORD};Encrypt=False; ports: - 5000:80 volumes: diff --git a/templates/Cms.Empty/.env b/templates/Cms.Empty/.env new file mode 100644 index 0000000..01d806e --- /dev/null +++ b/templates/Cms.Empty/.env @@ -0,0 +1,4 @@ +# These variables are used for passing values into docker-compose.yml and the containers +SA_PASSWORD=Qwerty12345! +DB_NAME=cms_empty +DB_DIRECTORY=cms-empty diff --git a/templates/Cms.Empty/Docker/create-db.sh b/templates/Cms.Empty/Docker/create-db.sh index c3f11cc..404d15f 100644 --- a/templates/Cms.Empty/Docker/create-db.sh +++ b/templates/Cms.Empty/Docker/create-db.sh @@ -1,7 +1,9 @@ #!/bin/bash +echo "Creating database..." + for i in {1..100}; do - /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "$SA_PASSWORD" -Q "IF NOT EXISTS (SELECT * FROM sys.databases WHERE name = '${DB_NAME}') CREATE DATABASE ${DB_NAME} ON (NAME=${DB_NAME}_data, FILENAME='/var/opt/mssql/host_data/${DB_NAME}.mdf') LOG ON (NAME=${DB_NAME}_log, FILENAME='/var/opt/mssql/host_data/${DB_NAME}.ldf')" + /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "$SA_PASSWORD" -Q "IF NOT EXISTS (SELECT * FROM sys.databases WHERE name = '${DB_NAME}') CREATE DATABASE ${DB_NAME} ON (NAME=${DB_NAME}_data, FILENAME='/var/opt/mssql/host_data/${DB_DIRECTORY}/${DB_NAME}.mdf') LOG ON (NAME=${DB_NAME}_log, FILENAME='/var/opt/mssql/host_data/${DB_DIRECTORY}/${DB_NAME}.ldf')" if [ $? -eq 0 ]; then echo "Creating database completed" break @@ -9,4 +11,4 @@ for i in {1..100}; do echo "Creating database. Not ready yet..." sleep 1 fi -done \ No newline at end of file +done diff --git a/templates/Cms.Empty/docker-compose.yml b/templates/Cms.Empty/docker-compose.yml index 2c46f81..544d432 100644 --- a/templates/Cms.Empty/docker-compose.yml +++ b/templates/Cms.Empty/docker-compose.yml @@ -6,12 +6,13 @@ services: dockerfile: ./Docker/db.dockerfile context: . environment: - SA_PASSWORD: Qwerty12345! - DB_NAME: cms + SA_PASSWORD: ${SA_PASSWORD} + DB_NAME: ${DB_NAME} + DB_DIRECTORY: ${DB_DIRECTORY} ports: - 6000:1433 volumes: - - ./App_Data:/var/opt/mssql/host_data + - ./App_Data:/var/opt/mssql/host_data/${DB_DIRECTORY} image: Cms.Empty.1/db web: depends_on: @@ -22,7 +23,7 @@ services: environment: ASPNETCORE_URLS: http://*:80 ASPNETCORE_ENVIRONMENT: Development - CONNECTIONSTRINGS__EPISERVERDB: Server=db;Database=cms;User Id=sa;Password=Qwerty12345!;Encrypt=False; + CONNECTIONSTRINGS__EPISERVERDB: Server=db;Database=${DB_NAME};User Id=sa;Password=${SA_PASSWORD};Encrypt=False; ports: - 5000:80 volumes: diff --git a/templates/Commerce.Empty/.env b/templates/Commerce.Empty/.env new file mode 100644 index 0000000..c650605 --- /dev/null +++ b/templates/Commerce.Empty/.env @@ -0,0 +1,5 @@ +# These variables are used for passing values into docker-compose.yml and the containers +SA_PASSWORD=Qwerty12345! +DB_NAME=commerce_empty_cms +DB_NAME_COMMERCE=commerce_empty_commerce +DB_DIRECTORY=commerce-empty diff --git a/templates/Commerce.Empty/Docker/create-db.sh b/templates/Commerce.Empty/Docker/create-db.sh index 689b775..5057705 100644 --- a/templates/Commerce.Empty/Docker/create-db.sh +++ b/templates/Commerce.Empty/Docker/create-db.sh @@ -1,8 +1,10 @@ #!/bin/bash +echo "Creating database..." + for i in {1..100}; do - /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "$SA_PASSWORD" -Q "IF NOT EXISTS (SELECT * FROM sys.databases WHERE name = '${DB_NAME}') CREATE DATABASE ${DB_NAME} ON (NAME=${DB_NAME}_data, FILENAME='/var/opt/mssql/host_data/${DB_NAME}.mdf') LOG ON (NAME=${DB_NAME}_log, FILENAME='/var/opt/mssql/host_data/${DB_NAME}.ldf')" - /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "$SA_PASSWORD" -Q "IF NOT EXISTS (SELECT * FROM sys.databases WHERE name = '${DB_NAME_COMMERCE}') CREATE DATABASE ${DB_NAME_COMMERCE} ON (NAME=${DB_NAME_COMMERCE}_data, FILENAME='/var/opt/mssql/host_data/${DB_NAME_COMMERCE}.mdf') LOG ON (NAME=${DB_NAME_COMMERCE}_log, FILENAME='/var/opt/mssql/host_data/${DB_NAME_COMMERCE}.ldf')" + /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "$SA_PASSWORD" -Q "IF NOT EXISTS (SELECT * FROM sys.databases WHERE name = '${DB_NAME}') CREATE DATABASE ${DB_NAME} ON (NAME=${DB_NAME}_data, FILENAME='/var/opt/mssql/host_data/${DB_DIRECTORY}/${DB_NAME}.mdf') LOG ON (NAME=${DB_NAME}_log, FILENAME='/var/opt/mssql/host_data/${DB_DIRECTORY}/${DB_NAME}.ldf')" + /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "$SA_PASSWORD" -Q "IF NOT EXISTS (SELECT * FROM sys.databases WHERE name = '${DB_NAME_COMMERCE}') CREATE DATABASE ${DB_NAME_COMMERCE} ON (NAME=${DB_NAME_COMMERCE}_data, FILENAME='/var/opt/mssql/host_data/${DB_DIRECTORY}/${DB_NAME_COMMERCE}.mdf') LOG ON (NAME=${DB_NAME_COMMERCE}_log, FILENAME='/var/opt/mssql/host_data/${DB_DIRECTORY}/${DB_NAME_COMMERCE}.ldf')" if [ $? -eq 0 ]; then echo "Creating database completed" break @@ -10,4 +12,4 @@ for i in {1..100}; do echo "Creating database. Not ready yet..." sleep 1 fi -done \ No newline at end of file +done diff --git a/templates/Commerce.Empty/docker-compose.yml b/templates/Commerce.Empty/docker-compose.yml index 3fa2f68..50cefeb 100644 --- a/templates/Commerce.Empty/docker-compose.yml +++ b/templates/Commerce.Empty/docker-compose.yml @@ -6,13 +6,14 @@ services: dockerfile: ./Docker/db.dockerfile context: . environment: - SA_PASSWORD: Qwerty12345! - DB_NAME: cms - DB_NAME_COMMERCE: commerce + SA_PASSWORD: ${SA_PASSWORD} + DB_NAME: ${DB_NAME} + DB_NAME_COMMERCE: ${DB_NAME_COMMERCE} + DB_DIRECTORY: ${DB_DIRECTORY} ports: - 6000:1433 volumes: - - ./App_Data:/var/opt/mssql/host_data + - ./App_Data:/var/opt/mssql/host_data/${DB_DIRECTORY} image: Commerce.Empty.1/db web: depends_on: @@ -23,8 +24,8 @@ services: environment: ASPNETCORE_URLS: http://*:80 ASPNETCORE_ENVIRONMENT: Development - CONNECTIONSTRINGS__EPISERVERDB: Server=db;Database=cms;User Id=sa;Password=Qwerty12345!;Encrypt=False; - CONNECTIONSTRINGS__ECFSQLCONNECTION: Server=db;Database=commerce;User Id=sa;Password=Qwerty12345!;Encrypt=False; + CONNECTIONSTRINGS__EPISERVERDB: Server=db;Database=${DB_NAME};User Id=sa;Password=${SA_PASSWORD};Encrypt=False; + CONNECTIONSTRINGS__ECFSQLCONNECTION: Server=db;Database=${DB_NAME_COMMERCE};User Id=sa;Password=${SA_PASSWORD};Encrypt=False; ports: - 5000:80 volumes: From 3ca4fc27fff44e0089b24a5fbd7ebd740ed462e1 Mon Sep 17 00:00:00 2001 From: Gabe Petersen Date: Tue, 24 Oct 2023 22:22:35 -0400 Subject: [PATCH 2/7] Attach .mdf/.ldf if they exist in container If the container and its network are deleted, then the databases will be dropped. So when `docker compose up` runs again to create the containers, then the `CREATE DATABASE` command won't work since there is already a .mdf/.ldf file existent. This is why the `FOR ATTACH` command is needed in this case if the files already exist. --- templates/Alloy.Mvc/Docker/create-db.sh | 13 ++++++-- templates/Cms.Empty/Docker/create-db.sh | 13 ++++++-- templates/Commerce.Empty/Docker/create-db.sh | 32 ++++++++++++++++---- 3 files changed, 48 insertions(+), 10 deletions(-) diff --git a/templates/Alloy.Mvc/Docker/create-db.sh b/templates/Alloy.Mvc/Docker/create-db.sh index 404d15f..0f14ec7 100644 --- a/templates/Alloy.Mvc/Docker/create-db.sh +++ b/templates/Alloy.Mvc/Docker/create-db.sh @@ -2,9 +2,18 @@ echo "Creating database..." +let result=1 + for i in {1..100}; do - /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "$SA_PASSWORD" -Q "IF NOT EXISTS (SELECT * FROM sys.databases WHERE name = '${DB_NAME}') CREATE DATABASE ${DB_NAME} ON (NAME=${DB_NAME}_data, FILENAME='/var/opt/mssql/host_data/${DB_DIRECTORY}/${DB_NAME}.mdf') LOG ON (NAME=${DB_NAME}_log, FILENAME='/var/opt/mssql/host_data/${DB_DIRECTORY}/${DB_NAME}.ldf')" - if [ $? -eq 0 ]; then + if test -f /var/opt/mssql/host_data/${DB_DIRECTORY}/${DB_NAME}.mdf; then + echo "Restoring from .mdf/.ldf" + /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "$SA_PASSWORD" -Q "IF NOT EXISTS (SELECT * FROM sys.databases WHERE name = '${DB_NAME}') CREATE DATABASE ${DB_NAME} ON (NAME=${DB_NAME}_data, FILENAME='/var/opt/mssql/host_data/${DB_DIRECTORY}/${DB_NAME}.mdf') LOG ON (NAME=${DB_NAME}_log, FILENAME='/var/opt/mssql/host_data/${DB_DIRECTORY}/${DB_NAME}.ldf') FOR ATTACH;" + let result=$? + else + /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "$SA_PASSWORD" -Q "IF NOT EXISTS (SELECT * FROM sys.databases WHERE name = '${DB_NAME}') CREATE DATABASE ${DB_NAME} ON (NAME=${DB_NAME}_data, FILENAME='/var/opt/mssql/host_data/${DB_DIRECTORY}/${DB_NAME}.mdf') LOG ON (NAME=${DB_NAME}_log, FILENAME='/var/opt/mssql/host_data/${DB_DIRECTORY}/${DB_NAME}.ldf')" + let result=$? + fi + if [ $result -eq 0 ]; then echo "Creating database completed" break else diff --git a/templates/Cms.Empty/Docker/create-db.sh b/templates/Cms.Empty/Docker/create-db.sh index 404d15f..0f14ec7 100644 --- a/templates/Cms.Empty/Docker/create-db.sh +++ b/templates/Cms.Empty/Docker/create-db.sh @@ -2,9 +2,18 @@ echo "Creating database..." +let result=1 + for i in {1..100}; do - /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "$SA_PASSWORD" -Q "IF NOT EXISTS (SELECT * FROM sys.databases WHERE name = '${DB_NAME}') CREATE DATABASE ${DB_NAME} ON (NAME=${DB_NAME}_data, FILENAME='/var/opt/mssql/host_data/${DB_DIRECTORY}/${DB_NAME}.mdf') LOG ON (NAME=${DB_NAME}_log, FILENAME='/var/opt/mssql/host_data/${DB_DIRECTORY}/${DB_NAME}.ldf')" - if [ $? -eq 0 ]; then + if test -f /var/opt/mssql/host_data/${DB_DIRECTORY}/${DB_NAME}.mdf; then + echo "Restoring from .mdf/.ldf" + /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "$SA_PASSWORD" -Q "IF NOT EXISTS (SELECT * FROM sys.databases WHERE name = '${DB_NAME}') CREATE DATABASE ${DB_NAME} ON (NAME=${DB_NAME}_data, FILENAME='/var/opt/mssql/host_data/${DB_DIRECTORY}/${DB_NAME}.mdf') LOG ON (NAME=${DB_NAME}_log, FILENAME='/var/opt/mssql/host_data/${DB_DIRECTORY}/${DB_NAME}.ldf') FOR ATTACH;" + let result=$? + else + /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "$SA_PASSWORD" -Q "IF NOT EXISTS (SELECT * FROM sys.databases WHERE name = '${DB_NAME}') CREATE DATABASE ${DB_NAME} ON (NAME=${DB_NAME}_data, FILENAME='/var/opt/mssql/host_data/${DB_DIRECTORY}/${DB_NAME}.mdf') LOG ON (NAME=${DB_NAME}_log, FILENAME='/var/opt/mssql/host_data/${DB_DIRECTORY}/${DB_NAME}.ldf')" + let result=$? + fi + if [ $result -eq 0 ]; then echo "Creating database completed" break else diff --git a/templates/Commerce.Empty/Docker/create-db.sh b/templates/Commerce.Empty/Docker/create-db.sh index 5057705..d95982b 100644 --- a/templates/Commerce.Empty/Docker/create-db.sh +++ b/templates/Commerce.Empty/Docker/create-db.sh @@ -1,15 +1,35 @@ #!/bin/bash -echo "Creating database..." +echo "Creating databases..." + +let cmsresult=1 +let commerceresult=1 for i in {1..100}; do - /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "$SA_PASSWORD" -Q "IF NOT EXISTS (SELECT * FROM sys.databases WHERE name = '${DB_NAME}') CREATE DATABASE ${DB_NAME} ON (NAME=${DB_NAME}_data, FILENAME='/var/opt/mssql/host_data/${DB_DIRECTORY}/${DB_NAME}.mdf') LOG ON (NAME=${DB_NAME}_log, FILENAME='/var/opt/mssql/host_data/${DB_DIRECTORY}/${DB_NAME}.ldf')" - /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "$SA_PASSWORD" -Q "IF NOT EXISTS (SELECT * FROM sys.databases WHERE name = '${DB_NAME_COMMERCE}') CREATE DATABASE ${DB_NAME_COMMERCE} ON (NAME=${DB_NAME_COMMERCE}_data, FILENAME='/var/opt/mssql/host_data/${DB_DIRECTORY}/${DB_NAME_COMMERCE}.mdf') LOG ON (NAME=${DB_NAME_COMMERCE}_log, FILENAME='/var/opt/mssql/host_data/${DB_DIRECTORY}/${DB_NAME_COMMERCE}.ldf')" - if [ $? -eq 0 ]; then - echo "Creating database completed" + if test -f /var/opt/mssql/host_data/${DB_DIRECTORY}/${DB_NAME}.mdf; then + echo "Restoring CMS DB from .mdf/.ldf" + + /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "$SA_PASSWORD" -Q "IF NOT EXISTS (SELECT * FROM sys.databases WHERE name = '${DB_NAME}') CREATE DATABASE ${DB_NAME} ON (NAME=${DB_NAME}_data, FILENAME='/var/opt/mssql/host_data/${DB_DIRECTORY}/${DB_NAME}.mdf') LOG ON (NAME=${DB_NAME}_log, FILENAME='/var/opt/mssql/host_data/${DB_DIRECTORY}/${DB_NAME}.ldf') FOR ATTACH;" + let cmsresult=$? + else + /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "$SA_PASSWORD" -Q "IF NOT EXISTS (SELECT * FROM sys.databases WHERE name = '${DB_NAME}') CREATE DATABASE ${DB_NAME} ON (NAME=${DB_NAME}_data, FILENAME='/var/opt/mssql/host_data/${DB_DIRECTORY}/${DB_NAME}.mdf') LOG ON (NAME=${DB_NAME}_log, FILENAME='/var/opt/mssql/host_data/${DB_DIRECTORY}/${DB_NAME}.ldf')" + let cmsresult=$? + fi + + if test -f /var/opt/mssql/host_data/${DB_DIRECTORY}/${DB_NAME_COMMERCE}.mdf; then + echo "Restoring Commerce DB from .mdf/.ldf" + /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "$SA_PASSWORD" -Q "IF NOT EXISTS (SELECT * FROM sys.databases WHERE name = '${DB_NAME_COMMERCE}') CREATE DATABASE ${DB_NAME_COMMERCE} ON (NAME=${DB_NAME_COMMERCE}_data, FILENAME='/var/opt/mssql/host_data/${DB_DIRECTORY}/${DB_NAME_COMMERCE}.mdf') LOG ON (NAME=${DB_NAME_COMMERCE}_log, FILENAME='/var/opt/mssql/host_data/${DB_DIRECTORY}/${DB_NAME_COMMERCE}.ldf') FOR ATTACH;" + let commerceresult=$? + else + /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "$SA_PASSWORD" -Q "IF NOT EXISTS (SELECT * FROM sys.databases WHERE name = '${DB_NAME_COMMERCE}') CREATE DATABASE ${DB_NAME_COMMERCE} ON (NAME=${DB_NAME_COMMERCE}_data, FILENAME='/var/opt/mssql/host_data/${DB_DIRECTORY}/${DB_NAME_COMMERCE}.mdf') LOG ON (NAME=${DB_NAME_COMMERCE}_log, FILENAME='/var/opt/mssql/host_data/${DB_DIRECTORY}/${DB_NAME_COMMERCE}.ldf')" + let commerceresult=$? + fi + + if [ $cmsresult -eq 0 ] && [ $commerceresult -eq 0 ]; then + echo "Creating databases completed" break else - echo "Creating database. Not ready yet..." + echo "Creating databases. Not ready yet..." sleep 1 fi done From 128c0c90491ffc27fbc81b3f10ea6f1484b91d28 Mon Sep 17 00:00:00 2001 From: Gabe Petersen Date: Tue, 24 Oct 2023 22:33:57 -0400 Subject: [PATCH 3/7] Update README's for reclaiming docker space --- templates/Alloy.Mvc/README.md | 6 ++++++ templates/Cms.Empty/README.md | 6 ++++++ templates/Commerce.Empty/README.md | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/templates/Alloy.Mvc/README.md b/templates/Alloy.Mvc/README.md index fb363be..afe45f2 100644 --- a/templates/Alloy.Mvc/README.md +++ b/templates/Alloy.Mvc/README.md @@ -28,6 +28,12 @@ $ docker-compose up > Note that this Docker setup is just configured for local development. Follow this [guide to enable HTTPS](https://github.com/dotnet/dotnet-docker/blob/main/samples/run-aspnetcore-https-development.md). +#### Reclaiming Docker Image Space + +1. Backup the App_Data/\${DB_NAME}.mdf and App_Data/\${DB_NAME}.ldf DB restoration files for safety +2. Run `docker compose down --rmi all` to remove containers, networks, and images associated with the specific project instance +3. In the future, run `docker compose up` anytime you want to recreate the images and containers + ### Any OS with external database server Prerequisities diff --git a/templates/Cms.Empty/README.md b/templates/Cms.Empty/README.md index 47a3282..1ae7634 100644 --- a/templates/Cms.Empty/README.md +++ b/templates/Cms.Empty/README.md @@ -26,6 +26,12 @@ $ docker-compose up > Note that this Docker setup is just configured for local development. Follow this [guide to enable HTTPS](https://github.com/dotnet/dotnet-docker/blob/main/samples/run-aspnetcore-https-development.md). +#### Reclaiming Docker Image Space + +1. Backup the App_Data/\${DB_NAME}.mdf and App_Data/\${DB_NAME}.ldf DB restoration files for safety +2. Run `docker compose down --rmi all` to remove containers, networks, and images associated with the specific project instance +3. In the future, run `docker compose up` anytime you want to recreate the images and containers + ### Any OS with external database server Prerequisities diff --git a/templates/Commerce.Empty/README.md b/templates/Commerce.Empty/README.md index 5cb7750..1f23f31 100644 --- a/templates/Commerce.Empty/README.md +++ b/templates/Commerce.Empty/README.md @@ -26,6 +26,12 @@ $ docker-compose up > Note that this Docker setup is just configured for local development. Follow this [guide to enable HTTPS](https://github.com/dotnet/dotnet-docker/blob/main/samples/run-aspnetcore-https-development.md). +#### Reclaiming Docker Image Space + +1. Backup the App_Data/\${DB_NAME}.mdf and App_Data/\${DB_NAME}.ldf DB restoration files for safety +2. Run `docker compose down --rmi all` to remove containers, networks, and images associated with the specific project instance +3. In the future, run `docker compose up` anytime you want to recreate the images and containers + ### Any OS with external database server Prerequisities From ca48241f8a587426f85358bc8a4647a4b2fd54b4 Mon Sep 17 00:00:00 2001 From: Gabe Petersen Date: Tue, 24 Oct 2023 22:54:00 -0400 Subject: [PATCH 4/7] Update README's to check .env Docker variables --- templates/Alloy.Mvc/README.md | 1 + templates/Cms.Empty/README.md | 1 + templates/Commerce.Empty/README.md | 1 + 3 files changed, 3 insertions(+) diff --git a/templates/Alloy.Mvc/README.md b/templates/Alloy.Mvc/README.md index afe45f2..db4a370 100644 --- a/templates/Alloy.Mvc/README.md +++ b/templates/Alloy.Mvc/README.md @@ -21,6 +21,7 @@ $ dotnet run Prerequisities - Docker - Enable Docker support when applying the template +- Review the .env file and make changes where necessary to the Docker-related variables ```bash $ docker-compose up diff --git a/templates/Cms.Empty/README.md b/templates/Cms.Empty/README.md index 1ae7634..f8b59de 100644 --- a/templates/Cms.Empty/README.md +++ b/templates/Cms.Empty/README.md @@ -19,6 +19,7 @@ $ dotnet run Prerequisities - Docker - Enable Docker support when applying the template +- Review the .env file and make changes where necessary to the Docker-related variables ```bash $ docker-compose up diff --git a/templates/Commerce.Empty/README.md b/templates/Commerce.Empty/README.md index 1f23f31..234b93a 100644 --- a/templates/Commerce.Empty/README.md +++ b/templates/Commerce.Empty/README.md @@ -19,6 +19,7 @@ $ dotnet run Prerequisities - Docker - Enable Docker support when applying the template +- Review the .env file and make changes where necessary to the Docker-related variables ```bash $ docker-compose up From 182b656d6b8147586cf53f6ebc96d0441776c2eb Mon Sep 17 00:00:00 2001 From: Gabe Petersen Date: Thu, 2 Nov 2023 15:15:44 -0400 Subject: [PATCH 5/7] Add dotnet template sourceName support Fix in response to https://github.com/episerver/content-templates/pull/47#issuecomment-1784715529. See https://learn.microsoft.com/en-us/dotnet/core/tools/custom-templates for information on custom templates. --- templates/Alloy.Mvc/.env | 4 ++-- templates/Alloy.Mvc/.template.config/template.json | 3 ++- templates/Cms.Empty/.env | 4 ++-- templates/Cms.Empty/.template.config/template.json | 3 ++- templates/Commerce.Empty/.env | 4 ++-- templates/Commerce.Empty/.template.config/template.json | 3 ++- 6 files changed, 12 insertions(+), 9 deletions(-) diff --git a/templates/Alloy.Mvc/.env b/templates/Alloy.Mvc/.env index 14c1c83..bb927b4 100644 --- a/templates/Alloy.Mvc/.env +++ b/templates/Alloy.Mvc/.env @@ -1,4 +1,4 @@ # These variables are used for passing values into docker-compose.yml and the containers SA_PASSWORD=Qwerty12345! -DB_NAME=alloy_mvc_cms -DB_DIRECTORY=alloy-mvc +DB_NAME=Alloy.Mvc.1 +DB_DIRECTORY=Alloy.Mvc.1 diff --git a/templates/Alloy.Mvc/.template.config/template.json b/templates/Alloy.Mvc/.template.config/template.json index e8dbda1..e58d721 100644 --- a/templates/Alloy.Mvc/.template.config/template.json +++ b/templates/Alloy.Mvc/.template.config/template.json @@ -19,7 +19,8 @@ "exclude": [ "Directory.Build.props", "docker-compose.yml", - "Docker/**/*" + "Docker/**/*", + ".env" ] } ] diff --git a/templates/Cms.Empty/.env b/templates/Cms.Empty/.env index 01d806e..cf491ab 100644 --- a/templates/Cms.Empty/.env +++ b/templates/Cms.Empty/.env @@ -1,4 +1,4 @@ # These variables are used for passing values into docker-compose.yml and the containers SA_PASSWORD=Qwerty12345! -DB_NAME=cms_empty -DB_DIRECTORY=cms-empty +DB_NAME=Cms.Empty.1 +DB_DIRECTORY=Cms.Empty.1 diff --git a/templates/Cms.Empty/.template.config/template.json b/templates/Cms.Empty/.template.config/template.json index 50594f6..7fa80ca 100644 --- a/templates/Cms.Empty/.template.config/template.json +++ b/templates/Cms.Empty/.template.config/template.json @@ -19,7 +19,8 @@ "exclude": [ "Directory.Build.props", "docker-compose.yml", - "Docker/**/*" + "Docker/**/*", + ".env" ] } ] diff --git a/templates/Commerce.Empty/.env b/templates/Commerce.Empty/.env index c650605..d9e44bb 100644 --- a/templates/Commerce.Empty/.env +++ b/templates/Commerce.Empty/.env @@ -1,5 +1,5 @@ # These variables are used for passing values into docker-compose.yml and the containers SA_PASSWORD=Qwerty12345! -DB_NAME=commerce_empty_cms -DB_NAME_COMMERCE=commerce_empty_commerce +DB_NAME=Commerce.Empty.1_cms +DB_NAME_COMMERCE=Commerce.Empty.1_commerce DB_DIRECTORY=commerce-empty diff --git a/templates/Commerce.Empty/.template.config/template.json b/templates/Commerce.Empty/.template.config/template.json index 58e0a8b..ae3dc5f 100644 --- a/templates/Commerce.Empty/.template.config/template.json +++ b/templates/Commerce.Empty/.template.config/template.json @@ -19,7 +19,8 @@ "exclude": [ "Directory.Build.props", "docker-compose.yml", - "Docker/**/*" + "Docker/**/*", + ".env" ] } ] From 4a9d57cc7a81435fe44ffbd71202ba9cafd14c67 Mon Sep 17 00:00:00 2001 From: Gabe Petersen Date: Mon, 13 Nov 2023 10:29:24 -0500 Subject: [PATCH 6/7] Remove newlines in create DB bash files This will also fix the DB directory for the empty commerce template to be the variable of the project name --- templates/Alloy.Mvc/Docker/create-db.sh | 2 +- templates/Cms.Empty/Docker/create-db.sh | 2 +- templates/Commerce.Empty/.env | 2 +- templates/Commerce.Empty/Docker/create-db.sh | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/templates/Alloy.Mvc/Docker/create-db.sh b/templates/Alloy.Mvc/Docker/create-db.sh index 0f14ec7..a32a7a3 100644 --- a/templates/Alloy.Mvc/Docker/create-db.sh +++ b/templates/Alloy.Mvc/Docker/create-db.sh @@ -20,4 +20,4 @@ for i in {1..100}; do echo "Creating database. Not ready yet..." sleep 1 fi -done +done \ No newline at end of file diff --git a/templates/Cms.Empty/Docker/create-db.sh b/templates/Cms.Empty/Docker/create-db.sh index 0f14ec7..a32a7a3 100644 --- a/templates/Cms.Empty/Docker/create-db.sh +++ b/templates/Cms.Empty/Docker/create-db.sh @@ -20,4 +20,4 @@ for i in {1..100}; do echo "Creating database. Not ready yet..." sleep 1 fi -done +done \ No newline at end of file diff --git a/templates/Commerce.Empty/.env b/templates/Commerce.Empty/.env index d9e44bb..0d38a23 100644 --- a/templates/Commerce.Empty/.env +++ b/templates/Commerce.Empty/.env @@ -2,4 +2,4 @@ SA_PASSWORD=Qwerty12345! DB_NAME=Commerce.Empty.1_cms DB_NAME_COMMERCE=Commerce.Empty.1_commerce -DB_DIRECTORY=commerce-empty +DB_DIRECTORY=Commerce.Empty.1 diff --git a/templates/Commerce.Empty/Docker/create-db.sh b/templates/Commerce.Empty/Docker/create-db.sh index d95982b..221411c 100644 --- a/templates/Commerce.Empty/Docker/create-db.sh +++ b/templates/Commerce.Empty/Docker/create-db.sh @@ -32,4 +32,4 @@ for i in {1..100}; do echo "Creating databases. Not ready yet..." sleep 1 fi -done +done \ No newline at end of file From 241442b2f10baeb798646441e2332aca3d1b8e0f Mon Sep 17 00:00:00 2001 From: Johan Petersson Date: Tue, 14 Nov 2023 08:27:39 +0100 Subject: [PATCH 7/7] Skip publishing package on CI builds --- .github/workflows/ci.yml | 54 ++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b629ca6..daf167f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,31 +31,31 @@ jobs: path: artifacts/*.nupkg retention-days: 2 - publish: - name: Publish - needs: build_test_pack - runs-on: windows-latest - env: - nugetSource: https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json - DOTNET_NOLOGO: 1 - steps: - - name: Download artifacts - uses: actions/download-artifact@v2 - with: - name: packages - - name: Publish to Github Packages - run: dotnet nuget push *.nupkg --source $env:nugetSource --skip-duplicate --api-key ${{ secrets.GITHUB_TOKEN }} + # publish: + # name: Publish + # needs: build_test_pack + # runs-on: windows-latest + # env: + # nugetSource: https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json + # DOTNET_NOLOGO: 1 + # steps: + # - name: Download artifacts + # uses: actions/download-artifact@v2 + # with: + # name: packages + # - name: Publish to Github Packages + # run: dotnet nuget push *.nupkg --source $env:nugetSource --skip-duplicate --api-key ${{ secrets.GITHUB_TOKEN }} - cleanup: - name: Cleanup - needs: build_test_pack - runs-on: ubuntu-latest - steps: - - name: Cleanup old Packages - uses: actions/delete-package-versions@v3 - with: - package-name: 'EPiServer.Templates' - min-versions-to-keep: 10 - # 1-in-1-out - num-old-versions-to-delete: 1 - delete-only-pre-release-versions: "true" + # cleanup: + # name: Cleanup + # needs: build_test_pack + # runs-on: ubuntu-latest + # steps: + # - name: Cleanup old Packages + # uses: actions/delete-package-versions@v3 + # with: + # package-name: 'EPiServer.Templates' + # min-versions-to-keep: 10 + # # 1-in-1-out + # num-old-versions-to-delete: 1 + # delete-only-pre-release-versions: "true"