Files
homarr/Dockerfile.unraid
Kaloyan Danchev a48a06e680
Some checks failed
Master CI / yarn_install_and_build (push) Has been cancelled
Add Docker deployment for Unraid
- Add Dockerfile.unraid with multi-stage build (builds inside container)
- Add docker-compose.unraid.yml for easy deployment
- Add build-and-push.sh script for building and pushing to Gitea registry
- Update root redirect to /unraid dashboard

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-06 09:48:30 +02:00

106 lines
2.8 KiB
Docker

# Multi-stage Dockerfile for Homarr Unraid UI
# Builds entirely inside Docker to avoid native module issues
# Build stage
FROM node:20.2.0-slim AS builder
WORKDIR /app
# Install build dependencies
RUN apt-get update && apt-get install -y \
python3 \
make \
g++ \
git \
openssl \
&& rm -rf /var/lib/apt/lists/*
# Copy package files
COPY package.json yarn.lock ./
COPY .yarnrc.yml ./
COPY .yarn ./.yarn
# Install dependencies
RUN yarn install --immutable
# Copy source code
COPY . .
# Build the application
ENV SKIP_ENV_VALIDATION=1
ENV NEXTAUTH_SECRET=build-time-secret
ENV DATABASE_URL=file:build.sqlite
RUN yarn build
# Production stage
FROM node:20.2.0-slim
WORKDIR /app
# Define node.js environment variables
ARG PORT=7575
ENV NEXT_TELEMETRY_DISABLED=1
ENV NODE_ENV=production
ENV NODE_OPTIONS='--no-experimental-fetch'
# Copy built application from builder
COPY --from=builder /app/next.config.js ./
COPY --from=builder /app/public ./public
COPY --from=builder /app/package.json ./temp_package.json
COPY --from=builder /app/yarn.lock ./temp_yarn.lock
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
COPY --from=builder /app/scripts/run.sh ./scripts/run.sh
COPY --from=builder /app/drizzle ./drizzle
COPY --from=builder /app/drizzle/migrate ./migrate
COPY --from=builder /app/tsconfig.json ./migrate/tsconfig.json
COPY --from=builder /app/cli ./cli
RUN chmod +x ./scripts/run.sh
RUN mkdir -p /data
# Install runtime dependencies
RUN apt-get update && apt-get install -y openssl wget && rm -rf /var/lib/apt/lists/*
# Move node_modules to temp location to avoid overwriting
RUN mv node_modules _node_modules
RUN rm package.json
# Install dependencies for migration
RUN cp ./migrate/package.json ./package.json
RUN yarn install --production=false
# Copy better_sqlite3 build for current platform
RUN cp /app/node_modules/better-sqlite3/build/Release/better_sqlite3.node /app/_node_modules/better-sqlite3/build/Release/better_sqlite3.node || true
# Copy node_modules for migration to migrate folder
RUN mv node_modules ./migrate/node_modules
# Restore app node_modules
RUN mv _node_modules node_modules
# Setup CLI
RUN echo '#!/bin/bash\nnode /app/cli/cli.js "$@"' > /usr/bin/homarr
RUN chmod +x /usr/bin/homarr
RUN cd /app/cli && yarn install --production || true
# Expose the default application port
EXPOSE $PORT
ENV PORT=${PORT}
# Environment defaults
ENV DATABASE_URL="file:/data/db.sqlite"
ENV AUTH_TRUST_HOST="true"
ENV PORT=7575
ENV NEXTAUTH_SECRET=NOT_IN_USE_BECAUSE_JWTS_ARE_UNUSED
# Health check
HEALTHCHECK --interval=10s --timeout=5s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:${PORT} || exit 1
VOLUME [ "/app/data/configs" ]
VOLUME [ "/data" ]
ENTRYPOINT ["sh", "./scripts/run.sh"]