-
Notifications
You must be signed in to change notification settings - Fork 0
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 #39 from magicpages/develop
Refactor project structure and update dependencies for v2.0.0
- Loading branch information
Showing
14 changed files
with
475 additions
and
377 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,32 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
## [2.0.0] - 2025-02-04 | ||
|
||
### Added | ||
- TypeScript strict type checking | ||
- Configuration validation using Zod | ||
- HTTP connection pooling for better performance | ||
- Automatic retry mechanism for failed requests | ||
- Detailed performance logging | ||
- Docker development environment | ||
- Health check endpoint | ||
|
||
### Changed | ||
- Improved cache purging with parallel processing | ||
- Better error handling with detailed error messages | ||
- Modular code structure with separate concerns | ||
- Optimized Bunny CDN API calls with concurrency limits | ||
- Docker configuration simplified for better testing | ||
|
||
### Removed | ||
- Spam protection (not needed anymore) | ||
- Body size limits | ||
- Legacy callback-style code | ||
- Direct environment variable usage without validation | ||
|
||
[2.0.0]: https://github.com/magicpages/ghost-bunnycdn-perma-cache-purger/releases/tag/v2.0.0 |
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,43 +1,15 @@ | ||
# Stage 1: Build the application | ||
FROM node:20-alpine as builder | ||
FROM node:18 | ||
|
||
WORKDIR /app | ||
|
||
# Copy package.json and yarn.lock files | ||
COPY package.json yarn.lock ./ | ||
COPY package*.json ./ | ||
RUN npm ci | ||
|
||
# Install dependencies | ||
RUN yarn install --frozen-lockfile | ||
|
||
# Copy the TypeScript source files | ||
COPY src ./src | ||
|
||
# Copy tsconfig.json | ||
COPY tsconfig.json ./ | ||
|
||
# Build the application | ||
RUN yarn build | ||
|
||
# Stage 2: Setup the runtime container | ||
FROM node:20-alpine | ||
|
||
WORKDIR /app | ||
|
||
# Copy package.json along with the built JavaScript files and node_modules | ||
COPY package.json ./ | ||
COPY --from=builder /app/node_modules ./node_modules | ||
COPY --from=builder /app/dist ./dist | ||
COPY . . | ||
RUN npm run build | ||
|
||
ENV NODE_ENV=production | ||
ENV PORT=3000 | ||
ENV ENABLE_PROFILING=false | ||
|
||
# Expose the port the app runs on | ||
EXPOSE 3000 | ||
|
||
# Conditional command to enable profiling if requested | ||
CMD if [ "$ENABLE_PROFILING" = "true" ]; then \ | ||
node --inspect=0.0.0.0:9229 --max-old-space-size=2048 dist/index.js; \ | ||
else \ | ||
node dist/index.js; \ | ||
fi | ||
CMD ["npm", "start"] |
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
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,49 +1,32 @@ | ||
version: '3.8' | ||
|
||
services: | ||
mysql: | ||
image: mysql:8 | ||
environment: | ||
MYSQL_ROOT_PASSWORD: example | ||
MYSQL_DATABASE: ghost | ||
MYSQL_USER: ghost | ||
MYSQL_PASSWORD: ghost | ||
volumes: | ||
- mysql_data:/var/lib/mysql | ||
healthcheck: | ||
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"] | ||
interval: 30s | ||
timeout: 10s | ||
retries: 5 | ||
start_period: 10s | ||
|
||
ghost: | ||
image: ghost:latest | ||
image: ghost:5 | ||
environment: | ||
url: http://localhost:2368 | ||
database__client: mysql | ||
database__connection__host: mysql | ||
database__connection__user: ghost | ||
database__connection__password: ghost | ||
database__connection__database: ghost | ||
url: http://localhost:4000 | ||
database__client: sqlite3 | ||
database__connection__filename: /var/lib/ghost/content/data/ghost.db | ||
volumes: | ||
- ghost_data:/var/lib/ghost/content | ||
depends_on: | ||
mysql: | ||
condition: service_healthy | ||
|
||
bunnycdn-perma-cache-purger: | ||
image: magicpages/bunnycdn-perma-cache-purger:latest | ||
proxy: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
environment: | ||
GHOST_URL: http://ghost:2368 | ||
BUNNYCDN_API_KEY: your_bunnycdn_api_key | ||
BUNNYCDN_PULL_ZONE_ID: your_pull_zone_id | ||
depends_on: | ||
ghost: | ||
condition: service_started | ||
- GHOST_URL=http://ghost:2368 | ||
- PORT=4000 | ||
- DEBUG=true | ||
- BUNNYCDN_API_KEY=<your-bunnycdn-api-key> | ||
- BUNNYCDN_PULL_ZONE_ID=<your-bunnycdn-pull-zone-id> | ||
- BUNNYCDN_PURGE_OLD_CACHE=true | ||
- BUNNYCDN_STORAGE_ZONE_NAME=<your-bunnycdn-storage-zone-name> | ||
- BUNNYCDN_STORAGE_ZONE_PASSWORD=<your-bunnycdn-storage-zone-password> | ||
ports: | ||
- "2368:3000" | ||
- "4000:4000" | ||
depends_on: | ||
- ghost | ||
|
||
volumes: | ||
ghost_data: | ||
mysql_data: |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,6 +1,6 @@ | ||
{ | ||
"name": "ghost-bunnycdn-middleware", | ||
"version": "1.2.1", | ||
"version": "2.0.0", | ||
"description": "A middleware between a Ghost CMS instance and BunnyCDN, supposed to run in a Docker stack, alongside a Ghost container.", | ||
"main": "dist/index.js", | ||
"author": "Jannis Fedoruk-Betschki <[email protected]>", | ||
|
@@ -26,7 +26,8 @@ | |
"http-proxy": "^1.18.1", | ||
"multer": "^1.4.5-lts.1", | ||
"node-fetch": "3.3.2", | ||
"p-limit": "^6.1.0" | ||
"p-limit": "^6.1.0", | ||
"zod": "^3.24.1" | ||
}, | ||
"scripts": { | ||
"build": "tsc", | ||
|
Oops, something went wrong.