Add Docker deployment for Unraid
Some checks failed
Master CI / yarn_install_and_build (push) Has been cancelled
Some checks failed
Master CI / yarn_install_and_build (push) Has been cancelled
- 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>
This commit is contained in:
105
Dockerfile.unraid
Normal file
105
Dockerfile.unraid
Normal file
@@ -0,0 +1,105 @@
|
||||
# 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"]
|
||||
34
docker-compose.unraid.yml
Normal file
34
docker-compose.unraid.yml
Normal file
@@ -0,0 +1,34 @@
|
||||
version: "3.8"
|
||||
|
||||
services:
|
||||
homarr-unraid:
|
||||
image: git.xtrm-lab.org/jazzymc/homarr:latest
|
||||
container_name: homarr-unraid-ui
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "7576:7575"
|
||||
environment:
|
||||
# Unraid API Configuration
|
||||
- UNRAID_HOST=192.168.10.20
|
||||
- UNRAID_API_KEY=${UNRAID_API_KEY}
|
||||
- UNRAID_USE_SSL=false
|
||||
- UNRAID_PORT=80
|
||||
# App Configuration
|
||||
- TZ=Europe/Sofia
|
||||
- DATABASE_URL=file:/data/db.sqlite
|
||||
- AUTH_TRUST_HOST=true
|
||||
- NEXTAUTH_URL=http://192.168.10.20:7576
|
||||
- NEXTAUTH_SECRET=${NEXTAUTH_SECRET:-changeme}
|
||||
volumes:
|
||||
- /mnt/user/appdata/homarr-unraid/data:/data
|
||||
- /mnt/user/appdata/homarr-unraid/configs:/app/data/configs
|
||||
networks:
|
||||
- unraid-net
|
||||
labels:
|
||||
- "net.unraid.docker.managed=true"
|
||||
- "net.unraid.docker.icon=https://homarr.dev/img/logo.png"
|
||||
- "net.unraid.docker.webui=http://[IP]:[PORT:7576]"
|
||||
|
||||
networks:
|
||||
unraid-net:
|
||||
driver: bridge
|
||||
@@ -21,7 +21,7 @@ module.exports = withBundleAnalyzer({
|
||||
redirects: async () => [
|
||||
{
|
||||
source: '/',
|
||||
destination: '/board',
|
||||
destination: '/unraid',
|
||||
permanent: false,
|
||||
},
|
||||
],
|
||||
|
||||
45
scripts/build-and-push.sh
Executable file
45
scripts/build-and-push.sh
Executable file
@@ -0,0 +1,45 @@
|
||||
#!/bin/bash
|
||||
# Build and push Homarr Unraid UI to Gitea registry
|
||||
# Uses multi-stage Dockerfile to build inside Docker
|
||||
|
||||
set -e
|
||||
|
||||
REGISTRY="git.xtrm-lab.org"
|
||||
IMAGE_NAME="jazzymc/homarr"
|
||||
TAG="${1:-latest}"
|
||||
|
||||
echo "=== Building Homarr Unraid UI ==="
|
||||
echo "Using multi-stage Docker build (no local dependencies required)"
|
||||
echo ""
|
||||
|
||||
# Build Docker image using the multi-stage Dockerfile
|
||||
echo "Building Docker image (this may take 5-10 minutes)..."
|
||||
docker build -f Dockerfile.unraid -t "${REGISTRY}/${IMAGE_NAME}:${TAG}" .
|
||||
|
||||
# Login to Gitea registry (if not already logged in)
|
||||
echo ""
|
||||
echo "Logging into Gitea registry..."
|
||||
docker login "${REGISTRY}" || echo "Already logged in or use: docker login ${REGISTRY}"
|
||||
|
||||
# Push to registry
|
||||
echo ""
|
||||
echo "Pushing to registry..."
|
||||
docker push "${REGISTRY}/${IMAGE_NAME}:${TAG}"
|
||||
|
||||
echo ""
|
||||
echo "=== Build Complete ==="
|
||||
echo "Image: ${REGISTRY}/${IMAGE_NAME}:${TAG}"
|
||||
echo ""
|
||||
echo "To deploy on Unraid:"
|
||||
echo "1. SSH to Unraid: ssh root@192.168.10.20 -p 422"
|
||||
echo "2. Create directory: mkdir -p /mnt/user/appdata/homarr-unraid/{data,configs}"
|
||||
echo "3. Pull image: docker pull ${REGISTRY}/${IMAGE_NAME}:${TAG}"
|
||||
echo "4. Run container:"
|
||||
echo " docker run -d \\"
|
||||
echo " --name homarr-unraid-ui \\"
|
||||
echo " -p 7576:7575 \\"
|
||||
echo " -e UNRAID_HOST=192.168.10.20 \\"
|
||||
echo " -e UNRAID_API_KEY=YOUR_API_KEY \\"
|
||||
echo " -v /mnt/user/appdata/homarr-unraid/data:/data \\"
|
||||
echo " -v /mnt/user/appdata/homarr-unraid/configs:/app/data/configs \\"
|
||||
echo " ${REGISTRY}/${IMAGE_NAME}:${TAG}"
|
||||
Reference in New Issue
Block a user