From 46ecfda1345a8965c24cd17e1ec34cbf63b744a6 Mon Sep 17 00:00:00 2001 From: exsersewo Date: Sat, 30 Jan 2021 01:17:37 +0000 Subject: [PATCH] Add Docker --- .dockerignore | 4 ++++ .env.default | 8 ++++++++ NuGet.config | 10 ++++++++++ docker-compose.yml | 12 ++++++++++++ src/.dockerignore | 25 +++++++++++++++++++++++++ src/RestAPI/Dockerfile | 16 ++++++++++++++++ 6 files changed, 75 insertions(+) create mode 100644 .dockerignore create mode 100644 .env.default create mode 100644 NuGet.config create mode 100644 docker-compose.yml create mode 100644 src/.dockerignore create mode 100644 src/RestAPI/Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..95936d9 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +.git +.github +**/.idea +**/.vs diff --git a/.env.default b/.env.default new file mode 100644 index 0000000..fe688ca --- /dev/null +++ b/.env.default @@ -0,0 +1,8 @@ +DATASOURCE= +HOST= +HOSTPORT= +USERNAME= +PASSWORD= +DATABASE= +BLACKLISTEDFIELDS= +HTTPSPORT= \ No newline at end of file diff --git a/NuGet.config b/NuGet.config new file mode 100644 index 0000000..b38c37f --- /dev/null +++ b/NuGet.config @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..5ad8b34 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,12 @@ +version: '3' +services: + api: + build: + context: . + dockerfile: src/RestAPI/Dockerfile + ports: + - "80:80" + container_name: "restapi" + env_file: + - .env + network_mode: host \ No newline at end of file diff --git a/src/.dockerignore b/src/.dockerignore new file mode 100644 index 0000000..3729ff0 --- /dev/null +++ b/src/.dockerignore @@ -0,0 +1,25 @@ +**/.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 +LICENSE +README.md \ No newline at end of file diff --git a/src/RestAPI/Dockerfile b/src/RestAPI/Dockerfile new file mode 100644 index 0000000..9aa9585 --- /dev/null +++ b/src/RestAPI/Dockerfile @@ -0,0 +1,16 @@ +FROM mcr.microsoft.com/dotnet/sdk:5.0.102-ca-patch-buster-slim AS build +WORKDIR /app + +COPY ["src/RestAPI/RestAPI.csproj", "src/RestAPI/"] +RUN dotnet restore "src/RestAPI/RestAPI.csproj" +COPY . . + +WORKDIR ./src/RestAPI + +RUN dotnet build "RestAPI.csproj" -c Release -o /app/build +RUN dotnet publish "RestAPI.csproj" -c Release -o /app/publish + +FROM mcr.microsoft.com/dotnet/aspnet:5.0 +WORKDIR /app +COPY --from=build /app/publish . +ENTRYPOINT ["dotnet", "RestAPI.dll"] \ No newline at end of file