1.[.drone.yml]
kind: pipeline
type: docker
name: deployment
platform:
os: linux
arch: amd64
steps:
- name: build
image: mcr.microsoft.com/dotnet/sdk:6.0
volumes:
- name: dotnet-build
path: /mnt/dotnet/app
commands:
- cd ./Coreqi_Api
- dotnet restore
- dotnet build -c Release -o /mnt/dotnet/app/build
- dotnet publish -c Release -o /mnt/dotnet/app/publish /p:UseAppHost=false
- cp ./Dockerfile /mnt/dotnet/app
- echo project build success
- name: build-docker
image: plugins/docker
privileged: true
settings:
context: /mnt/dotnet/app
dockerfile: /mnt/dotnet/app/Dockerfile
commands:
- cd /mnt/dotnet/app
- docker build -t fanqi/coreqi:latest .
- docker stop coreqi && docker rm coreqi
- docker run -d -p 10018:80 --name coreqi fanqi/coreqi:latest
volumes:
- name: dotnet-build
path: /mnt/dotnet/app
- name: dockersock
path: /var/run/docker.sock
volumes:
- name: dotnet-build
host:
path: /mnt/dotnet/app
- name: dockersock
host:
path: /var/run/docker.sock
2.dockerfile
FROM mcr.microsoft.com/dotnet/aspnet:6.0
WORKDIR /app
EXPOSE 80
EXPOSE 443
COPY /publish .
ENTRYPOINT ["dotnet", "Coreqi_Api.dll"]