Skip to content

Commit

Permalink
Merge pull request #40 from ItzNotABug/dockerize-ghosler
Browse files Browse the repository at this point in the history
Dockerize `Ghosler`
  • Loading branch information
ItzNotABug authored Mar 26, 2024
2 parents b91ed84 + e43f830 commit 703a2a5
Show file tree
Hide file tree
Showing 10 changed files with 277 additions and 170 deletions.
30 changes: 30 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# build files
.idea/
.vscode/
node_modules/

# local development files
.logs/
*.log
files/

# spam
.DS_Store

# git
.git
.gitignore

# markdown
LICENSE.md
README.md

# custom template
custom-template.ejs

# tailwind files
tailwind.config.js
public/styles/tailwind.css

# installer
docker-install.sh
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
.idea
*.iml

# vs code
.vscode

# logs
.logs
*.log
.DS_Store

# project specific data files folder
files
Expand All @@ -13,7 +17,7 @@ files
node_modules

# debug configuration
config.debug.json
configuration/config.debug.json

# custom template used for tests
custom-template.ejs
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Build stage
FROM node:18-alpine

# Label
LABEL author="@ItzNotABug"

# Set working directory
WORKDIR /usr/src/app

# Copy the rest of your application code
COPY . .

# Install PM2 globally
RUN npm install pm2 -g

# Install dependencies
RUN npm ci --omit-dev

# Start your app
CMD ["pm2-runtime", "start", "app.js", "--name", "ghosler-app"]
98 changes: 37 additions & 61 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ with the capability to use **multiple** email accounts.

---

### Table of Contents

- [Screenshots](#screenshots)
- [Key Features](#key-features)
- [Running Ghosler](#running-ghosler)
- [Setup Instructions](#setup-instructions)
- [Testing Configurations](#testing-configurations)
- [Using Custom Templates](#custom-template)

---

### Screenshots

- **Newsletter**
Expand All @@ -20,44 +31,6 @@ with the capability to use **multiple** email accounts.
</tr>
</table>

- **Dashboard**

<details>
<summary>
Mobile View
</summary>
<table>
<tr>
<td><img style="border-radius: 2px;" src="https://github.com/ItzNotABug/ghosler/assets/20625965/225d6929-68f1-474d-a694-257197c41424" alt="Ghosler - Login" /></td>
<td><img style="border-radius: 2px;" src="https://github.com/ItzNotABug/ghosler/assets/20625965/39571ef5-d1f0-4145-b205-37963e28fda7" alt="Ghosler - Home" /></td>
<td><img style="border-radius: 2px;" src="https://github.com/ItzNotABug/ghosler/assets/20625965/dc72d8c0-7943-44ce-8ffa-56fbac51c703" alt="Ghosler - Analytics" /></td>
</tr>
<tr>
<td><img style="border-radius: 2px;" src="https://github.com/ItzNotABug/ghosler/assets/20625965/e06ac7aa-9e6b-4bd4-8227-d8ea76f58f64" alt="Ghosler - Analytics - Details" /></td>
<td><img style="border-radius: 2px;" src="https://github.com/ItzNotABug/ghosler/assets/20625965/3c75cb17-dc0a-4662-aef3-b696d70cca65" alt="Ghosler - Settings" /></td>
<td><img style="border-radius: 2px;" src="https://github.com/ItzNotABug/ghosler/assets/20625965/55e45089-fac1-40ef-b818-a440465d7c9d" alt="Ghosler - Logs" /></td>
</tr>
</table>
</details>

<details>
<summary>
Desktop View
</summary>
<table>
<tr>
<td><img src="https://github.com/ItzNotABug/ghosler/assets/20625965/39e5a0b1-2053-4a5f-8efa-96c45f3e3369" alt="Ghosler - Login" /></td>
<td><img src="https://github.com/ItzNotABug/ghosler/assets/20625965/3f18b7a5-8fcd-4bed-821f-963237052d4f" alt="Ghosler - Home" /></td>
<td><img src="https://github.com/ItzNotABug/ghosler/assets/20625965/60e9c9ad-6ae6-46c3-8708-0b9d91a960d9" alt="Ghosler - Analytics" /></td>
</tr>
<tr>
<td><img src="https://github.com/ItzNotABug/ghosler/assets/20625965/eadacf4f-e9dd-45e3-b8f1-4aa18be4a41c" alt="Ghosler - Analytics - Details" /></td>
<td><img src="https://github.com/ItzNotABug/ghosler/assets/20625965/0061ac2b-7aa5-48ca-8de4-9383c7a5d81e" alt="Ghosler - Settings" /></td>
<td><img src="https://github.com/ItzNotABug/ghosler/assets/20625965/a6fa0f5e-8fd4-4fc4-ac01-e27b756ba749" alt="Ghosler - Logs" /></td>
</tr>
</table>
</details>

### Key Features

- **Support for Multiple Email Accounts**: Distribute newsletters through various email accounts, dividing member counts
Expand All @@ -71,30 +44,39 @@ with the capability to use **multiple** email accounts.
your members are interacting with added links.
- **Newsletter Post Feedback**: Gain insights into reader preferences with detailed feedback on each post, including
likes, dislikes, and overall sentiment.
- **Ghost Native Widgets**: Ghosler supports major Ghost widgets (cards) for your newsletter, out of the box.\
See: [#17](https://github.com/ItzNotABug/ghosler/pull/17) for more info.
- **Custom Email Subjects**: Ghosler allows using customised email subject for your newsletter.\
See: [#28](https://github.com/ItzNotABug/ghosler/pull/28) for more info.
- **Ghost Native Widgets**: Ghosler supports major Ghost widgets (cards) for your newsletter, out of the box.
- **Custom Email Subjects**: Ghosler allows using customised email subject for your newsletter.
- **Multiple Newsletters**: Ghosler supports managing multiple newsletters! Publish a post & select the newsletter to
associate with & instantly send emails.\
See: [#32](https://github.com/ItzNotABug/ghosler/pull/32) for more info.
associate with & instantly send emails.
- **Docker Support**: Ghosler also supports a straight forward Docker container.

### Running Ghosler

#### 1. Installation with `NPM`

Pre-requisites: `Node 18^` & `pm2` installed.

1. Install the `CLI` -

```npm
npm install -g ghosler-cli
```
```npm
npm install -g ghosler-cli
```

2. Go to the directory you want to install `Ghosler`, make sure its empty & run below command -

```shell
ghosler install
```
Now navigate to main site & edit required settings after completing the Setup instructions below.
```shell
ghosler install
```

#### 2. Installation with `Docker`

Execute this script to install or update `Ghosler` via `Docker` -

```bash
curl -sSL https://raw.githubusercontent.com/ItzNotABug/ghosler/master/docker-install.sh | bash
```

Now navigate to main site & edit required settings after completing the Setup instructions below.

### Setup Instructions

Expand Down Expand Up @@ -123,7 +105,7 @@ Now as soon as you publish your Post, it will be sent to your Subscribers who ha
### Testing Configurations

Ghosler defaults to using a debug configuration file, `config.debug.json`, if it exists. The structure of this file is
identical to that in [config.production.json](./config.production.json) file.
identical to that in [config.production.json](./configuration/config.production.json) file.

**Local Builds:**
Make sure to execute -
Expand All @@ -148,6 +130,9 @@ You can use below for combining the above commands -
npm run cleanstart
```

**Note**: For testing the Docker container over a publicly accessible URL, I used `Cloudflare Tunnel` as it doesn't have
a startup page like `ngrok` or the `VSCode`'s dev tunnel and works good for testing the Ghost Webhooks.

### Custom Template

If you want to customize the newsletter template even more, follow the steps -
Expand All @@ -157,15 +142,6 @@ If you want to customize the newsletter template even more, follow the steps -
3. That's it! Ghosler will use the new template for preview & sending newsletter.
4. Rename the file to anything if you don't want to use the custom template.

#### Looking for a dockerized solution?

See this [issue](https://github.com/ItzNotABug/ghosler/issues/31), and
this [comment](https://github.com/ItzNotABug/ghosler/issues/31#issuecomment-1987150626) which mentions an article
written by **[@viriatusX](https://github.com/viriatusX)** for containerizing Ghosler.

*Please note that due to my limited experience with Docker, I haven't tested this yet. For any issues, feel free to add
comments on the above linked issue.*

---

#### And don't forget to `` the project!
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@
"track_links": true
},
"mail": []
}
}
38 changes: 38 additions & 0 deletions docker-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash

# Define color codes
NC='\033[0m'
RED='\033[0;31m'
GREEN='\033[0;32m'
BOLD_GREEN='\033[1;32m'

# Set default values
DEFAULT_PORT=2369
DEFAULT_CONTAINER_NAME="ghosler"

echo ""
echo -e "${BOLD_GREEN}Note: If you are UPDATING, use the same PORT & CONTAINER NAME!${NC}"
echo ""

# Prompt for port number with default
echo -e "${GREEN}Provide a port for Ghosler [Default: $DEFAULT_PORT]${NC} : "
read -r PORT
PORT=${PORT:-$DEFAULT_PORT}

# Prompt for container name with default
echo -e "${GREEN}Provide a name for Ghosler Container [Default: $DEFAULT_CONTAINER_NAME]${NC} : "
read -r CONTAINER_NAME
CONTAINER_NAME=${CONTAINER_NAME:-$DEFAULT_CONTAINER_NAME}

echo -e "${GREEN}Starting Ghosler Docker installation...${NC}"
echo ""

# Use the variables in the docker run command
if ! docker run --rm --name "$CONTAINER_NAME" -d -p "$PORT":2369 -v "${CONTAINER_NAME}"-logs:/usr/src/app/.logs -v "${CONTAINER_NAME}"-analytics:/usr/src/app/files -v "${CONTAINER_NAME}"-configuration:/usr/src/app/configuration itznotabug/ghosler:0.94; then
echo ""
echo -e "${RED}Error: Failed to start Ghosler. Please check the Docker logs for more details.${NC}" >&2
exit 1
fi

echo ""
echo -e "${GREEN}Ghosler has been successfully installed and started.${NC}"
Loading

0 comments on commit 703a2a5

Please sign in to comment.