Move to docker image

This commit is contained in:
Robert Marshall 2023-02-16 18:42:13 +00:00
parent 832b4fb36a
commit bb93afd555
5 changed files with 47 additions and 83 deletions

29
.drone.yml Normal file
View file

@ -0,0 +1,29 @@
kind: pipeline
name: default
clone:
skip_verify: true
volumes:
- name: output
host:
path: /var/www/Website
steps:
- name: docker
image: plugins/docker
settings:
repo: docker.robware.uk/website
registry: docker.robware.uk
tags: latest
- name: notify
image: drillster/drone-email
settings:
host: 192.168.1.3
skip_verify: true
from: build@robware.uk
when:
status:
- changed
- failure

17
Dockerfile Normal file
View file

@ -0,0 +1,17 @@
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build-env
WORKDIR /app
COPY . ./
RUN curl -sL https://deb.nodesource.com/setup_18.x | bash -
RUN apt-get install -y nodejs
RUN chmod +x ./build.sh
RUN ./build.sh
RUN sed -i "s/<AuthEndpoint>/${AuthEndpoint}/g" output/appsettings.json
RUN sed -i "s/<AuthApiKey>/${AuthApiKey}/g" output/appsettings.json
RUN sed -i "s/<BlogEndpoint>/${BlogEndpoint}/g" output/appsettings.json
RUN sed -i "s/<GitEndpoint>/${GitEndpoint}/g" output/appsettings.json
RUN sed -i "s/<MailboxEndpoint>/${MailboxEndpoint}/g" output/appsettings.json
FROM mcr.microsoft.com/dotnet/aspnet:7.0
WORKDIR /app
COPY --from=build-env /app/output .
ENTRYPOINT ["dotnet", "Website.dll"]

View file

@ -1,66 +0,0 @@
kind: pipeline
name: default
clone:
skip_verify: true
volumes:
- name: output
host:
path: /var/www/Website
steps:
- name: build and publish
image: mcr.microsoft.com/dotnet/core/sdk:3.1
volumes:
- name: output
path: /output
environment:
ConnectionString:
from_secret: ConnectionString
BlogEndpoint:
from_secret: BlogEndpoint
GitEndpoint:
from_secret: GitEndpoint
AuthEndpoint:
from_secret: AuthEndpoint
AuthApiKey:
from_secret: AuthApiKey
MailboxEndpoint:
from_secret: MailboxEndpoint
commands:
- curl -sL https://deb.nodesource.com/setup_18.x | bash -
- apt-get install -y nodejs
- chmod +x ./build.sh
- ./build.sh
- sed -i "s/<DatabaseConnectionString>/$ConnectionString/g" output/appsettings.json
- sed -i "s/<BlogEndpoint>/$BlogEndpoint/g" output/appsettings.json
- sed -i "s/<GitEndpoint>/$GitEndpoint/g" output/appsettings.json
- sed -i "s/<AuthEndpoint>/$AuthEndpoint/g" output/appsettings.json
- sed -i "s/<AuthApiKey>/$AuthApiKey/g" output/appsettings.json
- sed -i "s/<MailboxEndpoint>/$MailboxEndpoint/g" output/appsettings.json
- cp Infrastructure/website.service output/
- cp -r ./output/* /output
- name: restart service
privileged: true
image: appleboy/drone-ssh
settings:
host: 192.168.1.3
username:
from_secret: ssh_user
password:
from_secret: ssh_password
script:
- systemctl daemon-reload
- service website restart
- name: notify
image: drillster/drone-email
settings:
host: 192.168.1.3
skip_verify: true
from: build@robware.uk
when:
status:
- changed
- failure

View file

@ -1,16 +0,0 @@
[Unit]
Description=Robware
[Service]
WorkingDirectory=/var/www/Website
ExecStart=/usr/bin/dotnet /var/www/Website/Website.dll
Restart=always
# Restart service after 10 seconds if the dotnet service crashes:
RestartSec=10
KillSignal=SIGINT
SyslogIdentifier=Website
User=www-data
Environment=ASPNETCORE_ENVIRONMENT=Production
[Install]
WantedBy=multi-user.target

View file

@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<RootNamespace></RootNamespace>
<IsPackable>False</IsPackable>