Some checks failed
Build and Push Docker Image / buildx (push) Has been cancelled
35 lines
721 B
Docker
35 lines
721 B
Docker
FROM node:25-alpine AS base
|
|
WORKDIR /app
|
|
|
|
# Dependencies stage
|
|
FROM base AS deps
|
|
COPY package*.json ./
|
|
RUN npm install --production
|
|
|
|
# Production stage
|
|
FROM base AS production
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
COPY . .
|
|
|
|
# Copy init script
|
|
COPY scripts/init-data-dir.sh /usr/local/bin/init-data-dir.sh
|
|
RUN chmod +x /usr/local/bin/init-data-dir.sh
|
|
|
|
EXPOSE 3000
|
|
|
|
# Create a non-root user
|
|
RUN addgroup -g 1001 -S nodejs
|
|
RUN adduser -S nextjs -u 1001
|
|
|
|
# Create directory for database
|
|
RUN mkdir -p /app/data
|
|
|
|
USER nextjs
|
|
|
|
# Set environment variable for database path
|
|
ENV DB_PATH=/app/data/data.db
|
|
|
|
# Use init script as entrypoint wrapper
|
|
ENTRYPOINT ["/usr/local/bin/init-data-dir.sh"]
|
|
CMD ["node", "server.js"]
|