Add Digital Ocean and Docker Use Case
See original GitHub issueIs your feature request related to a problem? Please describe. Add Docker and Digital Ocean Use Case
Describe the solution you’d like Add Docker and Digital Ocean Use Case
Describe alternatives you’ve considered None
Additional context Issue #14 was helpful, but I think you will increase the use case if you add something obvious to the README.md for Docker.
Basic Steps for Docker in Digital Ocean droplet (.NET CORE)
- Configure your web application per the instructions of this repo.
- Create Digital Ocean droplet. Under marketplace, there is a Docker image option that has Docker preinstalled.
- Point your DNS A record at the Digital Ocean Droplet IP.
- Build container and publish container to Docker Hub.
Sample Dockerfile
FROM mcr.microsoft.com/dotnet/core/aspnet:2.1-stretch-slim AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/core/sdk:2.1-stretch AS env
# Copy files from project into Docker /src folder and build project
WORKDIR /src
#Main Project
COPY /*.csproj /myprojectname
COPY . .
#Publish application to app directory
FROM env AS publish
RUN dotnet publish -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "myprojectname.dll"]
- Run your container. Assumes your container is working and published to Docker Hub…
docker run -v ~/x509stores/:/root/.dotnet/corefx/cryptography/x509stores/ --name mycontainername -d -p 80:80 -p 443:443 -e “ASPNETCORE_ENVIRONMENT=Production” -e ASPNETCORE_URLS=“http://+;https://+” -e ASPNETCORE_HTTPS_PORT=443 mydockerhubaccount/mycontainername
- Navigate to your domain name in the browser.
You could have a $5/month website this way that integrates easily with the CI/CD pipeline. I tested these basic steps and it works, but maybe more details are needed. I think it’s practical for smaller IT companies who don’t want to spend a ton of money to host a website.
Yeah, that’s kind of a mess, but if there is value in it, maybe I’ll write the instructions better.
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (2 by maintainers)
I would actually recommend using https://github.com/natemcmaster/LetsEncrypt#save-generated-certificates-and-account-information-to-a-directory instead of $HOME/.dotnet/corefx/cryptography/x509stores. Using the
PersistDataToDirectory
call will persists certificates AND your Let’s Encrypt account key, which allows you to renew your certificate weeks or months later when its close to expiring.Closing because there was no response to the previous comment. If you are looking at this issue in the future and think it should be reopened, please make a comment and mention natemcmaster so he sees it.