Skip to content

Commit 91a8840

Browse files
committed
Initial Commit
0 parents  commit 91a8840

File tree

191 files changed

+36022
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

191 files changed

+36022
-0
lines changed

.dockerignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.env
2+
.yarn/
3+
.next/
4+
.github/
5+
dist/
6+
assets/
7+
node_modules/

.github/workflows/docker-build.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Build and Push Docker image
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
docker:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Check out the repo
13+
uses: actions/checkout@v2
14+
15+
- name: Set up Docker Buildx
16+
uses: docker/setup-buildx-action@v1
17+
18+
- name: Log in to Docker Hub
19+
uses: docker/login-action@v1
20+
with:
21+
username: ${{ secrets.DOCKER_USERNAME }}
22+
password: ${{ secrets.DOCKER_PASSWORD }}
23+
24+
- name: Build and push
25+
uses: docker/build-push-action@v2
26+
with:
27+
context: .
28+
file: ./Dockerfile
29+
push: true
30+
tags: driaug/plunk:latest
31+
platforms: linux/amd64,linux/arm64

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
node_modules
2+
dist
3+
.idea
4+
.vscode
5+
*.log
6+
.env
7+
.tscache
8+
.next
9+
.out
10+
build
11+
.DS_Store
12+
.yarn/install-state.gz

.yarnrc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nodeLinker: node-modules

Dockerfile

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Base Stage
2+
FROM node:alpine AS base
3+
4+
WORKDIR /app
5+
6+
COPY . .
7+
8+
ARG NEXT_PUBLIC_API_URI=PLUNK_API_URI
9+
10+
RUN yarn install --network-timeout 1000000
11+
RUN yarn build:shared
12+
RUN yarn workspace @plunk/api build
13+
RUN yarn workspace @plunk/dashboard build
14+
15+
# Final Stage
16+
FROM node:alpine
17+
18+
WORKDIR /app
19+
20+
RUN apk add --no-cache bash nginx
21+
22+
COPY --from=base /app/packages/api/dist /app/packages/api/
23+
COPY --from=base /app/packages/dashboard/.next /app/packages/dashboard/.next
24+
COPY --from=base /app/packages/dashboard/public /app/packages/dashboard/public
25+
COPY --from=base /app/node_modules /app/node_modules
26+
COPY --from=base /app/packages/shared /app/packages/shared
27+
COPY --from=base /app/prisma /app/prisma
28+
COPY deployment/nginx.conf /etc/nginx/nginx.conf
29+
COPY deployment/entry.sh deployment/replace-variables.sh /app/
30+
31+
RUN chmod +x /app/entry.sh /app/replace-variables.sh
32+
33+
EXPOSE 3000
34+
35+
CMD ["sh", "/app/entry.sh"]

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
![card.png](/assets/card.png)
2+
3+
<h1 align="center">Plunk</h1>
4+
5+
<p align="center">
6+
The Open-Source Email Platform for AWS
7+
</p>
8+
9+
<p align="center">
10+
<img src="https://img.shields.io/github/contributors/useplunk/plunk"/>
11+
<img src="https://img.shields.io/github/actions/workflow/status/driaug/plunk-whitelabel/docker-build.yml"/>
12+
<img src="https://img.shields.io/docker/pulls/driaug/plunk"/>
13+
</p>
14+
15+
## Introduction
16+
Plunk is an open-source email platform built on top of AWS SES. It allows you to easily send emails from your applications.
17+
It can be considered as a self-hosted alternative to services like [SendGrid](https://sendgrid.com/), [Resend](https://resend.com) or [Mailgun](https://www.mailgun.com/).
18+
19+
## Features
20+
- **Transactional Emails**: Send emails straight from your API
21+
- **Automations**: Create automations based on user actions
22+
- **Broadcasts**: Send newsletters and product updates to big audiences
23+
24+
## Self-hosting Plunk
25+
The easiest way to self-host Plunk is by using the `driaug/plunk` Docker image.
26+
You can pull the latest image from [Docker Hub](https://hub.docker.com/r/driaug/plunk/).
27+
28+
A complete guide on how to deploy Plunk can be found in the [documentation](https://docs.useplunk.com/getting-started/self-hosting).

assets/card.png

24.6 KB
Loading

biome.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
3+
"organizeImports": {
4+
"enabled": true
5+
},
6+
"linter": {
7+
"enabled": true,
8+
"rules": {
9+
"recommended": true,
10+
"a11y": {
11+
"useKeyWithClickEvents": "off",
12+
"noSvgWithoutTitle": "off",
13+
"useButtonType": "off"
14+
},
15+
"complexity": {
16+
"noForEach": "off",
17+
"noStaticOnlyClass": "off"
18+
}
19+
}
20+
}
21+
}

deployment/entry.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/sh
2+
3+
echo "Starting Prisma migrations..."
4+
npx prisma migrate deploy
5+
echo "Prisma migrations completed."
6+
7+
sh replace-variables.sh &&
8+
9+
nginx &
10+
11+
echo "Starting the API server..."
12+
node packages/api/app.js &
13+
echo "API server started in the background."
14+
15+
echo "Starting the Dashboard..."
16+
cd packages/dashboard
17+
npx next start -p 5000 -H 0.0.0.0
18+
echo "Dashboard started."

deployment/nginx.conf

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
events {
2+
worker_connections 1024;
3+
}
4+
5+
http {
6+
server {
7+
listen 3000;
8+
9+
location /api/ {
10+
proxy_pass http://plunk:4000/;
11+
proxy_set_header Host $host;
12+
proxy_set_header X-Real-IP $remote_addr;
13+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
14+
proxy_set_header X-Forwarded-Proto $scheme;
15+
}
16+
17+
location / {
18+
proxy_pass http://plunk:5000;
19+
proxy_set_header Host $host;
20+
proxy_set_header X-Real-IP $remote_addr;
21+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
22+
proxy_set_header X-Forwarded-Proto $scheme;
23+
}
24+
}
25+
}

deployment/replace-variables.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
echo "Baking Environment Variables..."
4+
5+
if [ -z "${API_URI}" ]; then
6+
echo "API_URI is not set. Exiting..."
7+
exit 1
8+
fi
9+
10+
# Find and replace baked values with real values for the API_URI
11+
find /app/packages/dashboard/public /app/packages/dashboard/.next -type f -name "*.js" |
12+
while read file; do
13+
sed -i "s|PLUNK_API_URI|${API_URI}|g" "$file"
14+
done
15+
16+
echo "Environment Variables Baked."

lerna.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"npmClient": "yarn",
3+
"packages": [
4+
"packages/*"
5+
],
6+
"version": "1.0.0"
7+
}

package.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"name": "plunk",
3+
"version": "1.0.0",
4+
"private": true,
5+
"license": "MIT",
6+
"workspaces": {
7+
"packages": [
8+
"packages/*"
9+
]
10+
},
11+
"engines": {
12+
"npm": ">=6.14.x",
13+
"yarn": "1.22.x",
14+
"node": ">=18.x"
15+
},
16+
"devDependencies": {
17+
"@biomejs/biome": "^1.8.3",
18+
"lerna": "^8.1.6",
19+
"prisma": "^5.17.0",
20+
"rimraf": "^5.0.9"
21+
},
22+
"dependencies": {
23+
"@prisma/client": "^5.17.0"
24+
},
25+
"scripts": {
26+
"dev:api": "yarn workspace @plunk/api dev",
27+
"dev:dashboard": "yarn workspace @plunk/dashboard dev",
28+
"dev:shared": "yarn workspace @plunk/shared dev",
29+
"build:api": "yarn build:shared && yarn workspace @plunk/api build",
30+
"build:dashboard": "yarn build:shared && yarn workspace @plunk/dashboard build",
31+
"build:shared": "yarn generate && yarn workspace @plunk/shared build",
32+
"clean": "rimraf node_modules yarn.lock && yarn add lerna -DW && lerna run clean",
33+
"preinstall": "node tools/preinstall.js",
34+
"migrate": "prisma migrate dev",
35+
"migrate:deploy": "prisma migrate deploy",
36+
"generate": "prisma generate"
37+
}
38+
}

packages/api/.env.example

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# ENV
2+
JWT_SECRET=mysupersecretJWTsecret
3+
REDIS_URL=redis://127.0.0.1:6379
4+
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/postgres
5+
NODE_ENV=development
6+
7+
# AWS
8+
AWS_REGION=
9+
AWS_ACCESS_KEY_ID=
10+
AWS_SECRET_ACCESS_KEY=
11+
AWS_SES_CONFIGURATION_SET=
12+
AWS_CLOUDFRONT_DISTRIBUTION_ID=
13+
AWS_S3_BUCKET=

packages/api/package.json

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"name": "@plunk/api",
3+
"version": "1.0.0",
4+
"main": "dist/index.js",
5+
"private": true,
6+
"scripts": {
7+
"dev": "cross-env NODE_ENV=development ts-node-dev --transpile-only --exit-child src/app.ts",
8+
"start": "node ./dist/app.js",
9+
"build": "tsc",
10+
"clean": "rimraf node_modules dist .turbo"
11+
},
12+
"devDependencies": {
13+
"@types/bcrypt": "^5.0.2",
14+
"@types/compression": "^1.7.5",
15+
"@types/cookie-parser": "^1.4.7",
16+
"@types/cors": "^2.8.17",
17+
"@types/express": "^4.17.21",
18+
"@types/ioredis": "^5.0.0",
19+
"@types/jsonwebtoken": "^9.0.6",
20+
"@types/mjml": "^4.7.4",
21+
"@types/morgan": "^1.9.9",
22+
"@types/node-cron": "^3.0.11",
23+
"@types/signale": "^1.4.7",
24+
"cross-env": "^7.0.3",
25+
"prisma": "^5.17.0",
26+
"ts-node-dev": "^2.0.0",
27+
"typescript": "^5.5.3"
28+
},
29+
"dependencies": {
30+
"@aws-sdk/client-cloudfront": "^3.616.0",
31+
"@aws-sdk/client-ses": "^3.616.0",
32+
"@overnightjs/core": "^1.7.6",
33+
"@plunk/shared": "^1.0.0",
34+
"@prisma/client": "^5.17.0",
35+
"bcrypt": "^5.1.1",
36+
"body-parser": "^1.20.2",
37+
"compression": "^1.7.4",
38+
"cookie-parser": "^1.4.6",
39+
"cors": "^2.8.5",
40+
"dotenv": "^16.4.5",
41+
"express": "^4.19.2",
42+
"express-async-errors": "^3.1.1",
43+
"helmet": "^7.1.0",
44+
"ioredis": "^5.4.1",
45+
"jsonwebtoken": "^9.0.2",
46+
"mjml": "^4.15.3",
47+
"morgan": "^1.10.0",
48+
"node-cron": "^3.0.3",
49+
"signale": "^1.4.0"
50+
}
51+
}

0 commit comments

Comments
 (0)