Skip to content
This repository was archived by the owner on Jul 15, 2022. It is now read-only.

Conversation

@alfonsomunozpomer
Copy link
Contributor

To spin up a container just do:

docker build -t sitejs .
docker run -p 80:80 -p 443:443 sitejs

Since running sysctl within a Docker container is not allowed I added a flag for the serve command to skip disabling privileged ports on Linux via sudo sysctl .... I haven’t added documentation of this flag in README.md since I’m not sure how you’d like to handle this.

Regarding the Dockerfile itself, I first had in mind building Site.js in the host machine and then add it to the container via COPY. However, on my first go at it, running Site.js in the container complained about libc versions, so I decided to better build the app in the image. The biggest downside of this method is that the resulting image is a whopping 1.2 GB. Another option could be to have two containers, one that builds the app and produces the executable site and then copy it to a second container. I’ve tried it and the resulting image is ~200 MB. The downside is that the whole process isn’t self-contained in a single step.

To build Site.js in the container I had to replace your self-hosted patched version of Nexe with version 3.3.7. If I didn’t, running npm install would produce a node_modules/nexe directory which missed a required lib directory. This didn’t happen outside the container, so it’s really puzzling and if somebody has enough free time to investigate what’s going on I’d love to hear why.

A limitation is that within Docker you can’t run the command enable, again due to Docker’s limitations (no systemd or systemctl). However, I think that’s fine and running serve fits with the Docker/container philosophy of one container, one process.

By default the resulting container runs site serve /var/www/html --docker but you can pass any command you like, e.g.:

docker build -t sitejs .
docker run sitejs help

What I’ve noticed is that Firefox (or any other browser) won’t trust the certificates coming from the container. I’ve very limited knowledge about HTTPS/SSL so this is something that currently I haven’t got the time to look into. Without any arguments curl will fail:

$ curl 'https://localhost'
curl: (60) SSL certificate problem: self signed certificate in certificate chain
More details here: https://curl.haxx.se/docs/sslcerts.html

curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.

But:

$ curl -k 'https://localhost'
<!doctype html><html lang="en" style="font-family: sans-serif; background-color: #eae7e1"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Error 404: Not found</title></head><body style="display: grid; align-items: center; justify-content: center; height: 100vh; vertical-align: top; margin: 0;"><main><h1 style="font-size: 16vw; color: black; text-align:center; line-height: 0.25">4🤭4</h1><p style="font-size: 4vw; text-align: center; padding-left: 2vw; padding-right: 2vw;"><span>Could not find</span> <span style="color: grey;">/</span></p></main>  <script src="/instant/client/bundle.js"></script>

@aral Let me know your thoughts. No worries if this stays on hold, but solving the SSL certificates issue would be at least necessary in order to merge IMO.

@alfonsomunozpomer
Copy link
Contributor Author

Closing in favour of #28 (I messed up the branch history).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant