Fix Dockerfile to use Node 18 and improve build process
This commit is contained in:
parent
c5c44986d8
commit
9d45d1ded4
29
Dockerfile
29
Dockerfile
|
@ -1,23 +1,20 @@
|
||||||
FROM node:18-alpine as builder
|
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
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy package files first for better caching
|
# Clean npm cache and install dependencies with better error handling
|
||||||
COPY package*.json ./
|
|
||||||
|
|
||||||
# Clean npm cache and install dependencies with specific flags to avoid errors
|
|
||||||
RUN npm cache clean --force && \
|
RUN npm cache clean --force && \
|
||||||
npm install --production --no-optional && \
|
npm install --production --no-optional && \
|
||||||
npm install mocha
|
chmod +x app.sh
|
||||||
|
|
||||||
# Copy the rest of the application
|
# Build assets if needed
|
||||||
COPY . .
|
RUN node update-js.js || echo "No update-js.js script found"
|
||||||
|
|
||||||
# Make sure app.sh is executable
|
|
||||||
RUN chmod +x app.sh
|
|
||||||
|
|
||||||
# Build assets
|
|
||||||
RUN node update-js.js
|
|
||||||
|
|
||||||
FROM node:18-alpine
|
FROM node:18-alpine
|
||||||
|
|
||||||
|
@ -26,10 +23,14 @@ WORKDIR /app
|
||||||
# Copy from builder stage
|
# Copy from builder stage
|
||||||
COPY --from=builder /app .
|
COPY --from=builder /app .
|
||||||
|
|
||||||
|
# Install mocha in the final image
|
||||||
|
RUN npm install mocha
|
||||||
|
|
||||||
# Set environment variables
|
# Set environment variables
|
||||||
ENV NODE_ENV=production \
|
ENV NODE_ENV=production \
|
||||||
HASTEBIN_ENABLE_CSP=true \
|
HASTEBIN_ENABLE_CSP=true \
|
||||||
HASTEBIN_ENABLE_HSTS=true
|
HASTEBIN_ENABLE_HSTS=true \
|
||||||
|
HASTEBIN_ENABLE_CROSS_ORIGIN_ISOLATION=true
|
||||||
|
|
||||||
# Expose port
|
# Expose port
|
||||||
EXPOSE 7777
|
EXPOSE 7777
|
||||||
|
|
Loading…
Reference in New Issue