瀏覽代碼

Move to docker image

Robert Marshall 2 年之前
父節點
當前提交
bb93afd555
共有 5 個文件被更改,包括 47 次插入83 次删除
  1. 29 0
      .drone.yml
  2. 17 0
      Dockerfile
  3. 0 66
      Infrastructure/.drone.yml
  4. 0 16
      Infrastructure/website.service
  5. 1 1
      build/_build.csproj

+ 29 - 0
.drone.yml

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

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

+ 0 - 66
Infrastructure/.drone.yml

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

+ 0 - 16
Infrastructure/website.service

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

+ 1 - 1
build/_build.csproj

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