Build and Push Fridger Container / Build & Push Fridger Image (push) Failing after 31s
39 lines
914 B
Docker
39 lines
914 B
Docker
# Multi-stage lightweight Docker image for Fridger
|
|
FROM node:22-alpine AS runner
|
|
|
|
# Create app directory
|
|
WORKDIR /app
|
|
|
|
# Set environment
|
|
ENV NODE_ENV=production \
|
|
PORT=3000 \
|
|
FRIDGER_DATA_DIR=/data \
|
|
FRIDGER_DB_PATH=/data/fridger.db
|
|
|
|
# Install dependencies first for layer caching
|
|
COPY package.json package-lock.json ./
|
|
RUN npm ci --omit=dev && npm cache clean --force
|
|
|
|
# Copy application source
|
|
COPY server.js db.js barcode.js ./
|
|
COPY public/ ./public/
|
|
|
|
# Setup persistent data storage directory with proper permissions
|
|
RUN mkdir -p /data && chown -R node:node /app /data
|
|
|
|
# Use non-root user
|
|
USER node
|
|
|
|
# Expose web port
|
|
EXPOSE 3000
|
|
|
|
# Declare persistent volume
|
|
VOLUME ["/data"]
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
|
|
CMD wget --no-verbose --tries=1 --spider http://localhost:3000/health || exit 1
|
|
|
|
# Start the application
|
|
CMD ["node", "server.js"]
|