简体   繁体   中英

is it possible to run windows service / app (c#) on heroku platform?

I am checking the possibility to run my C# service on the Heroku platform...

Does anyone have an experience with such a solution?

There are some Heroku buildpacks for that use Mono to run .NET and C#. Here's the one that I built: https://github.com/friism/heroku-buildpack-mono

You could create a Dockerfile to generate a Docker image runnable on Heroku.

FROM microsoft/aspnetcore-build:2.0 AS build-env
WORKDIR /app

# Copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore

# Copy everything else and build
COPY . ./
RUN dotnet publish -c Release -o out

# Build runtime image
FROM microsoft/aspnetcore:2.0
WORKDIR /app
COPY --from=build-env /app/out .
CMD ASPNETCORE_URLS=http://*:$PORT dotnet <YOUR_API_NAME>.dll

Then you can publish it to Heroku either directly using these Docker commands:

docker build -t aspnetapp <YOUR_API_NAME>
docker login --username=$HEROKU_USERNAME --password=$HEROKU_API_KEY registry.heroku.com
docker tag aspnetapp registry.heroku.com/$HEROKU_APP_NAME/web
docker push registry.heroku.com/$HEROKU_APP_NAME/web

In order these commands:

  1. Create a Docker image and builds a release of your project in it
  2. Connect to Heroku's docker registry using your credentials
  3. Creates a new tag for your image
  4. Publishes your image to your Heroku app

However, if your machine does not support Docker, you can also use CircleCI to run these commands. More details here: https://www.codingnagger.com/2018/02/21/continuous-delivery/

There is now an official Heroku buildpack for building ASP.NET 5 (Core) apps using project.json files and the kpm package manager. Mono is bundled for runtime execution.

Example usage:

$ heroku create --buildpack http://github.com/heroku/dotnet-buildpack.git
$ git push heroku master

The buildpack will detect your app as ASP.NET 5 if it has project.json. If the source code you want to build contains multiple project.json files, you can use a .deployment or set a $PROJECT config var to control which one is built.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM