Skip to content

Commit

Permalink
Revert "Revert "feat: improve performance""
Browse files Browse the repository at this point in the history
This reverts commit 9f5fdb8.
  • Loading branch information
TorstenDittmann committed Jun 6, 2024
1 parent 38f1f29 commit 42c7a4f
Show file tree
Hide file tree
Showing 9 changed files with 171 additions and 472 deletions.
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"]
18 changes: 14 additions & 4 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,13 +26,22 @@ 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.middlewares.homepage_compress.compress=true
- traefik.http.routers.homepage.middlewares=homepage_compress
- traefik.http.services.homepage.loadbalancer.server.port=3000
#http
- traefik.http.routers.homepage.entrypoints=web
Expand All @@ -42,6 +52,6 @@ services:
- traefik.http.routers.homepage_secure.rule=PathPrefix(`/`)
- traefik.http.routers.homepage_secure.service=homepage
- traefik.http.routers.homepage_secure.tls=true

networks:
homepage:
5 changes: 5 additions & 0 deletions docker/production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ services:
- --certificatesresolvers.myresolver.acme.email=$_APP_SYSTEM_SECURITY_EMAIL_ADDRESS
- --certificatesresolvers.myresolver.acme.storage=/letsencrypt/${_APP_DOMAIN}.json
- --accesslog=true
labels:
- traefik.http.routers.traefik.middlewares=traefik-compress
- traefik.http.middlewares.traefik-compress.compress=true
ports:
- 80:80
- 443:443
Expand Down Expand Up @@ -84,6 +87,8 @@ services:
- traefik.enable=true
- traefik.docker.lbswarm=true
- traefik.constraint-label-stack=appwrite
- traefik.http.middlewares.homepage_compress.compress=true
- traefik.http.routers.homepage.middlewares=homepage_compress
- traefik.http.services.appwrite_api.loadbalancer.server.port=3000
#http
- traefik.http.routers.appwrite.entrypoints=web
Expand Down
5 changes: 5 additions & 0 deletions docker/stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ services:
- --certificatesresolvers.myresolver.acme.email=$_APP_SYSTEM_SECURITY_EMAIL_ADDRESS
- --certificatesresolvers.myresolver.acme.storage=/letsencrypt/${_APP_DOMAIN}.json
- --accesslog=true
labels:
- traefik.http.routers.traefik.middlewares=traefik-compress
- traefik.http.middlewares.traefik-compress.compress=true
ports:
- 80:80
- 443:443
Expand Down Expand Up @@ -85,6 +88,8 @@ services:
- traefik.enable=true
- traefik.docker.lbswarm=true
- traefik.constraint-label-stack=appwrite
- traefik.http.middlewares.homepage_compress.compress=true
- traefik.http.routers.homepage.middlewares=homepage_compress
- traefik.http.services.appwrite_api.loadbalancer.server.port=3000
#http
- traefik.http.routers.appwrite.entrypoints=web
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

0 comments on commit 42c7a4f

Please sign in to comment.