doc_noob
doc_noob

Reputation: 625

Dockerizing existing application

I am completely new to docker and i am not a developer. Right now i have an application which runs on centos/nginx/dotnetcore . In dotnet core i have 4 applications, we run them using dotnet appname.dll. or rather systemd. If i want to dockerize this application set, should i create centos as a separate docker image and then nginx as other image and then an image for each of the application ? If yes how do i link them, or should i create only one image with centos/nginx and all 4 applications (which is in tar) installed? Any help on this would be appreciated.

Upvotes: 2

Views: 289

Answers (2)

aekiratli
aekiratli

Reputation: 538

Check the dockerfile below about the ASP.NET rest API. It is the same way when you call dotnet appname.dll. Instead of running in Centos it runs in container which is debian based if I'm not wrong

FROM mcr.microsoft.com/dotnet/core/sdk:2.1 AS build-env
WORKDIR /app

COPY MicroService1.csproj MicroService1/
RUN dotnet restore MicroService1/MicroService1.csproj

COPY . .
RUN dotnet publish ./MicroService1.csproj -c Release -o out

FROM mcr.microsoft.com/dotnet/core/aspnet:2.1
WORKDIR /app
RUN ls
COPY --from=build-env /app/out ./

ENTRYPOINT ["dotnet", "MicroService1.dll"]

If you have 4 dependent applications you can use docker-compose.

version: '3.0'

services:
   db:
     image: mysql:5.7
     environment:
       MYSQL_RANDOM_ROOT_PASSWORD: 1
       MYSQL_DATABASE: accountowner
       MYSQL_USER: dbuser
       MYSQL_PASSWORD: dbuserpassword
     volumes:
       - dbdata:/var/lib/mysql
     ports:
       - "3306:3306"
     restart: always

   microservice1:
     depends_on:
       - db
     build:
       context: ./MicroService1/MicroService1
     ports:
       - "8080:80"
     restart: always

   frontend:
     depends_on:
       - microservice1
     build:
       context: ./Frontend
     ports:
       - "4200:4200"

volumes:
  dbdata:

Above docker-compose.yml given. It contains 3 service which are frondend, backend and database. In your docker-compose.yml you should define your 4 application

Upvotes: 1

Rajesh kumar R
Rajesh kumar R

Reputation: 214

nginx and dotnet as 2 seperate containers for each application would be ideal and recomended

Upvotes: 0

Related Questions