Building a tiny docker image

For a while, and purely for fun and experimentation, I've wanted to create a Docker image which does something useful and isn't huge. I knew that it's possible to use gcc to compile C code with the -static flag and then run it standalone inside a Docker container, but I'd never actually tried it. It's just one of those things I wanted to do. It means you can build your Docker image from scratch and not need any other OS files from another distribution. I was aiming for something that could be measured in kilobytes rather than megabytes.

So ... I decided to try and build my mini-webserver, dweb with the -static flag, then pack it down with upx before setting it up to run in Docker. I thought that I could get it to run the webserver in the container, but serve up files from a location on the host machine. I have no real need to do that, but I thought that it would be interesting. I'm not suggesting that this is a really good idea, but I do like the idea of avoiding bloat in docker images.

The result is on Docker Hub here and GitHub here. The compressed size of the image comes in at just 364 KB. That makes a nice change.

Well, that was fun. Perhaps one day I'll use this technique to do something useful, but at least I know how.

Another HooToo HT-TM02

A while back, my wife noticed that the HooToo HT-TM02 was on a special deal at Amazon. So she bought me another one. This is the second one I have. The one I got before is in daily use as an internet radio and is doing a fantastic job. But the problem is that I don't want to mess about with it, because I might break my radio! So this *second* one gives me something to actually play about with...

As before, I immediately installed OpenWrt on it. The installation procedure involves adding some extra storage which gives some additional space during the install process. So you need to plug in a correctly formatted USB thumbdrive. The instructions advise you to check whatever USB storage you have added is working before proceeding. But when I did it this time I forgot to check, so there was a slightly tense moment! Anyway it must have been fine, because the install went without a hitch. Phew.

Then I upgraded to the latest released version of OpenWrt (which was Chaos Calmer 15.05.1) and reset it to the default configuration. I like to work from a clean starting point. So this gives me a good hackable little linux toy to play with. I expect that most of my effort will be continue to be programmed in Nim and cross-compiled.

So here are my notes on configuring the basics when setting up a HooToo HT-TM02 with OpenWrt. This should make it easy to repeat if I need to do a factory reset. It assumes that there is a home router with an address of 192.168.1.1, so works around that. Obviously, it assumes that OpenWrt has already been installed on the HooToo. The aim is to have the HooToo connecting to an existing wifi network, so you can get to it wirelessly, and it can download packages and updates. But also, a network cable still works if required. Here goes:

  1. Start with OpenWrt defaults. Connect with a network cable and get an IP address from DHCP
  2. Don't connect to any other networks, because it will clash with the router
  3. Now point a browser to 192.168.1.1
  4. Log-in without a password and then set a new password straight away
  5. Edit the LAN address of the HooToo to 192.168.0.1 but leave DHCP on
  6. Save and then reboot the HooToo, it now should not clash with your router
  7. After the reboot, unplug and re-plug the network cable, just to be sure
  8. Point your browser to the new address, 192.168.0.1 and log in again
  9. Now, scan for your own wifi and click "Join Network"
  10. Enter your wifi passphrase
  11. Assign the wifi connection to the firewall zone "LAN", but otherwise, use the defaults and save
  12. Check the HooToo has an internet connection (eg go to: System->Software and click "Update Lists")

Connecting via a cable should now give a DHCP address in the 192.168.0.x range, so using a cable is also possible in case wifi is not an option. For me, this is a pretty good starting point; now the fun stuff begins.

Retro terminal on macOS

In the February 2017 issue of Linux Magazine (in the Linux Voice section), there was mention of Cool-Retro-Term. It gives you a terminal emulator that tries to duplicate the experience of using an old cathode ray tube monitor. But I also noticed that it comes with a dmg for installing on macOS.

And since I like a bit of retro technology, I couldn't resist trying it out. So I went a put a copy on my MacBook Pro. It really is quite cool looking, and visually reproduces an ancient monitor quite well. It even has the bend at the edge of the screen. Personally, I've turned off the glow line feature because I found it distracting. I have also made the font smaller, so that I can get more text on the screen - that's probably cheating - but it made the terminal more usable. Currently, I'm using the Apple II font from 1977.

Here I am using it to mess about with streaming radio from Madplay on one of my routers running OpenWrt:

It was really simple to install on macOS, and it really does faithfully reproduce the monitors from the old days. It's good nostalgic fun.

Upgrading to the latest release of Nim

I have had some fun in the last few of days. I decided to upgrade to the latest version of Nim ... because I had gotten a couple of releases behind I think. It is not a hard thing to do, but was just something that I had not gotten round to.

Anyway, for some reason, I decided to rebuild everything, including the Aporia IDE whilst I was at it. That's where things went a bit wrong, and sadly I had already binned the previous version of Aporia. So I was at risk of not having my IDE for Nim.

Whenever I tried to use Nimble (Nim's package manager) to rebuild Aporia, I was getting errors about dependency conflicts with GTK. Eventually, I grabbed the Aporia repository and was able to hack the aporia.nimble file. If you're really interested, I found that removing #head from where it says it requires gtk2 did the trick. Finally, I was able to build the latest Aporia. Phew, panic over.

After having figured all that out, I was looking at the Nimble repository on GitHub and noticed this build failure:

So ... it looked like bad timing. Not being able to install Aporia was being worked on. This must be due to the Nim incarnation of dependency hell I guess. But I can now report that this problem has been fixed anyway. It seems that I had just chosen the wrong moment to do my rebuild. It happens.

After a little more digging and some discussion on GitHub, it appears that I had been using a bleeding-edge copy of the Nimble package manager. So it's understandable that things might break. When I retraced my steps, I realised that I had installed Nimble from a script included with the release of Nim I had been using. That script installs the bleeding edge version, which is probably the wrong thing to do. So I logged that as an issue on the Nim repository. But it seems like the next release of Nim is just round the corner anyway. I'll try to upgrade to that version more quickly this time!

So, for the time being all is well. I have the latest release of Nim installed and Aporia is back. I've also replaced Nimble on my machine with the latest tagged version (manually), so in the meantime I should have a more stable setup. And I kind of enjoyed all this stuff anyway, so no worries.

Wifi problems with Elementary OS Freya on the ideapad 100

This week I had a problem where wifi suddenly stopped working on my Lenovo ideapad 100 15iby running Elementary OS Freya. I don't know what happened, but suddenly the machine refused to work with any access points. It would say I was connected, and I would have an IP address from DHCP... but there was no actual connection working. Chrome would just complain there was no internet, for example.

I ended up having to rebuild the Realtek rtl8723be wifi driver from the source repository here: https://github.com/lwfinger/rtlwifi_new/ but actually that was not too bad, because the instructions are quite simple. I just had to follow this post which seemed to work fine for me. But I did need to disable the sleep feature of the driver, which is mentioned as an extra step in the instructions. Otherwise the connection would keep dropping and then prompting me for my wifi password all the time.

So that was a slightly annoying problem! But I am pleased to have it sorted out. As I'm writing this I'm downloading a 750Mb file to make sure it's all OK. I'm currently at 500Mb and all is fine, so hopefully that's a job well done.

I have also noticed that Elementary OS Loki is now released, but there is no upgrade route from Freya, so I need to find some free time to do a backup and clean install. Hopefully that will be a smooth process... maybe I'll try running it 'live' first, without installing, to make sure that things work beforehand. That's a job for another day.

Vanishing mouse on my Lenovo ideapad

One problem I have found with my new Lenovo ideapad 100 15iby running Elementary OS Freya is an issue with the mouse pointer vanishing, as reported here. It seems that if you lock the machine, close the lid, or let it go to sleep, then after signing back in there is no mouse pointer. It's annoying because neither the trackpad or an external mouse seems to work.

Anyway, the solution which seems to work for me is just to replace Light-Locker with Gnome Screensaver. It means that the lock screen is not as pretty looking, but I'd rather have a mouse that works!

It's an easy fix and worth it, although it looks like future updates won't suffer from the same problem. So I look forward to trying that out when I upgrade to Elementary OS Loki. But I'm waiting for it to be released rather than using the beta.

Updated!

I have just migrated this blog to a newer version, so hopefully everything will work and all the old content will have been transferred over...  And I should be able to continue blogging again soon ... as long as I can tear myself away from learning Nim.

The Silicon Shed

I've been a bit quiet recently, my blog hasn't gotten much attention. But I have been getting up to speed with my new job and so I've been adjusting to my new routine.

Nowadays I work from home, which is nice because I don't have to commute. I am particularly enjoying that, because sitting in the car for hours a day always seemed like a waste of time. This also means that I don't need to wake up at 6am each day...

But to separate home life from work life I have made a separate office by converting my garage. So this means that I don't actually work in the house. I find that this really helps - I don't get distracted during working hours. It's worked out very well. Here's a picture of me sitting at my new desk:

My colleagues have named my new workspace the Silicon Shed and the name has really stuck. I have even tried to set things up so that a colleague can come over and join me for a bit of pair-programming. When I was reading the book "Hello, Startup" this sentence particularly made me smile:

"At this very moment, somewhere in the world, two programmers are sitting in a garage and creating our future, one line of code at a time."

These days I find myself mostly working with Azure WebJobs (which are awesome) and doing lots of C# async stuff. But when you work for a small company anything can happen, so that's a massive oversimplification really. Every day I'm learning something new, which is part of the fun.

La Palma minecraft addiction?

On the Spanish island of La Palma in the Canaries, local town planners deny they've become addicted to Minecraft:

Well OK, just kidding, but that's the kind of thing that went through my head when I took the photo... sorry.

Bad Robot!

In our house, we love our Roomba robot vacuum cleaner. We have had ours for years and it is pretty well behaved. Just occasionally it eats a stray sock or something. But its seems to have had a bad day this time:

Oh dear! It must have bumped the fireplace and then gotten tangled up in the resulting chaos. No real harm done, but it did look pretty funny.