Add Dockerfile and documentation.

This commit is contained in:
Kevin Matsubara 2026-03-15 13:48:38 +01:00
parent ef6adf0823
commit 7c0270e70d
3 changed files with 33 additions and 0 deletions

3
.gitignore vendored
View File

@ -1,3 +1,6 @@
# Ignore the tar file.
MusicAPI.tar
# Build results
bin/
obj/

4
Dockerfile Normal file
View File

@ -0,0 +1,4 @@
FROM mcr.microsoft.com/dotnet/aspnet:8.0
WORKDIR /app
COPY publish/ .
ENTRYPOINT ["dotnet", "MyApi.dll"]

View File

@ -9,3 +9,29 @@ run project locally:
* `dotnet run`
## Deployment
Publish project:
* `dotnet publish -c Release -o publish`
Build the container:
* `docker build -t music_api:latest .`
Export image to a file:
* `docker save music_api:latest -o MusicAPI.tar`
* Transer the file to USB, then run commands on the server.
Load devices:
* `lsblk`
Usually it is `sdb1`, mount it to a created mount point.
* `sudo mount /dev/sdb1 /mnt/usb`
* `cp /mnt/usb/MusicAPI.tar ~/`
* `sudo umount /mnt/usb`
Load image on server:
* `docker load -i MusicAPI.tar`
Run container on server:
* `docker run -d -p 8080:80 --name MusicAPI music_api:latest`