This commit is contained in:
38
Dockerfile
38
Dockerfile
@ -1,38 +1,34 @@
|
||||
FROM node:24-alpine
|
||||
FROM node:20-alpine
|
||||
|
||||
# Install pnpm
|
||||
RUN npm install -g pnpm
|
||||
|
||||
# Set the working directory in the container
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package.json and pnpm-lock.yaml (if available)
|
||||
COPY package*.json pnpm-lock.yaml* ./
|
||||
# Install pnpm globally
|
||||
RUN npm install -g pnpm
|
||||
|
||||
# Copy dependency files first for better caching
|
||||
COPY package.json pnpm-lock.yaml ./
|
||||
|
||||
# Install dependencies
|
||||
RUN pnpm install --frozen-lockfile --prod
|
||||
|
||||
# Copy the rest of the application code
|
||||
COPY . .
|
||||
# Copy application files
|
||||
COPY server.js todo-service.js signal-crypto.js ./
|
||||
COPY public/ ./public/
|
||||
COPY .env* ./
|
||||
|
||||
# Create a directory for the SQLite database
|
||||
RUN mkdir -p /app/data
|
||||
# Create data directory and set permissions
|
||||
RUN mkdir -p /app/data && chown -R node:node /app
|
||||
|
||||
# Set environment variables
|
||||
ENV NODE_ENV=production
|
||||
ENV SQLITE_DB_PATH=/app/data/db.db
|
||||
ENV PORT=3000
|
||||
|
||||
# Expose the port the app runs on
|
||||
# Expose port
|
||||
EXPOSE 3000
|
||||
|
||||
# Create a non-root user to run the application
|
||||
RUN addgroup -g 1001 -S nodejs
|
||||
RUN adduser -S nodejs -u 1001
|
||||
# Switch to non-root user
|
||||
USER node
|
||||
|
||||
# Change ownership of the app directory to the nodejs user
|
||||
RUN chown -R nodejs:nodejs /app
|
||||
USER nodejs
|
||||
|
||||
# Command to run the application
|
||||
CMD ["pnpm", "start"]
|
||||
# Start application
|
||||
CMD ["node", "server.js"]
|
||||
|
Reference in New Issue
Block a user