aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-05-31 15:35:25 +0800
committercrupest <crupest@outlook.com>2020-05-31 15:35:25 +0800
commit635b5ea646ec55c7ae212f79031b69c00ad79763 (patch)
tree6697477582d8d710c3961daad0b22a533edddfb2
parent590522661ba90ac388029c83d248e8277d2325f7 (diff)
downloadtimeline-635b5ea646ec55c7ae212f79031b69c00ad79763.tar.gz
timeline-635b5ea646ec55c7ae212f79031b69c00ad79763.tar.bz2
timeline-635b5ea646ec55c7ae212f79031b69c00ad79763.zip
Migrate to docker.
-rw-r--r--Timeline/Dockerfile4
-rw-r--r--Timeline/Services/PathProvider.cs2
-rw-r--r--Timeline/Startup.cs6
-rw-r--r--Timeline/appsettings.json5
-rw-r--r--azure-pipelines.yml27
5 files changed, 15 insertions, 29 deletions
diff --git a/Timeline/Dockerfile b/Timeline/Dockerfile
new file mode 100644
index 00000000..68685a55
--- /dev/null
+++ b/Timeline/Dockerfile
@@ -0,0 +1,4 @@
+FROM mcr.microsoft.com/dotnet/core/aspnet:3.1
+WORKDIR /app
+COPY ./publish .
+ENTRYPOINT ["dotnet", "Timeline.dll"]
diff --git a/Timeline/Services/PathProvider.cs b/Timeline/Services/PathProvider.cs
index 1f6b629a..eefbf41a 100644
--- a/Timeline/Services/PathProvider.cs
+++ b/Timeline/Services/PathProvider.cs
@@ -21,7 +21,7 @@ namespace Timeline.Services
public PathProvider(IConfiguration configuration)
{
_configuration = configuration;
- _workingDirectory = configuration.GetValue<string>("WorkDir");
+ _workingDirectory = configuration.GetValue<string?>("WorkDir") ?? "/timeline";
}
public string GetWorkingDirectory()
diff --git a/Timeline/Startup.cs b/Timeline/Startup.cs
index b6c3ff7f..09281551 100644
--- a/Timeline/Startup.cs
+++ b/Timeline/Startup.cs
@@ -36,12 +36,6 @@ namespace Timeline
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
- var workDir = Configuration.GetValue<string?>("WorkDir");
- if (workDir == null)
- {
- throw new InvalidOperationException("Please set a work directory first.");
- }
-
services.AddControllers(setup =>
{
setup.InputFormatters.Add(new StringInputFormatter());
diff --git a/Timeline/appsettings.json b/Timeline/appsettings.json
index 09840cd6..804ca43a 100644
--- a/Timeline/appsettings.json
+++ b/Timeline/appsettings.json
@@ -6,7 +6,6 @@
},
"Jwt": {
"Issuer": "api.crupest.xyz",
- "Audience": "api.crupest.xyz",
- },
- "Cors": [ "https://www.crupest.xyz", "https://crupest.xyz" ]
+ "Audience": "api.crupest.xyz"
+ }
}
diff --git a/azure-pipelines.yml b/azure-pipelines.yml
index 2231f532..22ceaf8a 100644
--- a/azure-pipelines.yml
+++ b/azure-pipelines.yml
@@ -80,22 +80,11 @@ stages:
- publish: Timeline/publish
artifact: timeline
- - deployment: deploy
- displayName: Deploy to Server
- environment:
- name: timeline-server
- resourceType: VirtualMachine
- tags: linux
- dependsOn: build
- strategy:
- runOnce:
- deploy:
- steps:
- - download: current
- artifact: timeline
-
- - script: |
- rm -rf /var/timeline/*
- cp -r $PIPELINE_WORKSPACE/timeline/. /var/timeline/
- sudo systemctl restart timeline.service
- displayName: 'Copy Files and Restart Service'
+ - task: Docker@2
+ displayName: Build And Push Docker Image
+ inputs:
+ command: buildAndPush
+ repository: timeline
+ tags: latest
+ buildContext: Timeline
+ containerRegistry: crupest-docker-hub