hastebin/Dockerfile

39 lines
858 B
Docker

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
# Clean npm cache and install dependencies with better error handling
RUN npm cache clean --force && \
npm install --production --no-optional && \
chmod +x app.sh
# Build assets if needed
RUN node update-js.js || echo "No update-js.js script found"
FROM node:18-alpine
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_CROSS_ORIGIN_ISOLATION=true
# Expose port
EXPOSE 7777
# Use app.sh script as entry point
CMD ["/app/app.sh"]