Coder Social home page Coder Social logo

alexkads / asp.net-core-in-fly.io Goto Github PK

View Code? Open in Web Editor NEW

This project forked from arshu/asp.net-core-in-fly.io

0.0 0.0 0.0 57.28 MB

Publishing a ASP.NET Core App in Fly.io. I discovered this while working (work in progress) on a more complex declarative web app framework using html/json which i am using fly.io to deploy

License: MIT License

JavaScript 2.31% C# 33.83% CSS 44.13% HTML 19.73%

asp.net-core-in-fly.io's Introduction

ASP.NET Core In Fly.io

Publishing a ASP.NET Core App in Fly.io.

Note: I discovered this while working (work in progress) on a more complex declarative web app framework using html/json which i am using fly.io to deploy guiapp app for publishing static data webapps in Git Repositories

Note : Docker is not required and hence can be done in Windows under Parallels in macos for those who don't have nested virtualization enabled/not available.

Step 1 - Create a Demo Asp.Net Core Project

Create a Demo Asp.Net Core Mvc Project in an Empty Directory

    dotnet new mvc -o AspNetDemo
    code -r AspNetDemo

Step 2 - Modify the Asp.Net Core Project

Modify the Asp.NET core Project to add the following property

    <ServerGarbageCollection>false</ServerGarbageCollection>;

The above setting will reduce the memory used by Asp.NET core so that the app can be deployed in the free tier of fly.io service

Step 3 - Publish the Asp.Net Core Project

Move to the Asp.Net Core Project Directory and run the following publish command to generate a

    dotnet publish -r linux-musl-x64 --output "..\linux64_musl" --self-contained true -p:PublishSingleFile=true -p:PublishTrimmed=true

Step 4 - Create a Docker File as below

    FROM mcr.microsoft.com/dotnet/runtime-deps:6.0-alpine-amd64

    EXPOSE 8080

    RUN mkdir /app
    WORKDIR /app
    COPY ./linux64_musl/. ./

    RUN chmod +x ./AspNetDemo
    CMD ["./AspNetDemo", "--urls", "http://0.0.0.0:8080"]

Step 5 - Ensure that you have installed fly.io

Ensure that you have installed fly.io client and done the getting started guide in Fly.IO Getting Started

Step 6 - Deploy AspNetDemo app to fly.io

Deploy the AspNetDemo app to fly.io using below commands. Ensure that the commands are run in the directory where the docker image exists

    flyctl launch

Enter the AppName : aspnet1

Select the Organization : Personal

Select the Region : Singapore

Step 7 - Verify the deployment

Verify the deployment by opening the browser and entering the following url in the following format

    https://aspnet1.fly.dev

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.