From 4125545257a8207c5805aaab4c155073b7f0b5a4 Mon Sep 17 00:00:00 2001 From: Karolis2011 Date: Wed, 19 Jun 2019 00:01:58 +0300 Subject: [PATCH 1/3] Docker file --- .dockerignore | 20 +++++++++++++++++++ EventBot/Dockerfile | 18 +++++++++++++++++ EventBot/EventBot.csproj | 6 ++---- .../FolderProfile-linux-arm.pubxml | 16 +++++++++++++++ EventBot/Properties/launchSettings.json | 4 ++++ 5 files changed, 60 insertions(+), 4 deletions(-) create mode 100644 .dockerignore create mode 100644 EventBot/Dockerfile create mode 100644 EventBot/Properties/PublishProfiles/FolderProfile-linux-arm.pubxml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..2d15e48 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,20 @@ +**/.dockerignore +**/.env +**/.git +**/.gitignore +**/.vs +**/.vscode +**/*.*proj.user +**/azds.yaml +**/charts +**/bin +**/obj +**/Dockerfile +**/Dockerfile.develop +**/docker-compose.yml +**/docker-compose.*.yml +**/*.dbmdl +**/*.jfm +**/secrets.dev.yaml +**/values.dev.yaml +**/.toolstarget \ No newline at end of file diff --git a/EventBot/Dockerfile b/EventBot/Dockerfile new file mode 100644 index 0000000..d67b7e4 --- /dev/null +++ b/EventBot/Dockerfile @@ -0,0 +1,18 @@ +FROM mcr.microsoft.com/dotnet/core/runtime:2.2-stretch-slim AS base +WORKDIR /app + +FROM mcr.microsoft.com/dotnet/core/sdk:2.2-stretch AS build +WORKDIR /src +COPY ["EventBot/EventBot.csproj", "EventBot/"] +RUN dotnet restore "EventBot/EventBot.csproj" +COPY . . +WORKDIR "/src/EventBot" +RUN dotnet build "EventBot.csproj" -c Release -o /app + +FROM build AS publish +RUN dotnet publish "EventBot.csproj" -c Release -o /app + +FROM base AS final +WORKDIR /app +COPY --from=publish /app . +ENTRYPOINT ["dotnet", "EventBot.dll"] \ No newline at end of file diff --git a/EventBot/EventBot.csproj b/EventBot/EventBot.csproj index 25ce4df..67da6ae 100644 --- a/EventBot/EventBot.csproj +++ b/EventBot/EventBot.csproj @@ -3,12 +3,9 @@ Exe netcoreapp2.2 + Linux - - - - @@ -20,6 +17,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/EventBot/Properties/PublishProfiles/FolderProfile-linux-arm.pubxml b/EventBot/Properties/PublishProfiles/FolderProfile-linux-arm.pubxml new file mode 100644 index 0000000..3fc0995 --- /dev/null +++ b/EventBot/Properties/PublishProfiles/FolderProfile-linux-arm.pubxml @@ -0,0 +1,16 @@ + + + + + FileSystem + Release + Any CPU + netcoreapp2.2 + bin\Release\netcoreapp2.2\publish\linux-arm + linux-arm + true + <_IsPortable>false + + \ No newline at end of file diff --git a/EventBot/Properties/launchSettings.json b/EventBot/Properties/launchSettings.json index 9c63605..3dacec8 100644 --- a/EventBot/Properties/launchSettings.json +++ b/EventBot/Properties/launchSettings.json @@ -3,8 +3,12 @@ "EventBot": { "commandName": "Project", "environmentVariables": { + "dbconnection": "Server=localhost;Database=eventbot;User=root;Password=tux;", "token": "" } + }, + "Docker": { + "commandName": "Docker" } } } \ No newline at end of file From a67f6f166666c0004ad6eb11efedf6a329bcb4f1 Mon Sep 17 00:00:00 2001 From: Karolis2011 Date: Wed, 19 Jun 2019 00:17:44 +0300 Subject: [PATCH 2/3] Addes travis and README --- .travis.yml | 9 +++++++++ README | 6 ------ README.md | 13 +++++++++++++ 3 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 .travis.yml delete mode 100644 README create mode 100644 README.md diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..ce1b85a --- /dev/null +++ b/.travis.yml @@ -0,0 +1,9 @@ +language: csharp +mono: none +dotnet: 2.2.0 + +install: +- dotnet restore + +script: + - dotnet build \ No newline at end of file diff --git a/README b/README deleted file mode 100644 index 7e6de9b..0000000 --- a/README +++ /dev/null @@ -1,6 +0,0 @@ - -`set dbconnection="Server=localhost;Database=eventbot;User=root;Password=password;"` - - -`Add-Migration InitialDatabase -Context MySqlDatabaseService -OutputDir Migrations\MySql` -`Add-Migration InitialDatabase -Context SqliteDatabaseService -OutputDir Migrations\Sqlite` \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..2cda7e6 --- /dev/null +++ b/README.md @@ -0,0 +1,13 @@ +# EventBot + +## Environment variables +### `token` variable +This is variable for discord bot's token obtained from discord developer panel. +### `dbconnection` variable +This is environment variable for Mysql / MariaDb database connection. Example connection string: + +```Server=localhost,123;Database=eventbot;User=root;Password=password;``` + + +`Add-Migration InitialDatabase -Context MySqlDatabaseService -OutputDir Migrations\MySql` +`Add-Migration InitialDatabase -Context SqliteDatabaseService -OutputDir Migrations\Sqlite` \ No newline at end of file From 9c7d370b5b05465dbaa3a72094b1691aaae4a12c Mon Sep 17 00:00:00 2001 From: Karolis2011 Date: Wed, 19 Jun 2019 00:23:15 +0300 Subject: [PATCH 3/3] Travis you can do it. --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ce1b85a..21cbd3b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,7 @@ language: csharp mono: none -dotnet: 2.2.0 +dist: xenial +dotnet: 2.2 install: - dotnet restore