Code Monkey home page Code Monkey logo

bsed's Introduction

Fabian Doing by Learning Docker Experience

This repo is all about me learning Docker by doing it from the ground up. I wanted this to be here to

Approaches you can take here to get to a working solution

We will work from the least effort to the most effort, in doing that we will still get to the same solution but one way will just get you a working solution up and running in a few minutes, the second approach will get you same place, but you will have a copy of the solution as well in YOUR own custom image. All approches outlined below assumes you have Docker already installed and set up ready to go, however if that is not the case, the first 2 part of the Blog series above will show you how to get to that point.

Use my custom image in Docker Hub to spin up the solution

Do the following:

  • Create a Directory where you want your solution to live
  • Go into that directory create a file called "docker-compose.yml"
  • Copy the following into the file:
    version: "3"
    services:
        web:
            image: "fabianwilliams/fabsevalswebapi"
            ports:
                - "8000:80"
            depends_on:
                - db
        db:
            image: "microsoft/mssql-server-linux"
            ports:
                - "1433:1433"
            environment:
                SA_PASSWORD: "P@ssword1!"
                ACCEPT_EULA: "Y"

then run the following

	docker-compose up -d

You can now access the Dockerized app at: http://localhost:8000

Clone my Repo here and build your own solution

This solution will make a clone of what I have here in Github, and will result in you having your own solution. Run the following:

	git clone https://github.com/fabianwilliams/bsed.git
	cd bsed
	docker-compose build
	docker-compose up -d

You can now access the Dockerized app at: http://localhost:8000

One thing to note about this solution that is quite important is the YML file that you see above has one line that is swapped out. the line that has the image in there would be gone and in its place would be

this one uses whats inside the DockerFile below. which takes the base image of aspnetcore and layers it with this Web.API solution. The docker file looks like:

Running my Fabian Evals Docker Solution using Docker Swarm

I've now added the capability to put my solution in Swarm Mode!!! You will need to modify my Docker Compose File a bit to add the DEPLOY section. In this case we are adding 2 Replicas ONLY for the WEB service which means it will run as in my case on 2 Nodes since i have more than 1 Ubuntu VM stood up. But you can still get multiple container replicas even if you have 1 Node, it just would mean you would have multiple replicas on 1 node.

version: "3"
services:
    web:
        image: "fabianwilliams/fabsevalswebapi"
        build: .
        deploy:
            replicas: 2
            restart_policy:
                condition: on-failure
        ports:
            - "8000:80"
        depends_on:
            - db
    db:
        image: "microsoft/mssql-server-linux"
        ports:
            - "1433:1433"
        environment:
            SA_PASSWORD: "P@ssword1!"
            ACCEPT_EULA: "Y"

Make sure you are running in swarm mode (docker swarm init). You can then run the following to deploy the containers to Docker Swarm with:

	docker stack deploy -c docker-compose.yml FabsEvals

Thank you all. I hope you have as much fun as I did makeing this.

bsed's People

Stargazers

 avatar

Watchers

 avatar

bsed's Issues

Speed Up Docker builds by using cache

Dude,

you should refactor your Dockerfile a bit. In order to use proper layer caching you should only add required files before executing dotnet restore. Right after `RUN ["dotnet", "restore"] copy the new sources.

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.