Fix bugs with deploying images

- Exclude resvg native modules
- Copy resvg native mods into final image
- ensure deps are correct for alpine
This commit is contained in:
Jade Ellis 2024-07-23 22:33:42 +01:00
parent 2bf9699285
commit 722637d530
No known key found for this signature in database
GPG key ID: 8705A2A3EBF77BD2
5 changed files with 14 additions and 4 deletions

View file

@ -1,5 +1,5 @@
# build the sapper app
FROM node AS base
FROM node:alpine AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
@ -12,11 +12,13 @@ WORKDIR /app
FROM base AS build
ENV CI=1
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
RUN mkdir ../node_modules
RUN cp -Lr node_modules/.pnpm/@resvg+resvg-*@*/node_modules/* ../node_modules/
# RUN cd packages/website; --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
RUN cd packages/website; pnpm run build
run cd packages/website; pnpm exec rollup -c server-rollup.config.mjs
RUN cd packages/website; pnpm exec rollup -c server-rollup.config.mjs
# copy node_modules/ and other build files over
FROM node:alpine
@ -26,6 +28,7 @@ COPY --from=build /app/packages/website/output .
COPY --from=build /app/packages/website/build/client ./client/
COPY --from=build /app/packages/website/build/prerendered ./prerendered/
COPY --from=build /app/packages/website/package.json ./package.json
COPY --from=build /node_modules ./node_modules/
ENV NODE_ENV production
EXPOSE 3000

View file

@ -13,6 +13,7 @@
"@fontsource/fira-mono": "^5.0.13",
"@json-feed-types/1_1": "^1.0.2",
"@rollup/plugin-commonjs": "^25.0.8",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/pluginutils": "^5.1.0",
"@sveltejs/adapter-auto": "^3.2.2",

View file

@ -1,6 +1,7 @@
// rollup.config.mjs
import { nodeResolve } from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import json from "@rollup/plugin-json";
export default {
input: 'build/index.js',
@ -8,5 +9,7 @@ export default {
dir: "output",
format: 'esm'
},
plugins: [nodeResolve(), commonjs()]
// external: id => id.startsWith("@resvg/resvg-js-"),
external: ["@resvg/resvg-js"],
plugins: [nodeResolve(), json(), commonjs()]
};

View file

@ -99,7 +99,7 @@ export async function GET({ url }) {
color: '#202020',
margin: '10px 0 10px'
},
children: `Published on ${new Date(page.date).toLocaleDateString()} \xB7 By Jade Ellis \xB7 ${page.readingTime.text}`
children: `Published on ${new Date(page.date).toLocaleDateString()} · By Jade Ellis · ${page.readingTime.text}`
})]
});
const svg = await satori(template, {

3
pnpm-lock.yaml generated
View file

@ -126,6 +126,9 @@ importers:
'@rollup/plugin-commonjs':
specifier: ^25.0.8
version: 25.0.8(rollup@4.18.0)
'@rollup/plugin-json':
specifier: ^6.1.0
version: 6.1.0(rollup@4.18.0)
'@rollup/plugin-node-resolve':
specifier: ^15.2.3
version: 15.2.3(rollup@4.18.0)