Reddit Saved Gallery is a SaaS web application allowing users to import, query, and manage their saved posts and media on Reddit.
This repository contains all the necessary services to host Reddit Saved Gallery. For quick start instructions to run Reddit Saved Gallery locally, see Getting started. For full deployment instructions to a production server, see Deploying to production.
For more details about the application, including some background on its architecture and design, check out Reddit Saved Gallery: A Scalable Web Application on LinkedIn.
The best way to run Reddit Saved Gallery locally is by using Docker. You must have Docker and Docker Compose installed on your machine.
You will need to create your own app on Reddit in order to obtain an OAuth2 client ID
and client secret
.
Go to https://www.reddit.com/prefs/apps and create an app. You may name it whatever you like. Make sure you have selected web app
, and have set the redirect uri
field to http://localhost:3000/callback
.
Take note of your client ID
and client secret
, as these will be needed later.
Download the compose.yaml file, either by copying its contents directly from this repository, or by running:
curl https://raw.githubusercontent.com/Ke126/reddit-saved-gallery/refs/heads/main/compose.yaml > ./compose.yaml
Create an .env
file in the same directory as your compose.yaml
file with the following required environment variables:
Key | Description |
---|---|
OAUTH_CLIENT_ID | The client ID for your Reddit app |
OAUTH_CLIENT_SECRET | The client secret for your Reddit app |
MONGO_INITDB_ROOT_USERNAME | The username used for MongoDB |
MONGO_INITDB_ROOT_PASSWORD | The password used for MongoDB |
With everything set up, running Reddit Saved Gallery locally is as simple as running:
docker compose up -d
Visit http://localhost:3000 to use Reddit Saved Gallery in your browser!
To stop the application, simply run:
docker compose down
[!NOTE] These instructions are only applicable for full deployment of Reddit Saved Gallery to a production server. For running the application locally, see Getting started.
This repository already comes configured with various GitHub Actions workflows to automate testing, building, and deploying Reddit Saved Gallery to a production server. Only a few things need to be configured to automate this process and remotely run the application on the production server.
Ensure that you own a valid domain name, and that there exists a DNS A type record pointing to the ip address of your production server.
Follow the instructions in Create a Reddit app and create a Reddit app. However, set the redirect uri
to https://${YOUR_DOMAIN_HERE}/callback
(substituting in your domain name), rather than a localhost address.
Take note of your client ID
and client secret
, as these will be needed later.
Docker and Docker Compose must be installed on the production server.
Because the GitHub Actions deployment pipeline will SSH into the production server to run Docker Compose up, a Linux user must be configured with SSH key-based authentication, and with permissions to run Docker commands without requiring the sudo
prefix. See https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user for more details.
Take note of your SSH private key and the output of running ssh-keyscan -H ${hostname}
(replacing hostname with the ip address of your production server), as these will be needed later.
The deployment pipeline requires creating a few GitHub repository secrets in order to securely access the production server:
Key | Description |
---|---|
SSH_PRIVATE_KEY | The private key used to SSH to the production server |
SSH_KNOWN_HOSTS | The output of running ssh-keyscan from above |
USER | The username of the Linux user on the production server |
HOSTNAME | The ip address of the production server |
ENV_FILE | The contents of an environment file, see below |
ENV_FILE
should be a single GitHub secret containing five environment variables, including the four required environment variables described above in Set up Docker Compose, as well as one additional DOMAIN
environment variable:
Key | Description |
---|---|
DOMAIN | The domain name of the production server |
With everything set up, deployment is as simple as running the continuous deployment (CD) workflow defined in deploy.yaml, which can be invoked manually from GitHub's website. Make sure the continuous integration (CI) workflow ci.yaml has been run beforehand, as this workflow creates and pushes multi-platform Docker images to the GitHub Container Registry (ghcr.io) that are required by the CD workflow. The CI workflow can also be invoked manually from GitHub's website if needed.
Development of Reddit Saved Gallery is still ongoing. The following are some of the enhancements planned for future updates: