feat: reduce docker image size

This commit is contained in:
diced 2023-08-28 21:24:18 -07:00
parent 9d533b57bf
commit 740d3db239
No known key found for this signature in database
GPG key ID: 370BD1BA142842D1
9 changed files with 9193 additions and 13083 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,9 +0,0 @@
checksumBehavior: update
nodeLinker: node-modules
plugins:
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"
yarnPath: .yarn/releases/yarn-3.6.0.cjs

View file

@ -1,35 +1,21 @@
# FROM ghcr.io/diced/prisma-binaries:4.10.x as prisma-binaries
FROM node:18-alpine3.16 as base
ENV PNPM_HOME="/pnpm"
RUN corepack enable pnpm
RUN corepack prepare pnpm@latest --activate
WORKDIR /zipline
# Prisma binaries
# COPY --from=prisma /prisma-engines /prisma-engines
# ENV PRISMA_QUERY_ENGINE_BINARY=/prisma-engines/query-engine \
# PRISMA_MIGRATION_ENGINE_BINARY=/prisma-engines/migration-engine \
# PRISMA_INTROSPECTION_ENGINE_BINARY=/prisma-engines/introspection-engine \
# PRISMA_FMT_BINARY=/prisma-engines/prisma-fmt \
# PRISMA_CLI_QUERY_ENGINE_TYPE=binary \
# PRISMA_CLIENT_ENGINE_TYPE=binary \
# ZIPLINE_BUILD=true \
# NEXT_TELEMETRY_DISABLED=1 \
# NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1 \
NODE_ENV=production
# Copy the necessary files from the project
COPY prisma ./prisma
COPY .yarn ./.yarn
COPY package.json ./
COPY yarn.lock ./
COPY .yarnrc.yml ./
COPY package.json .
COPY pnpm-lock.yaml .
# Install the dependencies
RUN yarn install --immutable
FROM base as deps
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile
FROM base as builder
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
COPY src ./src
COPY next.config.js ./next.config.js
@ -39,21 +25,21 @@ COPY mimes.json ./mimes.json
COPY code.json ./code.json
COPY themes ./themes
# Run the build
RUN ZIPLINE_BUILD=true yarn build
ENV NEXT_TELEMETRY_DISABLED=1 \
NODE_ENV=production
RUN ZIPLINE_BUILD=true pnpm run build
# Use Alpine Linux as the final image
FROM base
COPY --from=deps /zipline/node_modules ./node_modules
COPY --from=builder /zipline/build ./build
COPY --from=builder /zipline/.next ./.next
COPY --from=builder /zipline/mimes.json ./mimes.json
COPY --from=builder /zipline/code.json ./code.json
# remove the ZIPLINE_BUILD env var
RUN unset ZIPLINE_BUILD
# clean
RUN yarn cache clean --all
RUN rm -rf /tmp/* /root/*

View file

@ -2,19 +2,18 @@
"name": "zipline",
"private": true,
"license": "MIT",
"sideEffects": false,
"version": "4.0.0-dev+1",
"scripts": {
"build": "run-p \"build:*\"",
"build": "pnpm run \"/^build:.*/\"",
"build:prisma": "prisma generate",
"build:next": "next build",
"build:server": "tsup",
"dev": "run-s dev:build dev:server",
"dev:build": "cross-env NODE_ENV=development run-s build:server",
"dev:server": "cross-env NODE_ENV=development DEBUG=zipline node --require ./node_modules/dotenv/config ./build/server.js",
"start": "cross-env NODE_ENV=production node --require ./node_modules/dotenv/config ./build/server.js",
"lint": "eslint --cache --ignore-path .gitignore --fix .",
"format": "prettier --write --ignore-path .gitignore .",
"validate": "run-p lint format",
"dev": "pnpm run build:server && pnpm run dev:server",
"dev:server": "NODE_ENV=development DEBUG=zipline node --require dotenv/config --enable-source-maps ./build/server.js",
"start": "NODE_ENV=production node --require dotenv/config --enable-source-maps ./build/server.js",
"validate": "pnpm run \"/^validate:.*/\"",
"validate:lint": "eslint --cache --ignore-path .gitignore --fix .",
"validate:format": "prettier --write --ignore-path .gitignore .",
"db:prototype": "prisma db push && prisma generate"
},
"dependencies": {
@ -30,15 +29,16 @@
"@mantine/next": "^6.0.14",
"@mantine/notifications": "^6.0.14",
"@mantine/nprogress": "^6.0.14",
"@prisma/client": "^5.0.0",
"@prisma/internals": "^5.0.0",
"@prisma/migrate": "^5.0.0",
"@prisma/client": "^5.2.0",
"@prisma/internals": "^5.2.0",
"@prisma/migrate": "^5.2.0",
"@tabler/icons-react": "^2.23.0",
"@xoi/gps-metadata-remover": "^1.1.2",
"argon2": "^0.30.3",
"bytes": "^3.1.2",
"colorette": "^2.0.20",
"dayjs": "^1.11.8",
"dotenv": "^16.3.1",
"express": "^4.18.2",
"highlight.js": "^11.8.0",
"isomorphic-dompurify": "^1.8.0",
@ -63,6 +63,7 @@
"@types/bytes": "^3.1.1",
"@types/express": "^4.17.17",
"@types/katex": "^0.16.0",
"@types/ms": "^0.7.31",
"@types/multer": "^1.4.7",
"@types/node": "^20.3.1",
"@types/qrcode": "^1.5.1",
@ -70,21 +71,18 @@
"@types/react-dom": "^18.2.4",
"@typescript-eslint/eslint-plugin": "^6.4.0",
"@typescript-eslint/parser": "^6.4.0",
"cross-env": "^7.0.3",
"dotenv": "^16.1.3",
"eslint": "^8.41.0",
"eslint-config-next": "^13.4.19",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-unused-imports": "^3.0.0",
"npm-run-all": "^4.1.5",
"prettier": "^3.0.2",
"prisma": "^5.0.0",
"prisma": "^5.2.0",
"tsup": "^7.0.0",
"typescript": "^5.1.3"
},
"engines": {
"node": ">=18"
},
"packageManager": "yarn@3.6.0"
"packageManager": "pnpm@8.7.0"
}

9149
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -123,13 +123,13 @@ export default function FileModal({
Icon={IconFolderMinus}
onClick={() => removeFromFolder(file)}
tooltip={`Remove from folder "${
folders?.find((f) => f.id === file.folderId)?.name ?? ''
folders?.find((f: any) => f.id === file.folderId)?.name ?? ''
}"`}
color='red'
/>
) : (
<Select
data={folders?.map((f) => ({ value: f.id, label: f.name })) ?? []}
data={folders?.map((f: any) => ({ value: f.id, label: f.name })) ?? []}
placeholder='Add to a folder...'
searchable
creatable

View file

@ -1,13 +1,15 @@
import { defineConfig } from 'tsup';
export default defineConfig({
platform: 'node',
format: 'cjs',
treeshake: true,
clean: false,
sourcemap: true,
entryPoints: {
server: 'src/server/index.ts',
export default defineConfig([
{
platform: 'node',
format: 'cjs',
treeshake: true,
clean: false,
sourcemap: true,
entryPoints: {
server: 'src/server/index.ts',
},
outDir: 'build',
},
outDir: 'build',
});
]);

12114
yarn.lock

File diff suppressed because it is too large Load diff