chore: streamline Dockerfile and remove redundant steps

This commit is contained in:
2025-02-23 17:38:14 +01:00
parent 69f254c791
commit efcaccc0c2
2 changed files with 21 additions and 11 deletions

View File

@@ -32,11 +32,6 @@ jobs:
EOF EOF
echo "Created .env file:" && cat .env echo "Created .env file:" && cat .env
- name: Install dependencies
run: npm install
- name: Build & Push Docker Image - name: Build & Push Docker Image
run: | run: |
# Nutzt den Branch-Namen aus dem auslösenden Workflow # Nutzt den Branch-Namen aus dem auslösenden Workflow

View File

@@ -1,5 +1,5 @@
# Use Node.js LTS image as the base # Stage 1: Build
FROM node:current-alpine FROM node:current-alpine AS builder
# Set working directory # Set working directory
WORKDIR /app WORKDIR /app
@@ -7,20 +7,35 @@ WORKDIR /app
# Copy package.json and package-lock.json # Copy package.json and package-lock.json
COPY package*.json ./ COPY package*.json ./
# Install dependencies # Install dependencies including development dependencies
RUN npm install RUN npm install
# Copy the application code # Copy the application code
COPY . . COPY . .
# Copy the .env file # Install type definitions for react-responsive-masonry
COPY .env .env RUN npm install --save-dev @types/react-responsive-masonry
# Build the Next.js application # Build the Next.js application
RUN npm run build RUN npm run build
# Stage 2: Production
FROM node:current-alpine
# Set working directory
WORKDIR /app
# Copy only the necessary files from the build stage
COPY --from=builder /app/package*.json ./
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/public ./public
COPY --from=builder /app/.env .env
# Install only production dependencies
RUN npm install --only=production
# Expose the port the app runs on # Expose the port the app runs on
EXPOSE 3000 EXPOSE 3000
# Run the app with the start script # Run the app with the start script
CMD ["npm", "start"] ENTRYPOINT [ "npm", "run", "start" ]