joy-framework / joy

A full stack web framework written in janet
https://joy.swlkr.com
MIT License
537 stars 30 forks source link

chore(docker): add a simple docker/compose config and info about it #52

Closed hweeks closed 4 years ago

hweeks commented 4 years ago

This adds a basic Dockerfile with janet, jpm, and joy all installed and configured. It installs the code from jpm. I would be ok with building something that actually builds and ships joy in the container. I was looking at doing that but it seemed like you'd have to go mono-repo for that to be easy, as there are a few inner linked packages here.

hweeks commented 4 years ago

@swlkr I've got a few questions for you on this:

  1. is there a setting to change which host halo listens on? It looked like there was but I don't know enough about C to work on it. Is it here?
  2. I'd also like to probably setup a nginx server to front joy with HTTPS support and a simple reverse proxy, is that your expectation for a deployment?
  3. I'd like to create a doc around deploying/usage in a 'production' environment, where should that go?

PR in response to #49

swlkr commented 4 years ago
  1. Yep that should change which host halo listens on
  2. Yes, definitely front with nginx and reverse proxy, here's the nginx config I'm using for askjanet.xyz:
server {
  listen 80;
  listen [::]:80;
  server_name askjanet.xyz www.askjanet.xyz;
  return 302 https://$server_name$request_uri;
}

server {
  # SSL configuration

  listen 443 ssl;
  listen [::]:443 ssl;
  ssl        on;
  ssl_certificate         /etc/ssl/certs/askjanet.pem;
  ssl_certificate_key     /etc/ssl/private/askjanet.pem;

  server_name askjanet.xyz www.askjanet.xyz;

  access_log /var/log/nginx/access.log;
  error_log /var/log/nginx/error.log;

  gzip on;
  gzip_types text/css application/javascript;

  location ~ \.(css|js|svg|png) {
    root /home/sean/askjanet/public;
  }

  location / {
    proxy_hide_header Upgrade;
    proxy_pass http://127.0.0.1:8001/;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
  }
}
  1. Yeah! That would be amazing! Probably in docs/ just a bunch of markdown files. I'll eventually pull them out and stick them on the website and make them look pretty.
hweeks commented 4 years ago

Let me be way more specific about the port/host thing. I'm not sure how to call the start-server function with options, can you provide an example? I'm just now learning C/LISP/Janet so bear with me :P

swlkr commented 4 years ago

Wow that docker documentation is thorough thanks for that @hammywhammy

For the host thing, it's here https://github.com/joy-framework/halo/blob/master/halo_lib.janet#L3 so you call server with a third optional argument:

(import joy)

(joy/server (app) 9001 "127.0.0.1")

If it isn't working, that's a whole other thing, but that should do it.

swlkr commented 4 years ago

I was trying to test out this docker file first but it looks alright