diff --git a/.build/deploy.sh b/.build/deploy.sh
index c154f66..fdd9a59 100755
--- a/.build/deploy.sh
+++ b/.build/deploy.sh
@@ -1,5 +1,9 @@
BUILD_PATH=$1
+cd $BUILD_PATH/src || exit 1
+
+docker-build -f ./InternshipSystem.Api/Dockerfile -t internship.api .
+
cd $BUILD_PATH/.docker || exit 1
-docker-compose up -d --build --force-recreate
\ No newline at end of file
+docker-compose up -d --force-recreate
\ No newline at end of file
diff --git a/.docker/docker-compose.yaml b/.docker/docker-compose.yaml
index 6d84647..463fd71 100644
--- a/.docker/docker-compose.yaml
+++ b/.docker/docker-compose.yaml
@@ -3,7 +3,6 @@ services:
internship.api:
image: internship.api:latest
- build: ../src/Internship.Api
ports:
- 8080:80
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
index 92fcc64..12ed2af 100644
--- a/.vscode/tasks.json
+++ b/.vscode/tasks.json
@@ -2,56 +2,48 @@
"version": "2.0.0",
"tasks": [
{
- "label": "build",
- "command": "dotnet",
- "type": "process",
- "args": [
- "build",
- "${workspaceFolder}/src/Internship.Api/Internship.Api.csproj",
- "/property:GenerateFullPaths=true",
- "/consoleloggerparameters:NoSummary"
- ],
- "problemMatcher": "$msCompile"
+ "label": "build: api",
+ "type": "docker-build",
+ "dockerBuild": {
+ "dockerfile": "src/InternshipSystem.Api/Dockerfile",
+ "tag": "internship.api",
+ "context": "src"
+ },
+ "problemMatcher": [],
+ "group": {
+ "kind": "build",
+ "isDefault": true
+ }
},
{
- "label": "publish",
- "command": "dotnet",
- "type": "process",
+ "label": "down: api",
+ "type": "shell",
+ "command": "docker-compose",
"args": [
- "publish",
- "${workspaceFolder}/src/Internship.Api/Internship.Api.csproj",
- "/property:GenerateFullPaths=true",
- "/consoleloggerparameters:NoSummary"
- ],
- "problemMatcher": "$msCompile"
+ "-f",
+ ".docker/docker-compose.yaml",
+ "down",
+ "--volumes"
+ ]
},
{
- "label": "watch",
- "command": "dotnet",
- "type": "process",
- "args": [
- "watch",
- "run",
- "${workspaceFolder}/src/Internship.Api/Internship.Api.csproj",
- "/property:GenerateFullPaths=true",
- "/consoleloggerparameters:NoSummary"
- ],
- "problemMatcher": "$msCompile"
- },
- {
- "label": "up",
+ "label": "up: api",
"type": "shell",
"command": "docker-compose",
"args": [
"-f",
".docker/docker-compose.yaml",
"up",
- "--build"
+ "--remove-orphans"
+ ],
+ "dependsOn": [
+ "down: api",
+ "build: api"
],
"problemMatcher": []
},
{
- "label": "dotnet restore",
+ "label": "restore",
"type": "shell",
"command": "dotnet",
"args": [
@@ -59,5 +51,16 @@
],
"problemMatcher": []
},
+ {
+ "label": "publish",
+ "command": "dotnet",
+ "args": [
+ "publish",
+ "--output",
+ "./obj/docker/publish",
+ "--runtime",
+ "linux-x64"
+ ]
+ }
]
}
\ No newline at end of file
diff --git a/src/InternshipSystem.Api/.dockerignore b/src/InternshipSystem.Api/.dockerignore
deleted file mode 100644
index 257cb48..0000000
--- a/src/InternshipSystem.Api/.dockerignore
+++ /dev/null
@@ -1,24 +0,0 @@
-**/.classpath
-**/.dockerignore
-**/.env
-**/.git
-**/.gitignore
-**/.project
-**/.settings
-**/.toolstarget
-**/.vs
-**/.vscode
-**/*.*proj.user
-**/*.dbmdl
-**/*.jfm
-**/azds.yaml
-**/bin
-**/charts
-**/docker-compose*
-**/Dockerfile*
-**/node_modules
-**/npm-debug.log
-**/obj
-**/secrets.dev.yaml
-**/values.dev.yaml
-README.md
\ No newline at end of file
diff --git a/src/InternshipSystem.Api/Controllers/InternshipController.cs b/src/InternshipSystem.Api/Controllers/InternshipController.cs
deleted file mode 100644
index 78bf017..0000000
--- a/src/InternshipSystem.Api/Controllers/InternshipController.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-using System;
-using Microsoft.AspNetCore.Mvc;
-using InternshipSystem.Core;
-
-namespace InternshipSystem.Api.Controllers {
-
- [ApiController]
- //[Route("[internship]")]
- public class InternshipController : ControllerBase {
-
- [HttpGet]
- public IActionResult GetInternships() {
- //TODO: parse params
- //return JsonResult("");
- return Ok();
- }
-
- [HttpPost]
- public IActionResult CreateInternship(Internship internship) {
- //TODO: add internship
- return Ok();
- }
-
-
- }
-}
\ No newline at end of file
diff --git a/src/InternshipSystem.Api/Dockerfile b/src/InternshipSystem.Api/Dockerfile
index 3361645..f76cce3 100644
--- a/src/InternshipSystem.Api/Dockerfile
+++ b/src/InternshipSystem.Api/Dockerfile
@@ -1,16 +1,19 @@
+FROM mcr.microsoft.com/dotnet/core/sdk:3.1-alpine AS prep-env
+COPY . ./
+RUN mkdir /proj && cp --parents */*.csproj /proj
+
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-alpine AS build-env
WORKDIR /app
-
# Copy csproj and restore as distinct layers
-COPY *.csproj ./
-RUN dotnet restore
+COPY --from=prep-env ./proj .
+RUN dotnet restore ./InternshipSystem.Api
# Copy everything else and build
COPY . ./
-RUN dotnet publish -c Release -o out
+RUN dotnet publish ./InternshipSystem.Api -c Release -o out
# Build runtime image
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-alpine
WORKDIR /app
COPY --from=build-env /app/out .
-ENTRYPOINT ["dotnet", "./Internship.Api.dll"]
+ENTRYPOINT ["dotnet", "./InternshipSystem.Api.dll"]
diff --git a/src/InternshipSystem.Api/InternshipSystem.Api.csproj b/src/InternshipSystem.Api/InternshipSystem.Api.csproj
index f309fb8..5ccb212 100644
--- a/src/InternshipSystem.Api/InternshipSystem.Api.csproj
+++ b/src/InternshipSystem.Api/InternshipSystem.Api.csproj
@@ -18,7 +18,8 @@
-
+
+
diff --git a/src/InternshipSystem.Api/Startup.cs b/src/InternshipSystem.Api/Startup.cs
index 59c50c1..5186330 100644
--- a/src/InternshipSystem.Api/Startup.cs
+++ b/src/InternshipSystem.Api/Startup.cs
@@ -34,6 +34,7 @@ namespace InternshipSystem.Api
.UseHttpsRedirection()
.UseRouting()
.UseAuthorization()
+ .UseCors()
.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
diff --git a/src/InternshipSystem.Repository/InternshipSystem.Repository.csproj b/src/InternshipSystem.Repository/InternshipSystem.Repository.csproj
index 4b21438..7be0990 100644
--- a/src/InternshipSystem.Repository/InternshipSystem.Repository.csproj
+++ b/src/InternshipSystem.Repository/InternshipSystem.Repository.csproj
@@ -6,7 +6,7 @@
-
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all