Heroku is a cloud platform that supports a number of languages.NET Core has yet to be officially supported. The options for deploying.NET Core applications to Heroku are using Third Party buildpacks or container support. It can take some digging to find a buildpack that is well maintained and working properly for the version. .NET Core continues Microsoft’s shift towards a more open development philosophy. It is open-source and cross-platform. With a little bit of setup, you can get a.NET Core web app running on Linux-powered Heroku.
image: docker:git |
services: |
- docker:dind |
variables: |
DOCKER_DRIVER: overlay |
# You can find this on your Gitlab repo page, under 'Registry' |
CONTAINER_GITLAB: registry.gitlab.com/<USER OR GROUP NAME>/<REPO NAME> |
# It's just a tag, use whatever you want : back, front, test, staging... |
CONTAINER_TAG: latest |
# Change with the name of your Heroku app |
CONTAINER_HEROKU: registry.heroku.com/<HEROKU APP NAME>/web |
# Can be found on: https://dashboard.heroku.com/account under 'API Key' |
HEROKU_API_KEY: <LOOKS LIKE A GUID> |
# Heroku User name for login: usually an e-mail address |
HEROKU_USER: [email protected] |
# Order of tasks |
stages: |
- dockerize |
- deploy |
# Register in your gitlab registry. The environment variables are set automatically, don't change anything. |
before_script: |
- docker login -u gitlab-ci-token -p '$CI_BUILD_TOKEN' '$CI_REGISTRY' |
dockerize: |
stage: dockerize |
script: |
# Make an image from the current folder and tag it with the registry name and tag you defined |
- docker build -t $CONTAINER_GITLAB:$CONTAINER_TAG . |
# Push to Gitlab |
- docker push $CONTAINER_GITLAB:$CONTAINER_TAG |
only: |
- master |
# At this point, you could go to your repo 'Registry' page on Gitlab and see your image |
deploy_to_heroku: |
stage: deploy |
# On Your CI/CD page on Gitlab, under 'Environment', you can add new ones with informations like these and get informations about this deploy task |
environment: |
name: staging |
url: https://<HEROKU APP NAME>.herokuapp.com/ |
services: |
- docker:dind |
script: |
# Login to Heroku's registry |
- docker login --username=$HEROKU_USER --password=$HEROKU_API_KEY registry.heroku.com |
# Gets your Gitlab image |
- docker pull $CONTAINER_GITLAB:$CONTAINER_TAG |
# Make it good looking for Heroku |
- docker tag $CONTAINER_GITLAB:$CONTAINER_TAG $CONTAINER_HEROKU |
# Push it to Heroku |
- docker push $CONTAINER_HEROKU |
only: |
- master |
I've recently finished building my first from-start-to-sort-of-finish MVC application in .NET Core which I want to host.
However the only possibility of free hosting I can find is using Heroku, which only seems to support earlier versions of .NET Core (or Visual Studio) which uses project.json
.
As such I've been looking around online to find a way to convert my .msproj
project to a project.json
project.
Has anyone else encountered this, or have heard of solutions?
2 Answers
I haven't tested yet, but try this buildpack. Its support project.json and csproj as well.
You could create a Dockerfile to generate a Docker image runnable on Heroku.
Then you can publish it to Heroku either directly using these Docker commands:
In order these commands:
- Create a Docker image and builds a release of your project in it
- Connect to Heroku's docker registry using your credentials
- Creates a new tag for your image
- 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://blog.iamnguele.com/2018/02/21/continuous-delivery/
CodingNaggerCodingNagger