Skip to content

Commit

Permalink
fixed docker
Browse files Browse the repository at this point in the history
  • Loading branch information
appujet committed Sep 15, 2024
1 parent 15948da commit d25e529
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 45 deletions.
13 changes: 0 additions & 13 deletions .editorconfig

This file was deleted.

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

bun.lockb
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

Expand Down
39 changes: 14 additions & 25 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,16 @@ FROM node:22 AS builder

WORKDIR /opt/lavamusic/

# Copy package files and install dependencies
# Copy only package files and install dependencies
COPY package*.json ./
RUN npm install --legacy-peer-deps

# Install necessary tools and update npm
RUN apt-get update && apt-get install -y openssl git \
&& npm install -g npm@latest
RUN npm install
RUN npm config set global --legacy-peer-deps

# Copy source code
# Copy source code and configuration
COPY . .

# Copy tsconfig.json
COPY tsconfig.json ./
# Copy prisma
COPY prisma ./prisma
# Generate Prisma client
RUN npx prisma db push
# Build TypeScript
RUN npm run build
# Generate Prisma client and build TypeScript
RUN npx prisma db push && \
npm run build

# Stage 2: Create production image
FROM node:22-slim
Expand All @@ -32,18 +22,20 @@ ENV NODE_ENV=production
WORKDIR /opt/lavamusic/

# Install necessary tools
RUN apt-get update && apt-get install -y openssl
RUN apt-get update && apt-get install -y --no-install-recommends openssl && \
rm -rf /var/lib/apt/lists/*

# Copy compiled code and other necessary files from the builder stage
# Copy compiled code and necessary files from the builder stage
COPY --from=builder /opt/lavamusic/dist ./dist
COPY --from=builder /opt/lavamusic/src/utils/LavaLogo.txt ./src/utils/LavaLogo.txt
COPY --from=builder /opt/lavamusic/prisma ./prisma
COPY --from=builder /opt/lavamusic/scripts ./scripts
COPY --from=builder /opt/lavamusic/package*.json ./
COPY --from=builder /opt/lavamusic/locales ./locales

# Install production dependencies
COPY --from=builder /opt/lavamusic/package*.json ./
RUN npm install --omit=dev

# Generate Prisma client
RUN npx prisma generate
RUN npx prisma db push

Expand All @@ -53,12 +45,9 @@ RUN rm -rf /opt/lavamusic/application.yml && \

# Run as non-root user
RUN addgroup --gid 322 --system lavamusic && \
adduser --uid 322 --system lavamusic

# Change ownership of the folder
RUN chown -R lavamusic:lavamusic /opt/lavamusic/
adduser --uid 322 --system lavamusic && \
chown -R lavamusic:lavamusic /opt/lavamusic/

# Switch to the appropriate user
USER lavamusic

CMD ["node", "dist/index.js"]
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"build": "tsc --project tsconfig.json",
"clean": "node scripts/clean.js && npm run build",
"lint": "biome lint --write",
"prepare": "npm run clean && husky",
"format": "biome format --write"
},
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/music/Play.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { AutocompleteInteraction, VoiceChannel } from "discord.js";
import type { SearchResult } from "lavalink-client/dist/types";
import type { SearchResult } from "lavalink-client";
import { Command, type Context, type Lavamusic } from "../../structures/index";

export default class Play extends Command {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/music/PlayNext.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { AutocompleteInteraction, VoiceChannel } from "discord.js";
import type { SearchResult } from "lavalink-client/dist/types";
import type { SearchResult } from "lavalink-client";
import { Command, type Context, type Lavamusic } from "../../structures/index";

export default class PlayNext extends Command {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/music/Search.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, type VoiceChannel } from "discord.js";
import type { SearchResult, Track } from "lavalink-client/dist/types";
import type { SearchResult, Track } from "lavalink-client";
import { Command, type Context, type Lavamusic } from "../../structures/index";

export default class Search extends Command {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/Buttons.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, type EmojiIdentifierResolvable } from "discord.js";
import type { Player } from "lavalink-client/dist/types";
import type { Player } from "lavalink-client";
import type { Lavamusic } from "../structures/index";

function getButtons(player: Player, client: Lavamusic): ActionRowBuilder<ButtonBuilder>[] {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/functions/player.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Player, Track } from "lavalink-client/dist/types";
import type { Player, Track } from "lavalink-client";
import type { Requester } from "../../types";

/**
Expand Down

0 comments on commit d25e529

Please sign in to comment.