buro9 / microcosm

Front end for Microcosm, a Go web server that serves the static files, templates and performs API calls.
GNU Affero General Public License v3.0
11 stars 3 forks source link

Basic docker setup #53

Closed yemble closed 7 years ago

yemble commented 7 years ago

Useful to spin up a working stack quickly.

  1. Install docker
  2. docker-compose build
  3. docker-compose up

Need a proper api to point at, with a real hostname. Currently https://localhost produces an error in ApiRootFromRequest as it tries to do a DNS lookup (?) on localhost, and dev.microco.sm is blocked due to HSTS.

buro9 commented 7 years ago

Take a look at what I've merged... I've got it all working locally and it is definitely caching correctly but unsure if it required the exposing of 11211 from the memcached container.

How to know it's caching:

web_1    | 2017/03/13 23:32:40 https://dev.microco.sm/api/v1/site 109.62863ms
web_1    | 2017/03/13 23:32:40 https://dev.microco.sm/api/v1/whoami 24.764755ms
web_1    | 2017/03/13 23:32:40 https://dev.microco.sm/api/v1/microcosms 89.284874ms
web_1    | 2017/03/13 23:32:40 [32d112d81a58/TbnmhvN6WP-000001] "GET http://dev.microcosmcc.com/ HTTP/1.1" from 172.18.0.1 - 200 15841B in 718.369035ms
web_1    | 2017/03/13 23:32:43 https://dev.microco.sm/api/v1/site 369.093µs

Note the /api/v1/site line... it's gone from 100 milliseconds to 369 microseconds.

buro9 commented 7 years ago

Oh, and on local host I added dev.microcosmcc.com to my /etc/hosts as 127.0.0.1 so that I can just run things in my local browser and it works :)

yemble commented 7 years ago

Yep, that setup works here too.

I don't think the cache port needs to be exposed and the containers don't need to be linked either - compose starts a local network for the services, which can all see each other without any special config:

$ docker network ls
NETWORK ID          NAME                DRIVER              SCOPE
483cd3b18c95        microcosm_default   bridge              local

Right now it's giving me 404 on the two bootstrap files, despite downloading them and restarting - so I'm going to have a poke through the code and see why that is, as a learning exercise. Edit: duh, it was the bad volume mount path. I assumed it was loading files from host.

yemble commented 7 years ago

Happy to review code if you like, @buro9 - or track down bugs, etc. Maybe just call out what you need in the lfgss thread.

buro9 commented 7 years ago

Well the Docker stuff is a great help.

What I've done thus far is mostly to lay foundations.

I'm thinking that the actual conversation of the templates and views from the Django project at https://github.com/microcosm-cc/microweb won't take that long, but actually what's missing from Go is any demonstrated example of a large website actually being powered by Go.

So a lot of what I've done so far has been to think things like "How do templates work in Go when I want to share base files, and have lots of common blocks that multiple pages can use?" and "How can I achieve the equivalent of Django template tags to localize content or build URLs?".

I've created issues for converting all of the URLs within the Django project, and have assigned myself to a few.

I'm going to logically work through them in this order:

So far, the issues to which I've assigned myself are the ones I'm working on... the top level navigation. My hope is simply that the foundation emerges by nailing down a few complex templates.

So that's my order of work.

I've added you as a contributor to this project, and will now work on branches with PRs relating to the issues.

I tend to get a little done early in the week in the evening, and then 1 day on the weekend.

buro9 commented 7 years ago

BTW, you're right that memcached did not need ports exposed, and I've added you as a moderator on the dev site, so you can also edit random things and create forums, etc.