Skip to content
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

feat: improve performance #1018

Merged
merged 7 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
28 changes: 17 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Use an official Node runtime as a parent image
FROM node:20-bullseye
FROM node:20-bullseye as base

ARG PUBLIC_APPWRITE_COL_MESSAGES_ID
ENV PUBLIC_APPWRITE_COL_MESSAGES_ID ${PUBLIC_APPWRITE_COL_MESSAGES_ID}
Expand Down Expand Up @@ -38,20 +37,27 @@ ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"

WORKDIR /app
COPY package.json package.json
COPY pnpm-lock.yaml pnpm-lock.yaml
RUN corepack enable

FROM base as build

COPY . .
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
RUN NODE_OPTIONS=--max_old_space_size=8192 pnpm run build

# Remove the node_modules folder to avoid wrong binaries
RUN rm -rf node_modules
FROM base as final

# Install fontconfig
COPY ./local-fonts /usr/share/fonts
RUN apt-get update; apt-get install -y fontconfig
RUN apt-get update && \
apt-get install -y fontconfig && \
apt-get autoremove --purge && \
rm -rf /var/lib/apt/lists/*
RUN fc-cache -f -v
COPY --from=build /app/build/ build
COPY --from=build /app/server/ server
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile --prod

RUN corepack enable
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
RUN NODE_OPTIONS=--max_old_space_size=8192 pnpm run build


EXPOSE 3000
CMD [ "node", "server/main.js"]
37 changes: 24 additions & 13 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3.8'

services:
traefik:
image: traefik:2.9
Expand All @@ -12,11 +10,14 @@ services:
- --entrypoints.websecure.address=:443
- --providers.docker.constraints=Label(`traefik.constraint-label-stack`,`homepage`)
- --accesslog=true
labels:
- traefik.http.routers.traefik.middlewares=traefik-compress
- traefik.http.middlewares.traefik-compress.compress=true
ports:
- 80:80
- 8080:8080
volumes:
- /letsencrypt:/letsencrypt
# - /letsencrypt:/letsencrypt
- /var/run/docker.sock:/var/run/docker.sock
networks:
- homepage
Expand All @@ -25,23 +26,33 @@ services:
image: homepage-dev
build:
context: .
args:
- PUBLIC_APPWRITE_PROJECT_INIT_ID=$PUBLIC_APPWRITE_PROJECT_INIT_ID
- PUBLIC_APPWRITE_PROJECT_ID=$PUBLIC_APPWRITE_PROJECT_ID
- PUBLIC_APPWRITE_DB_MAIN_ID=$PUBLIC_APPWRITE_DB_MAIN_ID
- PUBLIC_APPWRITE_COL_THREADS_ID=$PUBLIC_APPWRITE_COL_THREADS_ID
- PUBLIC_APPWRITE_COL_MESSAGES_ID=$PUBLIC_APPWRITE_COL_MESSAGES_ID
- PUBLIC_APPWRITE_FN_TLDR_ID=$PUBLIC_APPWRITE_FN_TLDR_ID
restart: always
networks:
- homepage
labels:
- traefik.enable=true
- traefik.constraint-label-stack=homepage
- traefik.docker.network=homepage
- traefik.http.services.homepage.loadbalancer.server.port=3000
- traefik.docker.network=appwrite
- traefik.http.middlewares.appwrite_middlewares.compress=true
- traefik.http.services.appwrite_service.loadbalancer.server.port=3000
#http
- traefik.http.routers.homepage.entrypoints=web
- traefik.http.routers.homepage.rule=PathPrefix(`/`)
- traefik.http.routers.homepage.service=homepage
- traefik.http.routers.appwrite.entrypoints=web
- traefik.http.routers.appwrite.rule=PathPrefix(`/`)
- traefik.http.routers.appwrite.service=appwrite_service
- traefik.http.routers.appwrite.middlewares=appwrite_middlewares
# https
- traefik.http.routers.homepage_secure.entrypoints=websecure
- traefik.http.routers.homepage_secure.rule=PathPrefix(`/`)
- traefik.http.routers.homepage_secure.service=homepage
- traefik.http.routers.homepage_secure.tls=true

- traefik.http.routers.appwrite_secure.entrypoints=websecure
- traefik.http.routers.appwrite_secure.rule=PathPrefix(`/`)
- traefik.http.routers.appwrite_secure.service=appwrite_service
- traefik.http.routers.appwrite_secure.tls=true
- traefik.http.routers.appwrite_secure.middlewares=appwrite_middlewares

networks:
homepage:
12 changes: 9 additions & 3 deletions docker/production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ services:
- node.role == manager
preferences:
- spread: node.role == worker
labels:
- traefik.http.routers.traefik.middlewares=traefik-compress
- traefik.http.middlewares.traefik-compress.compress=true

server:
image: ghcr.io/appwrite/website:$_APP_VERSION
Expand Down Expand Up @@ -84,17 +87,20 @@ services:
- traefik.enable=true
- traefik.docker.lbswarm=true
- traefik.constraint-label-stack=appwrite
- traefik.http.services.appwrite_api.loadbalancer.server.port=3000
- traefik.http.services.appwrite_service.loadbalancer.server.port=3000
- traefik.http.middlewares.appwrite_middlewares.compress=true
#http
- traefik.http.routers.appwrite.entrypoints=web
- traefik.http.routers.appwrite.rule=Host(`$_APP_DOMAIN`) || Host(`www.$_APP_DOMAIN`)
- traefik.http.routers.appwrite.service=appwrite_api
- traefik.http.routers.appwrite.service=appwrite_service
- traefik.http.routers.appwrite.middlewares=appwrite_middlewares
# https
- traefik.http.routers.appwrite_secure.entrypoints=websecure
- traefik.http.routers.appwrite_secure.rule=Host(`$_APP_DOMAIN`) || Host(`www.$_APP_DOMAIN`)
- traefik.http.routers.appwrite_secure.service=appwrite_api
- traefik.http.routers.appwrite_secure.service=appwrite_service
- traefik.http.routers.appwrite_secure.tls=true
- traefik.http.routers.appwrite_secure.tls.certresolver=myresolver
- traefik.http.routers.appwrite_secure.middlewares=appwrite_middlewares

janitor:
image: appwrite/docker-janitor
Expand Down
12 changes: 9 additions & 3 deletions docker/stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ services:
- node.role == manager
preferences:
- spread: node.role == worker
labels:
- traefik.http.routers.traefik.middlewares=traefik-compress
- traefik.http.middlewares.traefik-compress.compress=true

server:
image: ghcr.io/appwrite/website:$_APP_VERSION
Expand Down Expand Up @@ -85,17 +88,20 @@ services:
- traefik.enable=true
- traefik.docker.lbswarm=true
- traefik.constraint-label-stack=appwrite
- traefik.http.services.appwrite_api.loadbalancer.server.port=3000
- traefik.http.services.appwrite_service.loadbalancer.server.port=3000
- traefik.http.middlewares.appwrite_middlewares.compress=true
#http
- traefik.http.routers.appwrite.entrypoints=web
- traefik.http.routers.appwrite.rule=Host(`$_APP_DOMAIN`) || Host(`www.$_APP_DOMAIN`)
- traefik.http.routers.appwrite.service=appwrite_api
- traefik.http.routers.appwrite.service=appwrite_service
- traefik.http.routers.appwrite.middlewares=appwrite_middlewares
# https
- traefik.http.routers.appwrite_secure.entrypoints=websecure
- traefik.http.routers.appwrite_secure.rule=Host(`$_APP_DOMAIN`) || Host(`www.$_APP_DOMAIN`)
- traefik.http.routers.appwrite_secure.service=appwrite_api
- traefik.http.routers.appwrite_secure.service=appwrite_service
- traefik.http.routers.appwrite_secure.tls=true
- traefik.http.routers.appwrite_secure.tls.certresolver=myresolver
- traefik.http.routers.appwrite_secure.middlewares=appwrite_middlewares

janitor:
image: appwrite/docker-janitor
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@
},
"packageManager": "[email protected]",
"dependencies": {
"compression": "^1.7.4",
"express": "^4.18.2"
"h3": "^1.11.1"
},
"devDependencies": {
"@appwrite.io/console": "^0.6.1",
"@appwrite.io/pink": "0.16",
"@appwrite.io/pink-icons": "0.16",
"@appwrite.io/repo": "github:appwrite/appwrite#main",
"@internationalized/date": "3.5.0",
"@melt-ui/pp": "^0.3.0",
"@melt-ui/svelte": "^0.74.3",
"@playwright/test": "^1.42.0",
Expand All @@ -43,7 +43,6 @@
"@types/morgan": "^1.9.9",
"@typescript-eslint/eslint-plugin": "^7.1.0",
"@typescript-eslint/parser": "^7.1.0",
"@internationalized/date": "3.5.0",
"dequal": "^2.0.3",
"eslint": "^8.57.0",
"eslint-config-prettier": "^8.10.0",
Expand Down
Loading
Loading