Skip to content

Commit

Permalink
docker: Fix dockerfiles to adapt to the new repo structure
Browse files Browse the repository at this point in the history
  • Loading branch information
MohamedBassem committed Mar 14, 2024
1 parent a03f1dc commit 2fbc98e
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 172 deletions.
5 changes: 0 additions & 5 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,13 @@
"@tanstack/react-query": "^5.24.8",
"@tanstack/react-query-devtools": "^5.21.0",
"@trpc/client": "11.0.0-next-beta.308",
"@trpc/next": "11.0.0-next-beta.308",
"@trpc/react-query": "11.0.0-next-beta.308",
"@trpc/server": "11.0.0-next-beta.308",
"better-sqlite3": "^9.4.3",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.0",
"drizzle-orm": "^0.29.4",
"install": "^0.13.0",
"lucide-react": "^0.330.0",
"meilisearch": "^0.37.0",
"next": "14.1.1",
"next-auth": "^4.24.5",
"next-pwa": "^5.6.0",
Expand All @@ -54,7 +51,6 @@
"react-hook-form": "^7.50.1",
"react-markdown": "^9.0.1",
"react-masonry-css": "^1.0.16",
"server-only": "^0.0.1",
"superjson": "^2.2.1",
"tailwind-merge": "^2.2.1",
"tailwindcss-animate": "^1.0.7",
Expand All @@ -73,7 +69,6 @@
"autoprefixer": "^10.4.17",
"postcss": "^8.4.35",
"tailwindcss": "^3.4.1",
"ts-node": "^10.9.2",
"vite-tsconfig-paths": "^4.3.1",
"vitest": "^1.3.1"
},
Expand Down
9 changes: 4 additions & 5 deletions apps/workers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
"name": "@hoarder/workers",
"version": "0.1.0",
"private": true,
"type": "module",
"dependencies": {
"@hoarder/db": "workspace:*",
"@hoarder/shared": "workspace:*",
"@hoarder/db": "workspace:^0.1.0",
"@hoarder/shared": "workspace:^0.1.0",
"@mozilla/readability": "^0.5.0",
"@tsconfig/node21": "^21.0.1",
"async-mutex": "^0.4.1",
"bullmq": "^5.1.9",
"dompurify": "^3.0.9",
Expand All @@ -29,14 +27,15 @@
"puppeteer-extra": "^3.3.6",
"puppeteer-extra-plugin-adblocker": "^2.13.6",
"puppeteer-extra-plugin-stealth": "^2.11.2",
"@tsconfig/node21": "^21.0.1",
"@hoarder/tsconfig": "workspace:^0.1.0",
"tsx": "^4.7.1",
"typescript": "^5.3.3",
"zod": "^3.22.4"
},
"devDependencies": {
"@hoarder/eslint-config": "workspace:^0.2.0",
"@hoarder/prettier-config": "workspace:^0.1.0",
"@hoarder/tsconfig": "workspace:^0.1.0",
"@types/dompurify": "^3.0.5",
"@types/jsdom": "^21.1.6",
"@types/metascraper": "^5.14.3"
Expand Down
20 changes: 10 additions & 10 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ RUN cd packages/db && \
# Rebuild the source code only when needed
FROM base AS web_builder

WORKDIR /app/packages/web
WORKDIR /app/apps/web

RUN pnpm next experimental-compile

Expand All @@ -37,19 +37,19 @@ WORKDIR /app
ENV NODE_ENV production
ENV NEXT_TELEMETRY_DISABLED 1

COPY --from=web_builder --chown=node:node /app/packages/web/.next/standalone ./
COPY --from=web_builder /app/packages/web/public ./packages/web/public
COPY --from=web_builder --chown=node:node /app/apps/web/.next/standalone ./
COPY --from=web_builder /app/apps/web/public ./apps/web/public
COPY --from=web_builder /db_migrations /db_migrations

# Set the correct permission for prerender cache
RUN mkdir -p ./package/web/.next
RUN chown node:node ./packages/web/.next
RUN mkdir -p ./apps/web/.next
RUN chown node:node ./apps/web/.next

# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=web_builder --chown=node:node /app/packages/web/.next/static ./packages/web/.next/static
COPY --from=web_builder --chown=node:node /app/apps/web/.next/static ./apps/web/.next/static

WORKDIR /app/packages/web
WORKDIR /app/apps/web
USER root
EXPOSE 3000

Expand All @@ -65,7 +65,7 @@ CMD ["/bin/sh", "-c", "(cd /db_migrations && node index.js) && node server.js"]

FROM base AS workers_builder

RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm deploy --filter @hoarder/workers --prod /prod
RUN --mount=type=cache,id=pnpm_workers,target=/pnpm/store pnpm deploy --node-linker=isolated --filter @hoarder/workers --prod /prod

################# The workers ##############

Expand All @@ -78,14 +78,14 @@ ENV CHROME_PATH "/usr/bin/chromium-browser"
ENV BROWSER_EXECUTABLE_PATH "/app/start-chrome.sh"
ENV BROWSER_USER_DATA_DIR="/tmp/chrome"

COPY --from=workers_builder /prod packages/workers
COPY --from=workers_builder /prod apps/workers

RUN corepack enable

ADD docker/start-chrome.sh .
RUN chmod +x start-chrome.sh

WORKDIR /app/packages/workers
WORKDIR /app/apps/workers

USER root

Expand Down
1 change: 0 additions & 1 deletion packages/db/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"version": "0.1.0",
"private": true,
"main": "index.ts",
"type": "module",
"scripts": {
"typecheck": "tsc --noEmit",
"migrate": "tsx migrate.ts",
Expand Down
1 change: 1 addition & 0 deletions packages/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"private": true,
"type": "module",
"dependencies": {
"bullmq": "^5.1.9",
"meilisearch": "^0.37.0",
"winston": "^3.11.0",
"zod": "^3.22.4"
Expand Down
5 changes: 1 addition & 4 deletions packages/trpc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
"@hoarder/prettier-config": "workspace:^0.1.0",
"@hoarder/tsconfig": "workspace:^0.1.0",
"@types/bcryptjs": "^2.4.6",
"@tsconfig/node21": "^21.0.1",
"@types/bcrypt": "^5.0.2",
"nock": "^13.5.4",
"vite-tsconfig-paths": "^4.3.1",
"vitest": "^1.3.1"
},
Expand All @@ -35,4 +32,4 @@
]
},
"prettier": "@hoarder/prettier-config"
}
}
Loading

0 comments on commit 2fbc98e

Please sign in to comment.