-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from sheodox/self-hosting
Self hosting support
- Loading branch information
Showing
16 changed files
with
658 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.DS_Store | ||
node_modules | ||
/build | ||
/.svelte-kit | ||
/package | ||
.env | ||
.env.* | ||
!.env.example | ||
vite.config.js.timestamp-* | ||
vite.config.ts.timestamp-* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# instance used if someone has never used the site | ||
ALEXANDRITE_DEFAULT_INSTANCE=lemmy.world | ||
|
||
# if the login page should include the lemmy explanation | ||
ALEXANDRITE_WELCOME_LEMMY_HELP=true | ||
# | ||
# if the login page should include links to find an instance | ||
ALEXANDRITE_WELCOME_INSTANCE_HELP=true | ||
|
||
# If blank, users can login to any instance. If set, users can only login to this instance. | ||
# If this is set, the Lemmy version warning is also hidden, as it's assumed the instance | ||
# hosting Alexandrite has a compatible version. Note: this should be your main Lemmy host name, | ||
# not the host name of Alexandrite (e.g. lemmy.example.com not alexandrite.example.com) | ||
ALEXANDRITE_FORCE_INSTANCE= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: Docker Image Publish | ||
|
||
on: | ||
push: | ||
branches: ['main'] | ||
|
||
jobs: | ||
build_and_publish: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Build and push the image | ||
run: | | ||
docker login --username sheodox --password ${{ secrets.GH_PAT }} ghcr.io | ||
docker build . --tag ghcr.io/sheodox/alexandrite:latest | ||
docker push ghcr.io/sheodox/alexandrite:latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# followed this guide, adapted to sveltekit | ||
# https://snyk.io/blog/10-best-practices-to-containerize-nodejs-web-applications-with-docker/ | ||
FROM node:18.17.0-bookworm-slim as build | ||
RUN apt-get update && apt-get install -y --no-install-recommends dumb-init | ||
ENV ALEXANDRITE_RUN_IN_NODE=true | ||
|
||
WORKDIR /usr/src/app | ||
|
||
COPY package*.json ./ | ||
|
||
RUN npm ci | ||
ENV NODE_ENV production | ||
COPY . /usr/src/app | ||
RUN npm run build | ||
|
||
FROM node:18.17.0-bookworm-slim | ||
COPY --from=build /usr/bin/dumb-init /usr/bin/dumb-init | ||
WORKDIR /usr/src/app | ||
|
||
COPY package*.json ./ | ||
RUN npm ci --only=production | ||
USER node | ||
COPY --chown=node:node --from=build /usr/src/app/build /usr/src/app/build | ||
|
||
CMD ["dumb-init", "node", "build"] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,70 @@ | ||
# Alexandrite (formerly sx-lemmy) | ||
<div align="center"> | ||
<img src="static/logo.svg?sanitize=true" width="160" height="160" alt="logo"> | ||
<h1>Alexandrite</h1> | ||
</div> | ||
|
||
Alexandrite is an alternative web UI for Lemmy with a focus on app-quality easy browsing. | ||
[Alexandrite](https://alexandrite.app/) is a beautiful desktop-first alternative web UI for [Lemmy](https://join-lemmy.org/), a social link aggregator and discussion forum for the [Fediverse](https://simple.wikipedia.org/wiki/Fediverse). | ||
|
||
This is still a work in progress, so not all features are supported yet. | ||
Alexandrite comes packed full of features! | ||
|
||
![screenshot](docs/example.png) | ||
- Infinite scrolling | ||
- View posts in an overlay or side-by-side with the feed in a second column so you don't lose your spot | ||
- Customizable theme hue | ||
- Powerful account switcher, login to different accounts across the same or different instances simultaneously in different browser tabs | ||
- Most mod tools | ||
- Supports most markdown formatting | ||
|
||
## Support Development | ||
|
||
A lot of time and effort has gone into Alexandrite. If you would like to support development you can [Buy Me a Coffee](https://www.buymeacoffee.com/sheodox). I really appreciate all the support! | ||
|
||
## Self Hosting | ||
|
||
Alexandrite supports self hosting with a few configuration options. Check out the [example environment variable config](.env.example) to see what options can be passed as arguments to `docker`. | ||
|
||
### Using Docker | ||
|
||
The easiest way to host Alexandrite would be using a prebuilt image, or building from source using the provided Dockerfile. | ||
|
||
The app listens inside the container to port `3000` and doesn't provide HTTPs, you'll probably want to configure your own reverse proxy between the internet and Alexandrite to provide HTTPS. | ||
|
||
Run using: | ||
|
||
```bash | ||
docker run -p 3000:3000 ghcr.io/sheodox/alexandrite:latest | ||
``` | ||
|
||
Or, with some customized options: | ||
|
||
```bash | ||
docker run -p 3000:3000 --env 'ALEXANDRITE_DEFAULT_INSTANCE=programming.dev' ghcr.io/sheodox/alexandrite:latest | ||
``` | ||
|
||
Or as part of a docker compose setup: | ||
|
||
```yaml | ||
version: '3.7' | ||
services: | ||
# ... | ||
alexandrite: | ||
image: ghcr.io/sheodox/alexandrite:latest | ||
ports: | ||
- 3000:3000 | ||
environment: | ||
# example config only allowing logins to example.com | ||
# with no links to Lemmy docs, or an instance list | ||
ALEXANDRITE_DEFAULT_INSTANCE: example.com | ||
ALEXANDRITE_WELCOME_LEMMY_HELP: false | ||
ALEXANDRITE_WELCOME_INSTANCE_HELP: false | ||
ALEXANDRITE_FORCE_INSTANCE: example.com | ||
``` | ||
### Serverless | ||
You can alternatively host Alexandrite on the serverless platforms supported by [Sveltekit's `adapter-auto`](https://kit.svelte.dev/docs/adapter-auto). It should be pretty low on resource usage, as SSR is disabled. | ||
|
||
## Contributing | ||
|
||
PRs are welcome! The app is written in [Svelte](https://svelte.dev/) using [Sveltekit](https://kit.svelte.dev/), running with SSR disabled, as all interactions with Lemmy are done client-side using [`lemmy-js-client`](https://github.com/LemmyNet/lemmy-js-client). | ||
|
||
One small warning, I really enjoy figuring out how things work and doing things myself for the learning experience instead of using third party libraries. The UI is written using my own very sparsely documented [UI/component library](https://github.com/sheodox/sheodox-ui) that is a mix of pre-built components and Bootstrap/Tailwind-like utility classes. The [virtualized list renderer](src/lib/VirtualFeed.svelte) is also custom built. |
Oops, something went wrong.