From e99d4fd3c69327f12be8943a997169f798ae7512 Mon Sep 17 00:00:00 2001 From: hunghvu Date: Wed, 2 Oct 2024 23:40:33 -0700 Subject: [PATCH] fix: attempt to resolve #174 --- apps/cms/Dockerfile | 15 +++++++++------ apps/web/Dockerfile | 35 ++++++++++++++++++----------------- docker-compose.yml | 2 -- package.json | 3 ++- 4 files changed, 29 insertions(+), 26 deletions(-) diff --git a/apps/cms/Dockerfile b/apps/cms/Dockerfile index 92a4d5f..44983a8 100644 --- a/apps/cms/Dockerfile +++ b/apps/cms/Dockerfile @@ -7,6 +7,7 @@ RUN apk update WORKDIR /app COPY . . +ENV SKIP_YARN_COREPACK_CHECK=0 RUN yarn global add turbo RUN turbo prune cms --docker @@ -24,12 +25,13 @@ COPY --from=builder /app/out/pnpm-lock.yaml ./pnpm-lock.yaml COPY --from=builder /app/out/full/ . COPY turbo.json turbo.json +ENV SKIP_YARN_COREPACK_CHECK=0 RUN yarn global add turbo -RUN yarn global add pnpm@9.0.4 +RUN yarn global add pnpm RUN yarn global add dotenv-cli RUN pnpm install -ENV NODE_ENV production +ENV NODE_ENV=production RUN pnpm run build --filter cms FROM base AS runner @@ -50,10 +52,11 @@ COPY --from=installer --chown=payload:nodejs /app/apps/cms/node_modules ./apps/c COPY --from=installer --chown=payload:nodejs /app/node_modules/.pnpm ./node_modules/.pnpm # Runtime environment variables -ENV PAYLOAD_PUBLIC_SERVER_URL https://payload.hungvu.tech -ENV PAYLOAD_FRONT_END_DOMAIN hungvu.tech -ENV PAYLOAD_BACK_END_DOMAIN payload.hungvu.tech -ENV PAYLOAD_PORT 3100 +ENV PAYLOAD_PUBLIC_SERVER_URL=https://payload.hungvu.tech +ENV PAYLOAD_FRONT_END_DOMAIN=hungvu.tech +ENV PAYLOAD_BACK_END_DOMAIN=payload.hungvu.tech +ENV PAYLOAD_PORT=3100 +ENV SKIP_YARN_COREPACK_CHECK=0 WORKDIR /app/apps/cms CMD yarn run serve \ No newline at end of file diff --git a/apps/web/Dockerfile b/apps/web/Dockerfile index 3725cc8..03f2bba 100644 --- a/apps/web/Dockerfile +++ b/apps/web/Dockerfile @@ -4,6 +4,7 @@ FROM base AS builder RUN apk add --no-cache libc6-compat RUN apk update WORKDIR /app +ENV SKIP_YARN_COREPACK_CHECK=0 RUN yarn global add turbo COPY . . RUN turbo prune web --docker @@ -21,9 +22,9 @@ COPY --from=builder /app/out/pnpm-lock.yaml ./pnpm-lock.yaml COPY --from=builder /app/out/full/ . COPY turbo.json turbo.json - +ENV SKIP_YARN_COREPACK_CHECK=0 RUN yarn global add turbo -RUN yarn global add pnpm@9.0.4 +RUN yarn global add pnpm RUN yarn global add dotenv-cli # pnpm install cannot run after NODE_ENV production, or else it skips devDependencies # and breaks turborepo setup @@ -33,29 +34,29 @@ ENV NEXT_TELEMETRY_DISABLED 1 ENV NODE_ENV production # Public environment variables, only for build time -ENV NEXT_PUBLIC_BASE_URL https://hungvu.tech -ENV NEXT_PUBLIC_GOOGLE_SITE_VERIFICATION EGTdZytY_C05esF562wX0i-fpIShKgfypgbhQV3bPzU -ENV NEXT_PUBLIC_API_OPENWRT_TOH_FILTER https://hungvu.tech/api/openwrt-toh/filter +ENV NEXT_PUBLIC_BASE_URL=https://hungvu.tech +ENV NEXT_PUBLIC_GOOGLE_SITE_VERIFICATION=EGTdZytY_C05esF562wX0i-fpIShKgfypgbhQV3bPzU +ENV NEXT_PUBLIC_API_OPENWRT_TOH_FILTER=https://hungvu.tech/api/openwrt-toh/filter # Global content material -ENV NEXT_REQUEST_CMS_STATIC_ROUTE_METADATA_URL https://payload.hungvu.tech/api/static-route-metadata +ENV NEXT_REQUEST_CMS_STATIC_ROUTE_METADATA_URL=https://payload.hungvu.tech/api/static-route-metadata # Media -ENV NEXT_REQUEST_CMS_MEDIA_URL https://payload.hungvu.tech/api/media +ENV NEXT_REQUEST_CMS_MEDIA_URL=https://payload.hungvu.tech/api/media # Blog -ENV NEXT_REQUEST_CMS_ARTICLES_URL https://payload.hungvu.tech/api/articles -ENV NEXT_REQUEST_CMS_ARTICLES_IGNORE_REDUNDANT_FIELDS_URL https://payload.hungvu.tech/api/articles/ignore-redundant-fields -ENV NEXT_REQUEST_CMS_ARTICLES_IN_THE_SAME_SERIES_URL https://payload.hungvu.tech/api/articles/in-series +ENV NEXT_REQUEST_CMS_ARTICLES_URL=https://payload.hungvu.tech/api/articles +ENV NEXT_REQUEST_CMS_ARTICLES_IGNORE_REDUNDANT_FIELDS_URL=https://payload.hungvu.tech/api/articles/ignore-redundant-fields +ENV NEXT_REQUEST_CMS_ARTICLES_IN_THE_SAME_SERIES_URL=https://payload.hungvu.tech/api/articles/in-series # Lab -ENV NEXT_REQUEST_CMS_LABS_URL https://payload.hungvu.tech/api/labs -ENV NEXT_REQUEST_CMS_LABS_IGNORE_REDUNDANT_FIELDS_URL https://payload.hungvu.tech/api/labs/ignore-redundant-fields +ENV NEXT_REQUEST_CMS_LABS_URL=https://payload.hungvu.tech/api/labs +ENV NEXT_REQUEST_CMS_LABS_IGNORE_REDUNDANT_FIELDS_URL=https://payload.hungvu.tech/api/labs/ignore-redundant-fields # Lab - OpenWRT TOH -ENV NEXT_REQUEST_CMS_OPENWRT_TOH_URL https://payload.hungvu.tech/api/openwrt-toh -ENV NEXT_REQUEST_CMS_OPENWRT_TOH_AVAILABLE_VALUES_OF_EACH_FIELD_URL https://payload.hungvu.tech/api/openwrt-toh/available-values-of-each-field -ENV NEXT_REQUEST_CMS_OPENWRT_TOH_FILTER_URL https://payload.hungvu.tech/api/openwrt-toh/filter +ENV NEXT_REQUEST_CMS_OPENWRT_TOH_URL=https://payload.hungvu.tech/api/openwrt-toh +ENV NEXT_REQUEST_CMS_OPENWRT_TOH_AVAILABLE_VALUES_OF_EACH_FIELD_URL=https://payload.hungvu.tech/api/openwrt-toh/available-values-of-each-field +ENV NEXT_REQUEST_CMS_OPENWRT_TOH_FILTER_URL=https://payload.hungvu.tech/api/openwrt-toh/filter RUN pnpm run build --filter web FROM base AS runner @@ -72,8 +73,8 @@ COPY --from=installer --chown=nextjs:nodejs /app/apps/web/.next/standalone ./ COPY --from=installer --chown=nextjs:nodejs /app/apps/web/.next/static ./apps/web/.next/static COPY --from=installer --chown=nextjs:nodejs /app/apps/web/public ./apps/web/public -ENV NEXT_TELEMETRY_DISABLED 1 -ENV NODE_ENV production +ENV NEXT_TELEMETRY_DISABLED=1 +ENV NODE_ENV=production # It seems these are required for both build and runtime # For build time, it is so Next.js can generate cache files diff --git a/docker-compose.yml b/docker-compose.yml index 1c7cd68..6564e64 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,5 @@ # Author: Hung Vu -version: "3.8" - services: # MongoDB Atlas does not support IPv6, so self hosting is a stopgap solution mongo: diff --git a/package.json b/package.json index 18a446a..6c9aa37 100644 --- a/package.json +++ b/package.json @@ -25,5 +25,6 @@ }, "engines": { "node": ">=20.0.0" - } + }, + "packageManager": "pnpm@9.12.0" } \ No newline at end of file