Add drone io and docker suppport

This commit is contained in:
Simon 2021-10-02 02:24:33 +01:00
parent a6f0f8c72a
commit 115bc6bc27
7 changed files with 121 additions and 5 deletions

48
.drone.yml Normal file
View File

@ -0,0 +1,48 @@
kind: pipeline
type: docker
name: deploy
steps:
# GO api
- name: build_api
image: golang
environment:
- GIN_MODE=release
commands:
- cd Api
- go build
# Platformio esp firmware
# - name: build_esp
# C# frontend
# upload docker
- name: upload_frontend
when:
branch:
- master
settings:
dockerfile: ManagementPage/ManagementPage/Dockerfile
repo: "registry.jacknet.io/51m0n/environment-api"
username: simon
password:
from_secret: docker_password
registry: registry.jacknet.io
auto_tag: true
# upload docker
- name: upload_api
depends_on:
- build_api
image: plugins/docker
when:
branch:
- master
settings:
context: Api
dockerfile: Api/Dockerfile
repo: "registry.jacknet.io/51m0n/environment-api"
username: simon
password:
from_secret: docker_password
registry: registry.jacknet.io
auto_tag: true
# upload firmware blob
# - name: upload_esp

9
Api/Dockerfile Normal file
View File

@ -0,0 +1,9 @@
FROM ubuntu
EXPOSE 8080
ENV GIN_MODE=release
COPY EnvironmentManagerAPI /EnvironmentManagerAPI
ENTRYPOINT ["./EnvironmentManagerAPI"]

View File

@ -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

View File

@ -0,0 +1,22 @@
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["ManagementPage/ManagementPage.csproj", "ManagementPage/"]
RUN dotnet restore "ManagementPage/ManagementPage.csproj"
COPY . .
WORKDIR "/src/ManagementPage"
RUN dotnet build "ManagementPage.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "ManagementPage.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "ManagementPage.dll"]

View File

@ -4,10 +4,13 @@
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>a667e9e0-64d9-4a5e-a721-f9c32f29af02</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="5.0.10" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.14.0" />
<PackageReference Include="MongoDB.Bson" Version="2.13.1" />
<PackageReference Include="MongoDB.Driver" Version="2.13.1" />
</ItemGroup>

View File

@ -5,5 +5,7 @@
<Controller_SelectedScaffolderCategoryPath>root/Common/MVC/Controller</Controller_SelectedScaffolderCategoryPath>
<RazorPage_SelectedScaffolderID>RazorPageScaffolder</RazorPage_SelectedScaffolderID>
<RazorPage_SelectedScaffolderCategoryPath>root/Common/RazorPage</RazorPage_SelectedScaffolderCategoryPath>
<NameOfLastUsedPublishProfile>P:\EnvironmentManagement\ManagementPage\ManagementPage\Properties\PublishProfiles\registry.jacknet.io.pubxml</NameOfLastUsedPublishProfile>
<ActiveDebugProfile>Docker</ActiveDebugProfile>
</PropertyGroup>
</Project>

View File

@ -1,4 +1,4 @@
{
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
@ -10,12 +10,12 @@
"profiles": {
"ManagementPage": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://environment.51m0n.com;http://+:80",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"applicationUrl": "https://environment.51m0n.com;http://+:80",
"dotnetRunMessages": true
},
"IIS Express": {
"commandName": "IISExpress",
@ -23,6 +23,13 @@
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Docker": {
"commandName": "Docker",
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
"publishAllPorts": true,
"useSSL": true
}
}
}
}