feat: reduce docker image size

This commit is contained in:
diced
2023-08-28 21:24:18 -07:00
parent 9d533b57bf
commit 740d3db239
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 FROM node:18-alpine3.16 as base
ENV PNPM_HOME="/pnpm"
RUN corepack enable pnpm
RUN corepack prepare pnpm@latest --activate
WORKDIR /zipline 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 prisma ./prisma
COPY .yarn ./.yarn COPY package.json .
COPY package.json ./ COPY pnpm-lock.yaml .
COPY yarn.lock ./
COPY .yarnrc.yml ./
# Install the dependencies FROM base as deps
RUN yarn install --immutable RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile
FROM base as builder FROM base as builder
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
COPY src ./src COPY src ./src
COPY next.config.js ./next.config.js COPY next.config.js ./next.config.js
@@ -39,21 +25,21 @@ COPY mimes.json ./mimes.json
COPY code.json ./code.json COPY code.json ./code.json
COPY themes ./themes COPY themes ./themes
# Run the build ENV NEXT_TELEMETRY_DISABLED=1 \
RUN ZIPLINE_BUILD=true yarn build NODE_ENV=production
RUN ZIPLINE_BUILD=true pnpm run build
# Use Alpine Linux as the final image
FROM base FROM base
COPY --from=deps /zipline/node_modules ./node_modules
COPY --from=builder /zipline/build ./build COPY --from=builder /zipline/build ./build
COPY --from=builder /zipline/.next ./.next COPY --from=builder /zipline/.next ./.next
COPY --from=builder /zipline/mimes.json ./mimes.json COPY --from=builder /zipline/mimes.json ./mimes.json
COPY --from=builder /zipline/code.json ./code.json COPY --from=builder /zipline/code.json ./code.json
# remove the ZIPLINE_BUILD env var
RUN unset ZIPLINE_BUILD
# clean # clean
RUN yarn cache clean --all RUN yarn cache clean --all
RUN rm -rf /tmp/* /root/* RUN rm -rf /tmp/* /root/*

View File

@@ -2,19 +2,18 @@
"name": "zipline", "name": "zipline",
"private": true, "private": true,
"license": "MIT", "license": "MIT",
"sideEffects": false,
"version": "4.0.0-dev+1", "version": "4.0.0-dev+1",
"scripts": { "scripts": {
"build": "run-p \"build:*\"", "build": "pnpm run \"/^build:.*/\"",
"build:prisma": "prisma generate",
"build:next": "next build", "build:next": "next build",
"build:server": "tsup", "build:server": "tsup",
"dev": "run-s dev:build dev:server", "dev": "pnpm run build:server && pnpm run dev:server",
"dev:build": "cross-env NODE_ENV=development run-s build:server", "dev:server": "NODE_ENV=development DEBUG=zipline node --require dotenv/config --enable-source-maps ./build/server.js",
"dev:server": "cross-env NODE_ENV=development DEBUG=zipline node --require ./node_modules/dotenv/config ./build/server.js", "start": "NODE_ENV=production node --require dotenv/config --enable-source-maps ./build/server.js",
"start": "cross-env NODE_ENV=production node --require ./node_modules/dotenv/config ./build/server.js", "validate": "pnpm run \"/^validate:.*/\"",
"lint": "eslint --cache --ignore-path .gitignore --fix .", "validate:lint": "eslint --cache --ignore-path .gitignore --fix .",
"format": "prettier --write --ignore-path .gitignore .", "validate:format": "prettier --write --ignore-path .gitignore .",
"validate": "run-p lint format",
"db:prototype": "prisma db push && prisma generate" "db:prototype": "prisma db push && prisma generate"
}, },
"dependencies": { "dependencies": {
@@ -30,15 +29,16 @@
"@mantine/next": "^6.0.14", "@mantine/next": "^6.0.14",
"@mantine/notifications": "^6.0.14", "@mantine/notifications": "^6.0.14",
"@mantine/nprogress": "^6.0.14", "@mantine/nprogress": "^6.0.14",
"@prisma/client": "^5.0.0", "@prisma/client": "^5.2.0",
"@prisma/internals": "^5.0.0", "@prisma/internals": "^5.2.0",
"@prisma/migrate": "^5.0.0", "@prisma/migrate": "^5.2.0",
"@tabler/icons-react": "^2.23.0", "@tabler/icons-react": "^2.23.0",
"@xoi/gps-metadata-remover": "^1.1.2", "@xoi/gps-metadata-remover": "^1.1.2",
"argon2": "^0.30.3", "argon2": "^0.30.3",
"bytes": "^3.1.2", "bytes": "^3.1.2",
"colorette": "^2.0.20", "colorette": "^2.0.20",
"dayjs": "^1.11.8", "dayjs": "^1.11.8",
"dotenv": "^16.3.1",
"express": "^4.18.2", "express": "^4.18.2",
"highlight.js": "^11.8.0", "highlight.js": "^11.8.0",
"isomorphic-dompurify": "^1.8.0", "isomorphic-dompurify": "^1.8.0",
@@ -63,6 +63,7 @@
"@types/bytes": "^3.1.1", "@types/bytes": "^3.1.1",
"@types/express": "^4.17.17", "@types/express": "^4.17.17",
"@types/katex": "^0.16.0", "@types/katex": "^0.16.0",
"@types/ms": "^0.7.31",
"@types/multer": "^1.4.7", "@types/multer": "^1.4.7",
"@types/node": "^20.3.1", "@types/node": "^20.3.1",
"@types/qrcode": "^1.5.1", "@types/qrcode": "^1.5.1",
@@ -70,21 +71,18 @@
"@types/react-dom": "^18.2.4", "@types/react-dom": "^18.2.4",
"@typescript-eslint/eslint-plugin": "^6.4.0", "@typescript-eslint/eslint-plugin": "^6.4.0",
"@typescript-eslint/parser": "^6.4.0", "@typescript-eslint/parser": "^6.4.0",
"cross-env": "^7.0.3",
"dotenv": "^16.1.3",
"eslint": "^8.41.0", "eslint": "^8.41.0",
"eslint-config-next": "^13.4.19", "eslint-config-next": "^13.4.19",
"eslint-config-prettier": "^9.0.0", "eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.0", "eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-unused-imports": "^3.0.0", "eslint-plugin-unused-imports": "^3.0.0",
"npm-run-all": "^4.1.5",
"prettier": "^3.0.2", "prettier": "^3.0.2",
"prisma": "^5.0.0", "prisma": "^5.2.0",
"tsup": "^7.0.0", "tsup": "^7.0.0",
"typescript": "^5.1.3" "typescript": "^5.1.3"
}, },
"engines": { "engines": {
"node": ">=18" "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} Icon={IconFolderMinus}
onClick={() => removeFromFolder(file)} onClick={() => removeFromFolder(file)}
tooltip={`Remove from folder "${ tooltip={`Remove from folder "${
folders?.find((f) => f.id === file.folderId)?.name ?? '' folders?.find((f: any) => f.id === file.folderId)?.name ?? ''
}"`} }"`}
color='red' color='red'
/> />
) : ( ) : (
<Select <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...' placeholder='Add to a folder...'
searchable searchable
creatable creatable

View File

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

12114
yarn.lock

File diff suppressed because it is too large Load Diff