This repository contains C# web API code that provides one endpoint at the addresses (http://localhost:5000/weatherforecast, https://localhost:5001/weatherforecast).
The README.md file contains commands that will allow you to:
- create an image of your API
- add the image to the docker hub platform
- download the image to the Raspberry Pi
- run the container with your web API on the Raspberry Pi
docker build -t dockertest_api .
docker build -t dockertest_api --platform linux/arm64/v8 .
docker build --no-cache -t dockertest_api --platform=linux/arm/v7 .
docker build --no-cache -t dockertest_api --platform=linux/arm64/v8 .
docker build --no-cache -t dockertest_api --platform=linux/arm64 .
-t - name and tag of the image
docker build --no-cache -t dockertest_api .
docker run -d -p 5000:5000 -e ASPNETCORE_HTTP_PORTS=5000 -e ASPNETCORE_ENVIRONMENT=Development dockertest_api
dotnet dev-certs https --clean
dotnet dev-certs https -ep $HOME\.aspnet\https\aspnetapp.pfx -p password
dotnet dev-certs https --trust
-ep - path to existing certificate file (.pfx) that you want to use for HTTPS development (existing PFX file)
IMPORTANT - COPY CERTIFICATE TO RASPBERRY PI!!! (use scp) -> to: $HOME/.aspnet/https (change <raspberrypi_ip> to correct Raspberry Pi ip)
scp C:\Users\bartl\.aspnet\https\aspnetapp.pfx malinka@<raspberrypi_ip>:/home/malinka/https/
docker run -d -p 5000:5000 -p 5001:5001 -e ASPNETCORE_URLS="https://+:5001;http://+:5000" -e ASPNETCORE_HTTP_PORTS=5000 -e ASPNETCORE_HTTPS_PORT=5001 -e ASPNETCORE_ENVIRONMENT=Development -e ASPNETCORE_Kestrel__Certificates__Default__Password=password -e ASPNETCORE_Kestrel__Certificates__Default__Path=/https/aspnetapp.pfx -v "$HOME/.aspnet/https:/https/" dockertest_api
dotnet dev-certs https -ep %USERPROFILE%\.aspnet\https\aspnetapp.pfx -p password
docker run -d -p 5000:5000 -p 5001:5001 -e ASPNETCORE_URLS="https://+;http://+" -e ASPNETCORE_HTTP_PORTS=5000 -e ASPNETCORE_HTTPS_PORT=5001 -e ASPNETCORE_Kestrel__Certificates__Default__Password=password -e ASPNETCORE_Kestrel__Certificates__Default__Path=/https/aspnetapp.pfx -v %USERPROFILE%\.aspnet\https:/https/ dockertest_api
docker run -d -p 5000:5000 -p 5001:5001 -e ASPNETCORE_URLS="https://+;http://+" -e ASPNETCORE_HTTP_PORTS=5000 -e ASPNETCORE_HTTPS_PORT=5001 -e ASPNETCORE_Kestrel__Certificates__Default__Password=password -e ASPNETCORE_Kestrel__Certificates__Default__Path=/https/aspnetapp.pfx -v "$HOME/.aspnet/https:/https/" dockertest_api
docker tag dockertest_api fritzthecat9/dockertest_api:1.0
docker tag dockertest_api fritzthecat9/dockertest_api:latest
docker login
docker push fritzthecat9/dockertest_api:latest
docker pull fritzthecat9/dockertest_api:latest
docker images
docker pull fritzthecat9/dockertest_api:latest
docker run -d -p 5000:5000 -p 5001:5001 -e ASPNETCORE_URLS="https://+:5001;http://+:5000" -e ASPNETCORE_HTTP_PORTS=5000 -e ASPNETCORE_HTTPS_PORT=5001 -e ASPNETCORE_ENVIRONMENT=Development -e ASPNETCORE_Kestrel__Certificates__Default__Password=password -e ASPNETCORE_Kestrel__Certificates__Default__Path=/https/aspnetapp.pfx -v "$HOME/.aspnet/https:/https/" fritzthecat9/dockertest_api:latest
docker rm container_name_or_id
docker rmi image_name_or_id
docker logs container_name_or_id
-f - continuously follow or stream the logs generated by a Docker container
docker logs -f container_name_or_id
curl http://localhost:5000/weatherforecast
curl https://localhost:5001/weatherforecast
-k - ignore certificate check
curl -k https://localhost:5001/weatherforecast
docker stop container_id
docker start container_id