fix config for docker and import in getServerSideProps

This commit is contained in:
Guillaume Dorce 2023-05-26 15:11:31 +02:00
parent 19379d3cf0
commit 36d83fceec
4 changed files with 7 additions and 7 deletions

View File

@ -18,17 +18,17 @@ RUN \
##### BUILDER ##### BUILDER
FROM --platform=linux/amd64 node:16-alpine3.17 AS builder FROM --platform=linux/amd64 node:16-alpine3.17 AS builder
ARG PB_API
WORKDIR /app WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules COPY --from=deps /app/node_modules ./node_modules
COPY . . COPY . .
ENV NEXT_TELEMETRY_DISABLED 1 ENV NEXT_TELEMETRY_DISABLED 1
ENV SKIP_ENV_VALIDATION 1
RUN \ RUN \
if [ -f yarn.lock ]; then SKIP_ENV_VALIDATION=1 yarn build; \ if [ -f yarn.lock ]; then yarn build; \
elif [ -f package-lock.json ]; then SKIP_ENV_VALIDATION=1 npm run build; \ elif [ -f package-lock.json ]; then npm run build; \
elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && SKIP_ENV_VALIDATION=1 pnpm run build; \ elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm run build; \
else echo "Lockfile not found." && exit 1; \ else echo "Lockfile not found." && exit 1; \
fi fi

View File

@ -1,5 +1,4 @@
import Layout from "@/layouts/Home" import Layout from "@/layouts/Home"
import { getPages } from "@/utils/pb"
import type { PagesRecord } from "@/@types/pocketbase-types" import type { PagesRecord } from "@/@types/pocketbase-types"
export default function Test({ json }: { json: PagesRecord[]}) { export default function Test({ json }: { json: PagesRecord[]}) {
@ -18,6 +17,7 @@ export default function Test({ json }: { json: PagesRecord[]}) {
} }
export async function getServerSideProps() { export async function getServerSideProps() {
const { getPages } = await import("@/utils/pb")
const {data, error} = await getPages(); const {data, error} = await getPages();
if (error || !data) { if (error || !data) {

View File

@ -1,6 +1,5 @@
import type { PagesRecord } from '@/@types/pocketbase-types'; import type { PagesRecord } from '@/@types/pocketbase-types';
import Layout from '@/layouts/Home' import Layout from '@/layouts/Home'
import { getPageBySlug } from '@/utils/pb'
function parseBoldText(text: string) { function parseBoldText(text: string) {
const parts = text.split(/(<b>.*?<\/b>)/g); const parts = text.split(/(<b>.*?<\/b>)/g);
@ -86,6 +85,7 @@ export default function Page({ data }: { slug: string, data: PagesRecord<Content
} }
export async function getServerSideProps({ params }: { params: { slug: string } }) { export async function getServerSideProps({ params }: { params: { slug: string } }) {
const { getPageBySlug } = await import("@/utils/pb");
const { data, error } = await getPageBySlug(params.slug); const { data, error } = await getPageBySlug(params.slug);
if (error || !data) { if (error || !data) {
return { return {

View File

@ -1,5 +1,4 @@
import type { PagesRecord } from "@/@types/pocketbase-types"; import type { PagesRecord } from "@/@types/pocketbase-types";
import { getPages } from "@/utils/pb";
import Layout from "@/layouts/Home"; import Layout from "@/layouts/Home";
export default function ListPages({ data }: { data: PagesRecord[] }) { export default function ListPages({ data }: { data: PagesRecord[] }) {
@ -22,6 +21,7 @@ export default function ListPages({ data }: { data: PagesRecord[] }) {
} }
export async function getServerSideProps() { export async function getServerSideProps() {
const { getPages } = await import("@/utils/pb");
const { data, error } = await getPages(); const { data, error } = await getPages();
if (error || !data) { if (error || !data) {
return { return {