Skip to content

Moving to pnpm and ditching nx #727

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 6, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,22 @@
# any half-built stuff in the build context as a pre-caution (also saves copying
# 180k files in node_modules that isn't used!).
**/node_modules
node_modules/*
node_modules
docker-data/*
dist
.nx
/apps/frontend/.next
/apps/backend/dist
/apps/workers/dist
/apps/cron/dist
/apps/commands/dist
.devcontainer
**/.git
**/dist
**/*.md
**/LICENSE
**/npm-debug.log
**/*.vscode
.git
.github
reports
5 changes: 5 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ignore-workspace-root-check=true
node-linker=hoisted
restrict-manifest-changes=true
sync-injected-deps-after-scripts[]=build
inject-workspace-packages=true
81 changes: 11 additions & 70 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,78 +1,19 @@
# This Dockerfile is used for producing 3 container images.
#
# base - which is thrown away, that contains node and the basic infrastructure.
# devcontainer - which is used for development, and contains the source code and the node_modules.
# dist - which is used for production, and contains the built source code and the node_modules.

ARG NODE_VERSION="20.17"

# Base image
FROM docker.io/node:${NODE_VERSION}-alpine3.19 AS base

## Just reduce unccessary noise in the logs.
ENV NPM_CONFIG_UPDATE_NOTIFIER=false
ENV NEXT_TELEMETRY_DISABLED=1

RUN apk add --no-cache \
caddy \
bash=5.2.21-r0 \
supervisor=4.2.5-r4
FROM node:20-alpine3.19
RUN apk add --no-cache g++ make py3-pip supervisor bash caddy
RUN npm --no-update-notifier --no-fund --global install [email protected] pm2

WORKDIR /app

EXPOSE 3000
EXPOSE 4200
EXPOSE 5000

COPY var/docker/entrypoint.sh /app/entrypoint.sh
COPY . /app
COPY var/docker/supervisord.conf /etc/supervisord.conf
COPY var/docker/supervisord /app/supervisord_available_configs/
COPY var/docker/Caddyfile /app/Caddyfile
COPY .env.example /config/postiz.env

VOLUME /config
VOLUME /uploads

LABEL org.opencontainers.image.source=https://github.com/gitroomhq/postiz-app

ENTRYPOINT ["/app/entrypoint.sh"]

# Builder image
FROM base AS devcontainer

RUN apk add --no-cache \
pkgconfig \
gcc \
pixman-dev \
cairo-dev \
pango-dev \
make \
build-base

COPY nx.json tsconfig.base.json package.json package-lock.json build.plugins.js /app/
COPY apps /app/apps/
COPY libraries /app/libraries/

RUN npm ci --no-fund && npx nx run-many --target=build --projects=frontend,backend,workers,cron

VOLUME /config
VOLUME /uploads

LABEL org.opencontainers.image.title="Postiz App (DevContainer)"

# Output image
FROM base AS dist

COPY --from=devcontainer /app/node_modules/ /app/node_modules/
COPY --from=devcontainer /app/dist/ /app/dist/

# Required for prisma
COPY --from=devcontainer /app/libraries/ /app/libraries/
COPY var/docker/entrypoint.sh /app/entrypoint.sh
COPY var/docker/supervisord/caddy.conf /etc/supervisor.d/caddy.conf
RUN chmod +x /app/entrypoint.sh

COPY package.json nx.json /app/
RUN pnpm install
RUN pnpm run build

VOLUME /config
VOLUME /uploads
EXPOSE 4200

## Labels at the bottom, because CI will eventually add dates, commit hashes, etc.
LABEL org.opencontainers.image.title="Postiz App (Production)"
CMD ["pnpm", "run", "pm2"]
18 changes: 0 additions & 18 deletions apps/backend/.eslintrc.json

This file was deleted.

8 changes: 8 additions & 0 deletions apps/backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
dist/
node_modules/
[._]*.s[a-v][a-z]
[._]*.sw[a-p]
[._]s[a-rt-v][a-z]
[._]ss[a-gi-z]
[._]sw[a-p]

11 changes: 0 additions & 11 deletions apps/backend/jest.config.ts

This file was deleted.

20 changes: 20 additions & 0 deletions apps/backend/nest-cli.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"$schema": "https://json.schemastore.org/nest-cli",
"collection": "@nestjs/schematics",
"monorepo": false,
"sourceRoot": "src",
"entryFile": "../../dist/backend/apps/backend/src/main",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Entry file path likely misconfigured

entryFile should point to the source entry (e.g., main.ts) under src, not the compiled output. Update to avoid CLI errors:

-  "entryFile": "../../dist/backend/apps/backend/src/main",
+  "entryFile": "main.ts",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"entryFile": "../../dist/backend/apps/backend/src/main",
"entryFile": "main.ts",

"language": "ts",
"generateOptions": {
"spec": false
},
"compilerOptions": {
"manualRestart": true,
"tsConfigPath": "./tsconfig.build.json",
"webpack": false,
"deleteOutDir": true,
"assets": [],
"watchAssets": false,
"plugins": []
}
}
14 changes: 14 additions & 0 deletions apps/backend/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "postiz-backend",
"version": "1.0.0",
"description": "",
"scripts": {
"dev": "dotenv -e ../../.env -- nest start --watch --entryFile=./apps/backend/src/main",
"build": "NODE_ENV=production nest build",
"start": "dotenv -e ../../.env -- node ./dist/apps/backend/src/main.js",
"pm2": "pm2 start pnpm --name backend -- start"
},
"keywords": [],
"author": "",
"license": "ISC"
}
65 changes: 0 additions & 65 deletions apps/backend/project.json

This file was deleted.

5 changes: 2 additions & 3 deletions apps/backend/src/api/routes/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {
Body,
Controller,
Get,
Ip,
Param,
Post,
Query,
Expand Down Expand Up @@ -103,7 +102,7 @@ export class AuthController {
response.status(200).json({
register: true,
});
} catch (e) {
} catch (e: any) {
response.status(400).send(e.message);
}
}
Expand Down Expand Up @@ -167,7 +166,7 @@ export class AuthController {
response.status(200).json({
login: true,
});
} catch (e) {
} catch (e: any) {
response.status(400).send(e.message);
}
}
Expand Down
2 changes: 1 addition & 1 deletion apps/backend/src/api/routes/posts.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class PostsController {
return { ask: this._shortLinkService.askShortLinkedin(body.messages) };
}

@Get('/marketplace/:id?')
@Get('/marketplace/:id')
async getMarketplacePosts(
@GetOrgFromRequest() org: Organization,
@Param('id') id: string
Expand Down
12 changes: 0 additions & 12 deletions apps/backend/tsconfig.app.json

This file was deleted.

23 changes: 23 additions & 0 deletions apps/backend/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"extends": "./tsconfig.json",
"exclude": ["node_modules", "test", "dist", "**/*spec.ts"],
"compilerOptions": {
"module": "CommonJS",
"resolveJsonModule": true,
"declaration": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"target": "ES2021",
"sourceMap": true,
"incremental": true,
"skipLibCheck": true,
"strictNullChecks": false,
"noImplicitAny": false,
"strictBindCallApply": false,
"forceConsistentCasingInFileNames": false,
"noFallthroughCasesInSwitch": false,
"outDir": "./dist"
}
}
19 changes: 7 additions & 12 deletions apps/backend/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
{
"extends": "../../tsconfig.base.json",
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.app.json"
},
{
"path": "./tsconfig.spec.json"
}
],
"compilerOptions": {
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true
"module": "commonjs",
"declaration": true,
"removeComments": true,
"allowSyntheticDefaultImports": true,
"target": "es2017",
"sourceMap": true,
"esModuleInterop": true
}
}
14 changes: 0 additions & 14 deletions apps/backend/tsconfig.spec.json

This file was deleted.

13 changes: 0 additions & 13 deletions apps/backend/webpack.config.js

This file was deleted.

Loading
Loading