Scaleway Go Quickstart

PUBLISHED ON 2016-09-08

So, I have played with using Scaleway as a little webserver and decided to document it a bit.

I am falling in love with ARM servers. From the new ThunderX setups I am getting to try for batch processing, to smaller servers like Scaleway offers. Using Go makes it very easy to take advantage of all the new ARM goodness popping up everywhere.

23 steps to victory

  1. Start by setting up an account at Scaleway, all the basic stuff: credit card, email confirmation, etc. Only thing worth noting is that if you are in the US your bank might decline the transaction to an out of country organization, might want to inform them first to make sure transaction goes through. They will initially hit your bank for like $2.25
  2. Add your SSH key as per normal. How to create an SSH key
  3. Create Server, choose the cheapest one, and defaults work fine (Ubuntu 16.04). It will just take a little bit (less than a couple minutes) to be setup and ready to go
  4. Login as root@server-ip using your SSH key
  5. Create a new user by using adduser some_user_name
  6. Add the user to sudo group using sudo usermod -aG sudo some_user_name
  7. Logout as root
  8. Login as your some_user_name
  9. Confirm you can sudo sudo su - and get to root prompt
  10. Update your box sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade (just a good practice)
  11. Install git sudo apt-get install git
  12. Get go wget https://storage.googleapis.com/golang/go1.7.1.linux-armv6l.tar.gz
  13. Put it in place with sudo tar -C /usr/local -xzf go1.7.1.linux-armv6l.tar.gz
  14. Cleanup with rm go1.7.1.linux-armv6l.tar.gz
  15. Add to your shell startup export PATH=$PATH:/usr/local/go/bin (and run it right now in shell so it takes effect)
  16. Run go and you should see the go banner and some information
  17. Add to your shell startup export GOPATH=$HOME/go (and run it right now in shell so it takes effect)
  18. Get it with go get github.com/robertmeta/scaleway_hello
  19. Add to your shell startup export PATH=$PATH:~/go/bin (and run it right now in shell so it takes effect)
  20. Test it with scaleway_hello – you should see at the prompt “hello scaleway user”
  21. Get little server with go get github.com/robertmeta/scaleway_server
  22. Let it bind to port 80 without root using: sudo setcap ‘cap_net_bind_service=+ep’ ~/go/bin/scaleway_server
  23. Run it scaleway_server – there will be no output, it will just block at the prompt
  24. Go to http://server-ip and you will see Hello world!

Let me know if you get stuck on any of these steps, hope it helps.

What Next?

Whatever you can imagine, maybe install caddy and hugo and generate a nice looking static site.

  1. Get caddy go get github.com/mholt/caddy/caddy (on tiny arm box, this takes a few minutes)
  2. Let it bind to port 80 without root using: sudo setcap ‘cap_net_bind_service=+ep’ ~/go/bin/caddy
  3. Get hugo go get github.com/spf13/hugo (on tiny arm box, this takes a minute or two)
  4. Let it bind to port 80 without root using: sudo setcap ‘cap_net_bind_service=+ep’ ~/go/bin/hugo
  5. Use hugo to create a site hugo new site foo
  6. Switch to foo cd foo
  7. Get a theme git clone https://github.com/SenjinDarashiva/hugoscroll themes/hugoscroll
  8. Create content hugo new post/hello.md
  9. Setup your hugo config vim config.toml and it should look like: baseurl = "http://server-ip/" title = "Hello World" languageCode = "en-us" theme = "hugoscroll"
  10. Run hugo, it will output the site to the public directory
  11. Switch to the public directory cd public
  12. Setup your caddy config vim Caddyfile and it should look like: server-ip:80
  13. Run caddy and how you have a hugo / caddy site running!

More Goodness?

Lets get it on https now, that is fairly easy, but you will need a domain!

  1. Setup your-fancy-domain and point it to that server-ip address.
  2. Setup your hugo config vim config.toml and it should look like: baseurl = "https://your-fancy-domain/" title = "Hello World" languageCode = "en-us" theme = "hugoscroll"
  3. Setup your caddy config vim Caddyfile and it should look like: your-fancy-domain:443
  4. Check out your new fancy (https based) site on https://your-fancy-domain/
  5. Look at mine -> https://scaleway.robertmelton.com
comments powered by Disqus