From 758b242f111a8c068def2d3cbc0b253379efbd66 Mon Sep 17 00:00:00 2001 From: Leopere Date: Sat, 1 Mar 2025 18:36:47 -0500 Subject: [PATCH] Fix Docker build issues by updating Node version and addressing npm installation errors --- Dockerfile | 38 +++++++++++++++ app.sh | 118 ++++++++++++++++++++++++++++++--------------- docker-compose.yml | 9 ++-- 3 files changed, 123 insertions(+), 42 deletions(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c2d4761 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,38 @@ +FROM node:18-alpine as builder + +WORKDIR /app + +# Copy package files first for better caching +COPY package*.json ./ + +# Clean npm cache and install dependencies with specific flags to avoid errors +RUN npm cache clean --force && \ + npm install --production --no-optional && \ + npm install mocha + +# 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 + +FROM node:18-alpine + +WORKDIR /app + +# Copy from builder stage +COPY --from=builder /app . + +# Set environment variables +ENV NODE_ENV=production \ + HASTEBIN_ENABLE_CSP=true \ + HASTEBIN_ENABLE_HSTS=true + +# Expose port +EXPOSE 7777 + +# Use app.sh script as entry point +CMD ["/app/app.sh"] \ No newline at end of file diff --git a/app.sh b/app.sh index e972691..c0b6c77 100755 --- a/app.sh +++ b/app.sh @@ -23,49 +23,89 @@ case "${STORAGE_TYPE}" in ;; esac - # Generate config.js from environment variables - cat > config.js < config.js <