Skip to content

Conversation

@adamoutler
Copy link

@adamoutler adamoutler commented Apr 5, 2025

This PR introduces the capability to build the Joplin web client and deploy it both as a static site via GitHub Pages and as a Docker container image to the GitHub Container Registry (GHCR).

Key Changes:

  • GitHub Actions Workflow (.github/workflows/deploy-github-pages.yml):
    • Fetch the Joplin source code from laurent22/joplin.
    • Builds the Joplin web app (packages/app-mobile/yarn web).
    • Deploys the static build artifacts to GitHub Pages.
    • Builds a Docker image using the new Dockerfile.
    • Pushes the Docker image to ghcr.io/${{ github.repository }} with latest and date-based tags, supporting linux/amd64 and linux/arm64.
    • Added packages: write permissions for GHCR push.
  • Dockerfile:
    • New file defining a multi-stage build process.
    • Uses nginx:alpine as the final stage.
    • Copies the built static web app files (./pages/) into the Nginx web root.
    • Copies the coop-coep.conf Nginx configuration file.
  • coop-coep.conf:
    • New Nginx configuration snippet.
    • Adds Cross-Origin-Opener-Policy: same-origin and Cross-Origin-Embedder-Policy: require-corp headers. These are necessary to enable crossOriginIsolated=true context, required for feature SharedArrayBuffer.
  • README.md:
    • Updated with a new section: "Running Joplin WebApp with Docker".
    • Provides detailed instructions on pulling the image (Note: Users should pull from ghcr.io/${{ github.repository }}:latest), running the container, and crucial configuration steps.
    • Emphasizes the requirement for HTTPS via a reverse proxy for both the web app and the Joplin Server.
    • Includes an example Nginx configuration for setting required CORS headers on the Joplin Server's reverse proxy, which is essential for communication between the web app and the server API.
    • Mentions the potential need to configure the Joplin Server API URL via environment variables in the Docker container.

Motivation:

The primary driver for this change is to enhance user privacy and control. By providing an official, easy-to-use Docker container for the Joplin web app, users are empowered to self-host the entire Joplin experience – both the server and the web client – within their own trusted website. This significantly reduces reliance on external services for accessing notes via a web browser and ensures that user data primarily transits systems they manage directly, offering a more private alternative to using centrally hosted web applications.

Usage:

Refer to the updated README.md for detailed instructions on pulling and running the Docker image, including necessary reverse proxy and CORS configuration on the Joplin Server side.

Testing:

For testing purposes, I've deployed the web-app here https://github.com/adamoutler/web-app/pkgs/container/web-app and it can be tested using

docker pull ghcr.io/adamoutler/web-app:latest
docker run -it -p8088:80 ghcr.io/adamoutler/web-app:latest

@personalizedrefrigerator
Copy link
Collaborator

including necessary reverse proxy and CORS configuration on the Joplin Server side.

This should also be handled by Joplin's service worker — it might not be necessary here.

@adamoutler
Copy link
Author

It was needed with Nginx Proxy Manager running under a docker container. It was the first thing required as the service worker would not run without that. There was no error handling in app and troubleshooting was base on errors I had to look up. So I placed instructions in readme.

@adamoutler
Copy link
Author

Oh. I think I understand the confusion. Joplin Server's CORS for the web-app are hard coded. In order to run in a docker, those values need to be overridden.

@adamoutler adamoutler mentioned this pull request Apr 9, 2025
@personalizedrefrigerator
Copy link
Collaborator

For reference, I'm linking to laurent22/joplin#12563, which adds a docker deployment step to the main Joplin repository.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants