Dockerfile no longer includes devDependencies or ./src

This commit is contained in:
Nix Krystik
2026-05-20 02:42:45 +08:00
parent 625231480b
commit 4f365db12e
5 changed files with 21 additions and 38 deletions
+17 -6
View File
@@ -1,10 +1,21 @@
FROM node:22-alpine FROM node:22-alpine AS build
WORKDIR /app WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . . COPY . .
RUN npm i
RUN npm run build RUN npm run build
CMD ["npm", "run", "start"]
# ----------
FROM node:22-alpine
WORKDIR /app
ENV NODE_ENV=production
COPY package*.json ./
RUN npm install --omit=dev
COPY --from=build /app/dist ./dist
USER node
CMD ["node", "./dist/index.js"]
+2 -2
View File
@@ -1,6 +1,6 @@
services: services:
discordbotrewrite: hexerade:
restart: always restart: unless-stopped
build: . build: .
env_file: '.env' env_file: '.env'
ports: ports:
+1 -27
View File
@@ -1,5 +1,5 @@
{ {
"name": "e621-discordbot-rewrite", "name": "discordbot-ng",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
@@ -22,7 +22,6 @@
"@types/express-session": "^1.18.1", "@types/express-session": "^1.18.1",
"eslint": "^9.27.0", "eslint": "^9.27.0",
"rimraf": "^6.0.1", "rimraf": "^6.0.1",
"source-map-support": "^0.5.21",
"tsup": "^8.5.0", "tsup": "^8.5.0",
"tsx": "^4.19.4", "tsx": "^4.19.4",
"typescript": "^5.8.3", "typescript": "^5.8.3",
@@ -1996,12 +1995,6 @@
"ieee754": "^1.1.13" "ieee754": "^1.1.13"
} }
}, },
"node_modules/buffer-from": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz",
"integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==",
"dev": true
},
"node_modules/bundle-require": { "node_modules/bundle-require": {
"version": "5.1.0", "version": "5.1.0",
"resolved": "https://registry.npmjs.org/bundle-require/-/bundle-require-5.1.0.tgz", "resolved": "https://registry.npmjs.org/bundle-require/-/bundle-require-5.1.0.tgz",
@@ -5285,25 +5278,6 @@
"node": ">= 8" "node": ">= 8"
} }
}, },
"node_modules/source-map-support": {
"version": "0.5.21",
"resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz",
"integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==",
"dev": true,
"dependencies": {
"buffer-from": "^1.0.0",
"source-map": "^0.6.0"
}
},
"node_modules/source-map-support/node_modules/source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
"dev": true,
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/sprintf-js": { "node_modules/sprintf-js": {
"version": "1.1.3", "version": "1.1.3",
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.3.tgz", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.3.tgz",
+1 -2
View File
@@ -6,7 +6,6 @@
"@types/express-session": "^1.18.1", "@types/express-session": "^1.18.1",
"eslint": "^9.27.0", "eslint": "^9.27.0",
"rimraf": "^6.0.1", "rimraf": "^6.0.1",
"source-map-support": "^0.5.21",
"tsup": "^8.5.0", "tsup": "^8.5.0",
"tsx": "^4.19.4", "tsx": "^4.19.4",
"typescript": "^5.8.3", "typescript": "^5.8.3",
@@ -25,7 +24,7 @@
}, },
"scripts": { "scripts": {
"dev": "tsx watch src/index.ts", "dev": "tsx watch src/index.ts",
"start": "node dist/index.js", "start": "node --enable-source-maps dist/index.js",
"build": "npm run clean && npx tsc && npm run copyfiles", "build": "npm run clean && npx tsc && npm run copyfiles",
"clean": "npx rimraf dist", "clean": "npx rimraf dist",
"copyfiles": "npx copyfiles -u 1 \"./src/**/*.html\" ./dist" "copyfiles": "npx copyfiles -u 1 \"./src/**/*.html\" ./dist"
-1
View File
@@ -1,5 +1,4 @@
import { Client as DiscordClient, GatewayIntentBits, MessageFlags, Partials } from 'discord.js'; import { Client as DiscordClient, GatewayIntentBits, MessageFlags, Partials } from 'discord.js';
import 'source-map-support/register';
import { config } from './config'; import { config } from './config';
import { handleAuditLogCreate, handleBanRemove, handleBulkMessageDelete, handleGuildCreate, handleMemberJoin, handleMessageCreate, handleMessageDelete, handleMessageUpdate, handleThreadCreate, handleVoiceStateUpdate } from './events'; import { handleAuditLogCreate, handleBanRemove, handleBulkMessageDelete, handleGuildCreate, handleMemberJoin, handleMessageCreate, handleMessageDelete, handleMessageUpdate, handleThreadCreate, handleVoiceStateUpdate } from './events';
import { Database } from './shared/Database'; import { Database } from './shared/Database';