Giter Site home page Giter Site logo

Dockerize Improvements about veterinaryclinic HOT 8 OPEN

f-nunez avatar f-nunez commented on June 15, 2024
Dockerize Improvements

from veterinaryclinic.

Comments (8)

f-nunez avatar f-nunez commented on June 15, 2024

Hello @harshit82, if you are still interested you can take this task related to Docker.
Feel free to contribute beyond what is mentioned in this. And no matter the time it takes, just enjoy.

from veterinaryclinic.

harshit82 avatar harshit82 commented on June 15, 2024

Thanks a lot for this, I will need some guidance.

from veterinaryclinic.

harshit82 avatar harshit82 commented on June 15, 2024

Any file you want me to start from?

from veterinaryclinic.

f-nunez avatar f-nunez commented on June 15, 2024

My bad I didn't tell you the context about the solution.

Well in short there are APIs and Web Apps to manage a Vet Clinic.
An Identity Api (IdentityServer) caring about authentication/authorization.
A Clinic Management API (clinicmanagement-api) and Blazor App (clinicmanagement-blazor) performing CRUD operations about Patients, Clients (pet owners) and Doctors.
A Scheduling API and Blazor App perfoming CRUDs Patient's appointments.
A Public Web App (public-web) handling appointment confirmations requested from Client's emails.
And more APIs behind.

You may find it useful to see the README file about how deploy and test the entire solution.

from veterinaryclinic.

f-nunez avatar f-nunez commented on June 15, 2024

For this Feature/Task. We can get focus in docker-compose.DockerDevelopment.yml and docker-compose.DockerNginx.yml at repository folder. Any of those files will show us how the containers (Services) are configured and where their Dockerfiles are located to build their images.

from veterinaryclinic.

f-nunez avatar f-nunez commented on June 15, 2024

To achive the third Criteria we can explore, compare and select related official images based on different Linux OS like debian, alpine, ubuntu, etc.

As example, if we look into a docker compose file at the entry labeled service called public-web, we can see where its Dockerfile is (.../Public/src/Fnunez.VeterinaryClinic.Public.Web/Dockerfile).

Working the third Criteria (Build smaller and secure images):
We can look into Dockerfile at the first line (FROM mcr.microsoft.com/dotnet/aspnet:7.0) and see a keyword "FROM" that specifies from which parent image we are building.

Then we could do some search at Docker's hub site for smallest official lighter images related to our current parent images.

Surfing on https://hub.docker.com/_/microsoft-dotnet we can see that there are a block called "Featured Repos" where we could get the ASP NET Core Runtime repo image (https://hub.docker.com/_/microsoft-dotnet-aspnet) and explore for a Tag Listing based on Linux which alpine is used to be the smallest and optimized image.

So taking the latest alpine version (7.0.203-alpine3.17-amd64) we just need to specify as the following line:
FROM mcr.microsoft.com/dotnet/aspnet:7.0.5-alpine3.17-amd64 AS base

After that, we will do the same for NET SDK (https://hub.docker.com/_/microsoft-dotnet-sdk) which currently and latest version is 7.0.203-alpine3.17-amd64.

And would looks like:
FROM mcr.microsoft.com/dotnet/sdk:7.0.203-alpine3.17-amd64 AS build

from veterinaryclinic.

f-nunez avatar f-nunez commented on June 15, 2024

Now the local Docker image for public-web would be smaller than before.
The final result on our Dockerfile would be like:

# Setup for docker-compose
FROM mcr.microsoft.com/dotnet/aspnet:7.0.5-alpine3.17-amd64 AS base # <--- changed
WORKDIR /app

FROM mcr.microsoft.com/dotnet/sdk:7.0.203-alpine3.17-amd64 AS build # <--- changed
WORKDIR /app
# run this from repository root
COPY ./ ./ 
# RUN ls -lha .

RUN echo 'Building Public Web container'

WORKDIR /app/Public/src/Fnunez.VeterinaryClinic.Public.Web
# RUN ls -lha .
RUN dotnet restore

RUN dotnet build "Fnunez.VeterinaryClinic.Public.Web.csproj" -c Development -o /app/build

FROM build AS publish
RUN dotnet publish "Fnunez.VeterinaryClinic.Public.Web.csproj" -c Development -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .

ENTRYPOINT ["dotnet", "Fnunez.VeterinaryClinic.Public.Web.dll"]

from veterinaryclinic.

f-nunez avatar f-nunez commented on June 15, 2024

Just comparing and playing a bit with old and new public-web image

Building and deploying the current/previous image through terminal:

docker-compose -f docker-compose.DockerNginx.yml build public-web --no-cache
docker-compose -f docker-compose.DockerNginx.yml up public-web -d
docker image list

We will see the current public-web image size is around 223 mb.

After edit the Dockerfile just re-build and re-deploy it:

docker-compose -f docker-compose.DockerNginx.yml down
docker-compose -f docker-compose.DockerNginx.yml build public-web --no-cache
docker-compose -f docker-compose.DockerNginx.yml up public-web -d
docker image list

We will see again the new public-web image size is around 119 mb.

In fact we reduced the image sizing from 223 mb to 119 mb.

from veterinaryclinic.

Related Issues (18)

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.