Compile Aspnet core 1.1 outside Docker container but run within

January 14th, 2017

Prerequisite

OSX

Docker

Dotnet core 1.1

A folder named (e.g.) /Users/yourname/Docker/Dandelion
and a folder named (e.g.) /Users/yourname/Docker/Dandelion/MyWeb

Create the web

In MyWeb run

1
2
3
4
dotnet new -t web
dotnet restore
dotnet build
dotnet publish

Now we have a web site compiled and ready to run with [dotnet run].
You can run the app and then [curl localhost] to find out if it is runnable; but if you got no error message earlier all should be ok.

Create an image

Go to the Dandelion folder.

Create a file Dockerfile and paste into it:

1
2
3
FROM microsoft/dotnet
EXPOSE 80
ENV "ASPNETCORE_URLS=http://+:80"

Then, to create the image run

1
docker build -t yourname/dandelion .

Note that the name must be all small caps.
Don’t miss the trailing period.

If you want to check that the image is created just execute [docker images] which should show the new image at the top of the list.

Start the container

Go to the Dandelion folder. (you are probably already standing there)

Execute

1
2
3
4
5
docker run -p 80:80 \
-ti --rm \
-v /Users/yourname/Documents/Docker/Dandelion/MyWeb/bin/Debug/netcoreapp1.1/publish:/MyWeb \
yourname/dandelion \
/bin/bash -c 'cd /MyWeb; dotnet MyWeb.dll'

and your web should start.

Verify result

Either open another console and execute

1
curl localhost

or go to localhost in your web browser.

dotnet publish command returns npm error

January 10th, 2017

When trying to

1
dotnet publish

a dotnet core 1.1 project you might receive

1
2
Publishing TheApp for .NETCoreApp,Version=v1.1
No executable found matching command "npm"

The remedy is to install NPM.

If you are running OSX you probably got Homebrew with the installation.
So just

1
brew install node

Then you might get

No executable found matching command “bower”

which means that Bower is missing. According to https://github.com/dotnet/cli/issues/3293 you should install it through npm like so:

1
2
npm install -g bower
npm install -g gulp

Create and run an Aspnet core 1.1 web site in Docker container on OSX

January 7th, 2017

Prerequisite:

Docker and Dotnet Core 1.1 should be installed on the host (=OSX).

You have a folder somewhere, for instance /User/yourname/Documents/Docker/mywebapp.

Create the image

In your folder, create the dockerfile

1
2
3
4
5
6
7
8
FROM microsoft/dotnet
# VOLUME /Documents/Docker/mywebapp
EXPOSE 80
ENV "ASPNETCORE_URLS=http://+:80"
RUN mkdir app
WORKDIR /app
RUN dotnet new -t web
RUN dotnet restore

Then execute

1
docker build -t mynick/myimage .

in a terminal in said folder.

If you now execute

1
docker images

you can se the new image as mynick/myimage.

Create the container and start the web server

In the terminal execute

1
2
3
4
docker run \
-p 80:80 \
-ti --rm mynick/myimage \
/bin/bash -c 'cd /app; dotnet run;'

Behold result

In a terminal execute

1
curl localhost

or in a web browser go to

1
localhost

Run Docker Dotnet core aspnet 1.1 web server with mounted executable on OSX

January 3rd, 2017

Prerequisite

Install docker.

Install Dotnet Core 1.1.

Create web application

Create a directory “theapp”.

Open a terminal and, in the directory, execute:

1
2
3
dotnet new -t web
dotnet restore
dotnet run

Check it works.

Execute, in a terminal:

1
curl localhost

Or is it

1
curl localhost:5000

?

Create container

In a terminal execute:
(after you have have updated “YourRootedPathAndFolder” appropriately.

1
2
3
4
5
6
docker run -p 80:80 \
-e "ASPNETCORE_URLS=http://+:80" \
-ti --rm \
-v /YourRootedPathAndFolder/TheApp:/theapp \
microft/dotnet \
/bin/bash -c 'cd /theapp; dotnet restore; dotnet run'

and when it is finished churning through the long list of modules open a new terminal and execute

1
curl localhost

on your host to receive a smaller waterfall of HTML.

That should be it.

Troubleshooting

If you forget to do the dotnet restore

1
2
3
4
docker run -p 80:80 \
-ti -v /Users/ola/Documents/Docker/loose/TheApp:/theapp \
microsoft/dotnet \
/bin/bash -c 'cd /theapp; dotnet run'

You get something like:

Project theapp (.NETCoreApp,Version=v1.1) was previously compiled. Skipping compilation.

Error: assembly specified in the dependencies manifest was not found — package: ‘Microsoft.AspNetCore.Antiforgery’, version: ‘1.0.1’, path: ‘lib/netstandard1.3/Microsoft.AspNetCore.Antiforgery.dll’

Attach and request

Run

1
docker ps

in a terminal. Note the Container ID.

Then execute, after the b5a…f5 is updated appropriately.

1
docker exec -it b5a8ccd5b1f5 bash

Now you have a shell inside the container and should be able to get a result from:

1
curl localhost:5000

Create a Dotnet aspnet core 1.1 web server in OSX

December 31st, 2016

Install Dotnet core à la https://www.microsoft.com/net/core#macos

Create a folder and to to it.

Open a terminal (one cannot reuse any terminal from before dotnet was installed since the path is updated) and execute:

1
2
3
dotnet new -t web
dotnet restore
dotnet run

Open another terminal and execute:

1
curl localhost:5000

A pile of HTML should scroll into view.

In the first terminal you can see the reaction.

Running Dotnet aspnet 1.1 in a Docker container on OSX without any Windows

December 29th, 2016

Prerequisite

Install Docker on OSX.

Create Dockerfile

Create a file named Dockerfile in a new folder.
Its contents are:

1
2
3
4
5
6
7
8
FROM microsoft/dotnet
# VOLUME /Documents/Docker/dnc
EXPOSE 80
ENV "ASPNETCORE_URLS=http://+:80"
RUN mkdir app
WORKDIR /app
RUN dotnet new -t web
RUN dotnet restore

Create image

1
docker build -t yournick/yourimagename .

Run image

1
2
3
docker run -p 80:80 \
-ti --rm yournick/yourimagename \
/bin/bash -c 'dotnet run'

See output

On the host:

1
curl localhost

and you should se a whole dab of HTMl. You can also watch it in your browser.

Starting Dotnet aspnet core 1.1 on OSX in a Docker container

December 27th, 2016

Install Docker on OSX.

https://docs.docker.com/docker-for-mac/

Prepare local drive

(This is strictly not necessary but if you skip this you have to remove the -v and following path from the docker run command further down. You will also have to mkdir the app folder in the container before cd to it.)

Go to you your local Documents folder. Create a Docker folder. Inside it create a dotnetcore folder. This results in /Users/myname/Documents/Docker/dotnetcore.

Start container

Open a terminal and execute (after exchanging “myname” to your user’s name)

1
2
3
4
docker run -p 80:80 \
-e "ASPNETCORE_URLS=http://+:80" \
-v "/Users/myname/Documents/Docker/dotnetcore:/app" \
-it --rm microsoft/dotnet

This will download the microsoft/dotnet image, start it, connect your host’s dotnetcore folder to an app folder inside the container, set an environment variable, publish the internal port 80 on port 80 and finally open a terminal inside the container; all in one go.

Start the web server

Now inside the container execute

1
2
3
cd app
dotnet new -t web
dotnet restore

Absolutely not necessary but if you

1
cat Program.cs

you will see something like

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
namespace WebApplication
{
public class Program
{
public static void Main(string[] args)
{
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
// .UseUrls("http://0.0.0.0:8000")
.UseIISIntegration()
.UseStartup<Startup>()
.Build();
host.Run();
}
}
}

Start the web server through

1
dotnet run

This will also compile the code before starting the application.

See output

If you open

1
http://localhost

in your host’s web browser you should now see a page about Dotnet aspnet core.

That all there is to it!

Trouble shooting

If you don’t check that the web server is running and listening on port 80 locally. This is done by opening a new terminal and check the ContainerID through

1
docker sp

Then you attach a terminal to the running container.

1
docker exec -it d10988067ec8 bash

(but with proper id)

Now, inside the container, run

1
curl localhost

and you should get a boatload of HTML back. In the other terminal window you should see some reaction to the request.

Links

More thourough but for version 1.0

https://store.docker.com/images/6c038a68-be47-4d7e-bfd2-33a6fe75b9ac?tab=description

Learn children to be a producer of content and not only a consumer on a tablet

November 30th, 2016

A tablet is not only for onsuming what other people have done. You can too. Also a kid can.

Bloxels

Create your own side scroller.

There is also hardware if you want.

http://www.bloxelsbuilder.com/

Coda game

I have not tested

http://filimundus.com/coda-game/

Daisy the dinosaur

There is not a clear goal, just fiddle around. For good and bad. It is like making movies in ScratchJr but only side scrolling and less effects.

http://daisythedinosaur.com/

The Foos

It is like Lightbot but side scrolling and with funnier characters. The goal is somewhat funnier compared to lightbot; getting a donut for a (US) police officer instead of just lighting a light bulb. To try it out there is an older? version on the web.

http://thefoos.com/play/

Hopscotch

Like Scratch.

https://www.gethopscotch.com/

Hour of code

Lots of stuff.

https://code.org/

Lego Minecraft

Hard to use computer interface.

Expensive.

Light bot

Make a little robot find her way around stairs and obstacles.

https://lightbot.com

Light bot looking but with famous figures like angry birds

https://studio.code.org/hoc/1

Minecraft (pocket edition)

https://minecraft.net/pocket

Scratch(Jr)

Unlogical user interface.

https://scratch.mit.edu/

Also see https://www.dexterindustries.com/BrickPi/program-it/scratch/ for using Scratch with Raspberrypi.

More mechanical than programming

Pettson and Findus

http://filimundus.com/pettsons-inventions/
http://filimundus.com/pettsons-inventions-2/
https://filimundus.com/pettsons-inventions-3/

Inventioneers

http://filimundus.com/inventioneers/

I have not tested

Cargo-bot

https://itunes.apple.com/us/app/cargo-bot/id519690804

Tynker

I have not tested.

https://www.tynker.com/

Move the turtle

itunes.apple.com/us/app/move-turtle.-programming-for/id509013878?mt=8

On a proper computer

Blockly

https://blockly-games.appspot.com/?lang=en

Quit skype with alt-F4 (Autohotkey needed)

October 20th, 2016

Due to overzealous user interface design Skype does not close with alt-F4 but instead minimises. That is not considered good behaviour.

I have found no setting in Skype to restore it normal Windows behaviour.

So I found and copied a Authotkey script that restores makes alt-F4 properly close Skype.

1
2
3
4
5
6
#IfWinActive ahk_exe Skype.exe ahk_class tSkMainForm
!f4::
WinClose
ExitApp
Return
#IfWinActive

Kudos to original article https://autohotkey.com/board/topic/126066-script-to-run-skype-with-real-alt-f4/

When code reviewing – do not forget to give appraisal too

September 29th, 2016

Albeit code reviewing is for the greater good and we all adhere to the idea of common ownage of code we are still critisising someone else’s labour.

Psychologically we cannot neglect that.

Ergo: remember to tell about the good solutions and code you find.

Unfortunately TFS does not have a (good) solution for differentiating between comments and praise and critisism.