Skip to content

Commit b401599

Browse files
authored
Added Support for Node (#17)
1 parent cd77c85 commit b401599

17 files changed

Lines changed: 718 additions & 578 deletions

File tree

.github/workflows/docker.yaml

Lines changed: 60 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build and Push Docker Image
1+
name: Build and Push Docker Images
22

33
on:
44
push:
@@ -7,8 +7,8 @@ on:
77
workflow_dispatch:
88

99
jobs:
10-
build-and-push:
11-
name: Build and Push Docker Image
10+
build-and-push-bun:
11+
name: Build and Push Bun Image
1212
runs-on: ubuntu-latest
1313
permissions:
1414
contents: write
@@ -27,8 +27,8 @@ jobs:
2727
username: ${{ github.repository_owner }}
2828
password: ${{ github.token }}
2929

30-
- name: Extract Docker metadata
31-
id: meta
30+
- name: Extract Docker metadata (Bun)
31+
id: meta-bun
3232
uses: docker/metadata-action@v5
3333
with:
3434
images: ghcr.io/dcodesdev/letterspace
@@ -39,16 +39,67 @@ jobs:
3939
type=semver,pattern={{major}}
4040
type=raw,value=latest,enable=${{ !contains(github.ref, '-') }}
4141
42-
- name: Build and push Docker image
42+
- name: Build and push Docker image (Bun)
4343
uses: docker/build-push-action@v6
4444
with:
4545
context: .
4646
push: true
47-
tags: ${{ steps.meta.outputs.tags }}
47+
tags: ${{ steps.meta-bun.outputs.tags }}
4848
# platforms: linux/amd64,linux/arm64
49-
cache-from: type=gha
50-
cache-to: type=gha,mode=max
49+
cache-from: type=gha,scope=bun
50+
cache-to: type=gha,mode=max,scope=bun
5151

52+
build-and-push-node:
53+
name: Build and Push Node Image
54+
runs-on: ubuntu-latest
55+
permissions:
56+
contents: write
57+
packages: write
58+
59+
steps:
60+
- uses: actions/checkout@v4
61+
62+
- name: Set up Docker Buildx
63+
uses: docker/setup-buildx-action@v3
64+
65+
- name: Login to GitHub Container Registry
66+
uses: docker/login-action@v3
67+
with:
68+
registry: ghcr.io
69+
username: ${{ github.repository_owner }}
70+
password: ${{ github.token }}
71+
72+
- name: Extract Docker metadata (Node)
73+
id: meta-node
74+
uses: docker/metadata-action@v5
75+
with:
76+
images: ghcr.io/dcodesdev/letterspace
77+
tags: |
78+
type=ref,event=tag
79+
type=semver,pattern={{version}}-node
80+
type=semver,pattern={{major}}.{{minor}}-node
81+
type=semver,pattern={{major}}-node
82+
type=raw,value=latest-node,enable=${{ !contains(github.ref, '-') }}
83+
84+
- name: Build and push Docker image (Node)
85+
uses: docker/build-push-action@v6
86+
with:
87+
context: .
88+
file: ./Dockerfile.node
89+
push: true
90+
tags: ${{ steps.meta-node.outputs.tags }}
91+
# platforms: linux/amd64,linux/arm64
92+
cache-from: type=gha,scope=node
93+
cache-to: type=gha,mode=max,scope=node
94+
95+
release:
96+
name: Create GitHub Release
97+
runs-on: ubuntu-latest
98+
permissions:
99+
contents: write
100+
needs: [build-and-push-bun, build-and-push-node]
101+
steps:
102+
- uses: actions/checkout@v4
52103
- name: Release
53104
uses: softprops/action-gh-release@v2
54105
with:

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ RUN cd apps/backend && pnpm run generate
2020

2121
ENV NODE_ENV=production
2222

23-
RUN cd apps/web && bunx vite build
23+
RUN cd apps/web && bun run build
2424

2525
EXPOSE 5000
2626
WORKDIR /app/apps/backend
27-
ENTRYPOINT ["./entrypoint.sh"]
27+
ENTRYPOINT ["./entrypoint.sh", "--bun"]

Dockerfile.node

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
FROM node:22-slim
2+
3+
RUN apt-get update -y && apt-get install -y openssl
4+
RUN npm install -g pnpm@10.10.0
5+
6+
WORKDIR /app
7+
8+
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml turbo.json .npmrc ./
9+
COPY apps/web/package.json ./apps/web/
10+
COPY apps/backend/package.json ./apps/backend/
11+
COPY packages/eslint-config/package.json ./packages/eslint-config/
12+
COPY packages/typescript-config/package.json ./packages/typescript-config/
13+
COPY packages/ui/package.json ./packages/ui/
14+
15+
RUN pnpm install --frozen-lockfile
16+
17+
COPY . .
18+
19+
WORKDIR /app/apps/backend
20+
RUN pnpm run generate
21+
RUN pnpm run build
22+
23+
ENV NODE_ENV=production
24+
25+
WORKDIR /app/apps/web
26+
RUN pnpm run build
27+
28+
EXPOSE 5000
29+
WORKDIR /app/apps/backend
30+
ENTRYPOINT ["./entrypoint.sh"]

RELEASE_NOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
### ✨ Features
22

3+
- Added support for NodeJS.
34
- New features and improvements.
45

56
### 🐛 Bug Fixes

apps/backend/.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ node_modules
33
.env
44

55
prisma/client/*
6-
!prisma/client/sql
6+
!prisma/client/sql
7+
dist
8+
tsconfig.build.tsbuildinfo

apps/backend/entrypoint.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,8 @@
33
pnpm exec prisma migrate deploy
44
pnpm exec prisma generate
55

6-
bun run src/index.ts
6+
if [ "$1" = "--bun" ]; then
7+
bun run src/index.ts
8+
else
9+
node dist/index.js
10+
fi

apps/backend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"scripts": {
77
"start": "bun run src/index.ts",
88
"dev": "watchexec -r -e ts bun run src/index.ts",
9+
"build": "rm -rf dist && tsc -b tsconfig.build.json",
910
"lint": "eslint .",
1011
"lint:fix": "eslint . --fix",
1112
"generate": "prisma generate",

apps/backend/tsconfig.build.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "dist",
5+
"rootDir": "src"
6+
},
7+
"exclude": ["node_modules", "dist", "tests"]
8+
}

apps/docs/src/app/getting-started/page.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ We've made LetterSpace for simplicity and ease of use. The easiest way to get st
3030

3131
backend:
3232
image: ghcr.io/dcodesdev/letterspace:latest
33+
# image: ghcr.io/dcodesdev/letterspace:latest-node # Or if you want to use NodeJS
3334
pull_policy: always
3435
restart: always
3536
depends_on:

apps/docs/src/app/layout.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import "nextra-theme-docs/style.css"
66
import Link from "next/link"
77
import Image from "next/image"
88
import type { Metadata } from "next"
9+
import { Analytics } from "@/components"
910

1011
export const metadata: Metadata = {
1112
title: "LetterSpace Documentation | Self-hosted Newsletter Platform",
@@ -127,6 +128,7 @@ export default async function RootLayout({
127128
// ... Your additional layout options
128129
>
129130
{children}
131+
<Analytics />
130132
</Layout>
131133
</body>
132134
</html>

0 commit comments

Comments
 (0)