AddEnvironmentVariables fix + build and release scripts

master
Tudor Stanciu 2021-11-14 13:12:41 +02:00
parent 8d02114553
commit b9ef2f94bb
5 changed files with 55 additions and 0 deletions

View File

@ -27,6 +27,8 @@ COPY --from=publish /app/publish .
ENV urls="http://*:80"
ENV ConnectionStrings__DatabaseConnection="***REMOVED***"
ENV TZ=Europe/Bucharest
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
#Workaround to lower the TLS level in container for old sql server version
RUN sed -i 's/TLSv1.2/TLSv1.0/g' /etc/ssl/openssl.cnf

View File

@ -26,6 +26,7 @@ namespace Chatbot.Api
var configuration = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddEnvironmentVariables()
.Build();
var connectionString = configuration.GetConnectionString("DatabaseConnection");

View File

@ -23,6 +23,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Chatbot.Api.Domain.Data", "
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Api", "Api", "{3AC727D4-4E65-4D98-A532-04C489540A74}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{341EE785-7F03-457F-9188-0ADB1A2B9DBD}"
ProjectSection(SolutionItems) = preProject
build-amd64.sh = build-amd64.sh
release.sh = release.sh
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -54,6 +60,7 @@ Global
{3759725E-8E75-44F4-86A3-34CC1EAC1D6C} = {3AC727D4-4E65-4D98-A532-04C489540A74}
{1FDA8402-A777-48AF-91A3-34B7D033A8A5} = {3AC727D4-4E65-4D98-A532-04C489540A74}
{999F5359-3CD8-4A0C-86B8-E3DC5421AA0C} = {3AC727D4-4E65-4D98-A532-04C489540A74}
{341EE785-7F03-457F-9188-0ADB1A2B9DBD} = {C42EC299-F3D5-4326-A756-80F9FEF233D9}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B43E78A6-ACCC-4A5C-84E2-0B6237C79896}

23
build-amd64.sh Normal file
View File

@ -0,0 +1,23 @@
#!/bin/bash
echo "Welcome!"
version="1.0.0"
localRegistryPass="***REMOVED***"
echo "Create docker image with version $version."
docker image build -t "chatbot-api:$version" -f "Chatbot.Api/Dockerfile" .
echo "Tag docker image with registry prefix."
docker tag chatbot-api:$version alpine-nexus:8500/chatbot/chatbot-api:$version
echo "Login to alpine-nexus registry."
docker login --username=admin --password=$localRegistryPass alpine-nexus:8500
echo "Push image alpine-nexus:8500/chatbot/chatbot-api:$version to registry."
docker push alpine-nexus:8500/chatbot/chatbot-api:$version
echo "Remove image alpine-nexus:8500/chatbot/chatbot-api:$version from local machine."
docker rmi alpine-nexus:8500/chatbot/chatbot-api:$version
echo "DONE!"

22
release.sh Normal file
View File

@ -0,0 +1,22 @@
#!/bin/sh
echo "Welcome!"
version="1.0.1"
oldver="1.0.0"
echo "Pull docker image chatbot-api:$version from registry."
docker pull alpine-nexus:8500/chatbot/chatbot-api:$version
echo "Stop old container."
docker stop chatbot-api && docker rm chatbot-api
echo "Run new container."
docker run -d --name chatbot-api --restart=always -p 5006:80 alpine-nexus:8500/chatbot/chatbot-api:$version
echo "Remove old image chatbot-api:$oldver."
docker rmi alpine-nexus:8500/chatbot/chatbot-api:$oldver
echo "Get container logs:"
docker logs chatbot-api
echo "DONE!"