😂 IDK anymore

This commit is contained in:
2025-02-25 16:00:37 -05:00
parent a2eae27c31
commit 8b8f470f52

View File

@@ -1,14 +1,17 @@
# Stage 1: Build Stage (Builder) # Use a non-ARM image (x86_64) for Node.js
FROM node:21-alpine3.18 AS builder FROM --platform=linux/amd64 node:21-alpine3.18 AS builder
# Set environment variables for build # Set metadata for contact
LABEL maintainer="Rishi Ghan <rishi.ghan@gmail.com>"
# Set environment variables
ENV NPM_CONFIG_LOGLEVEL=warn ENV NPM_CONFIG_LOGLEVEL=warn
ENV NODE_ENV=production ENV NODE_ENV=production
# Set the working directory # Set the working directory
WORKDIR /core-services WORKDIR /core-services
# Install build dependencies using apk # Install required dependencies using apk
RUN apk update && apk add --no-cache \ RUN apk update && apk add --no-cache \
bash \ bash \
wget \ wget \
@@ -43,7 +46,10 @@ RUN wget https://www.rarlab.com/rar/rarlinux-x64-621.tar.gz \
&& cp rar/unrar /usr/bin/ \ && cp rar/unrar /usr/bin/ \
&& rm -rf rarlinux-x64-621.tar.gz rar && rm -rf rarlinux-x64-621.tar.gz rar
# Copy application configuration files to build environment # Verify Node.js installation
RUN node -v && npm -v
# Copy application configuration files
COPY package.json package-lock.json ./ COPY package.json package-lock.json ./
COPY moleculer.config.ts ./ COPY moleculer.config.ts ./
COPY tsconfig.json ./ COPY tsconfig.json ./
@@ -51,25 +57,31 @@ COPY tsconfig.json ./
# Install application dependencies # Install application dependencies
RUN npm install RUN npm install
# Install sharp with platform-specific binaries # Install sharp with proper platform configuration
RUN npm install sharp --build-from-source RUN npm install --force sharp --platform=linux/amd64
# Install global dependencies # Install global dependencies
RUN npm install -g typescript ts-node RUN npm install -g typescript ts-node
# Stage 2: Final Stage (Run Environment) # Copy the rest of the application files (e.g., source code)
FROM node:21-alpine3.18 AS runtime COPY . .
# Set environment variables for runtime # Build the app
RUN npm run build
# Final image
FROM --platform=linux/amd64 node:21-alpine3.18
# Set environment variables
ENV NODE_ENV=production ENV NODE_ENV=production
ENV NPM_CONFIG_LOGLEVEL=warn
# Set the working directory # Set the working directory
WORKDIR /core-services WORKDIR /core-services
# Install runtime dependencies using apk (keep only what is needed to run the app) # Install runtime dependencies
RUN apk update && apk add --no-cache \ RUN apk update && apk add --no-cache \
bash \ bash \
wget \
imagemagick \ imagemagick \
python3 \ python3 \
xvfb \ xvfb \
@@ -82,11 +94,11 @@ RUN apk update && apk add --no-cache \
icu-dev \ icu-dev \
pkgconfig pkgconfig
# Copy only necessary files from the builder stage # Copy necessary files from the builder image
COPY --from=builder /core-services /core-services COPY --from=builder /core-services /core-services
# Expose the application's port # Expose the application's port
EXPOSE 3000 EXPOSE 3000
# Command to run the application # Command to run the application (this will now work)
CMD ["npm", "start"] CMD ["npm", "start"]