Fix Dockerfile to use Node 18 and improve build process

This commit is contained in:
Leopere 2025-03-02 13:33:53 -05:00
parent c5c44986d8
commit 9d45d1ded4
1 changed files with 15 additions and 14 deletions

View File

@ -1,23 +1,20 @@
FROM node:18-alpine as builder
# Install git and other dependencies
RUN apk add --no-cache git
# Clone the repository
RUN git clone --depth 1 https://git.nixc.us/Nixius/hastebin.git /app
WORKDIR /app
# Copy package files first for better caching
COPY package*.json ./
# Clean npm cache and install dependencies with specific flags to avoid errors
# Clean npm cache and install dependencies with better error handling
RUN npm cache clean --force && \
npm install --production --no-optional && \
npm install mocha
chmod +x app.sh
# Copy the rest of the application
COPY . .
# Make sure app.sh is executable
RUN chmod +x app.sh
# Build assets
RUN node update-js.js
# Build assets if needed
RUN node update-js.js || echo "No update-js.js script found"
FROM node:18-alpine
@ -26,10 +23,14 @@ WORKDIR /app
# Copy from builder stage
COPY --from=builder /app .
# Install mocha in the final image
RUN npm install mocha
# Set environment variables
ENV NODE_ENV=production \
HASTEBIN_ENABLE_CSP=true \
HASTEBIN_ENABLE_HSTS=true
HASTEBIN_ENABLE_HSTS=true \
HASTEBIN_ENABLE_CROSS_ORIGIN_ISOLATION=true
# Expose port
EXPOSE 7777