diff --git a/Dockerfile b/Dockerfile index 0ec5322..09a2e39 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,16 @@ FROM node:22-bookworm-slim AS deps WORKDIR /app +ENV NEXT_TELEMETRY_DISABLED=1 + +# Prisma needs OpenSSL available during generate. +RUN apt-get update \ + && apt-get install -y --no-install-recommends openssl ca-certificates \ + && rm -rf /var/lib/apt/lists/* + +# Copy Prisma schema before npm ci because package.json postinstall runs `prisma generate`. COPY package.json package-lock.json ./ +COPY prisma ./prisma RUN npm ci --no-audit --no-fund # ----------------------------- @@ -17,7 +26,13 @@ WORKDIR /app ENV NEXT_TELEMETRY_DISABLED=1 +RUN apt-get update \ + && apt-get install -y --no-install-recommends openssl ca-certificates \ + && rm -rf /var/lib/apt/lists/* + COPY --from=deps /app/node_modules ./node_modules +COPY --from=deps /app/package.json ./package.json +COPY --from=deps /app/package-lock.json ./package-lock.json COPY . . RUN npx prisma generate @@ -34,7 +49,10 @@ ENV NEXT_TELEMETRY_DISABLED=1 ENV PORT=6767 ENV HOSTNAME=0.0.0.0 -RUN groupadd --system --gid 1001 nodejs \ +RUN apt-get update \ + && apt-get install -y --no-install-recommends openssl ca-certificates \ + && rm -rf /var/lib/apt/lists/* \ + && groupadd --system --gid 1001 nodejs \ && useradd --system --uid 1001 --gid nodejs nextjs # Next.js standalone output diff --git a/README.md b/README.md index 69cacb4..e508cad 100644 --- a/README.md +++ b/README.md @@ -231,30 +231,17 @@ http://localhost:6767 Docker is the recommended deployment path for most users. -### 1. Clone the repository +### Option A: Use the published Docker Hub image + +After the image is published to Docker Hub, users can run OfflineAcademy without building from source. ```bash -git clone https://github.com/YOUR_USERNAME/offlineacademy.git +mkdir -p offlineacademy/My_Courses offlineacademy/prisma cd offlineacademy -``` - -### 2. Create `.env` - -```bash -cp .env.example .env -``` - -### 3. Create local folders - -```bash -mkdir -p My_Courses prisma +curl -fsSL -o docker-compose.yml https://raw.githubusercontent.com/nicetry247/offlineacademy/main/docker-compose.hub.yml +curl -fsSL -o .env https://raw.githubusercontent.com/nicetry247/offlineacademy/main/.env.example touch prisma/dev.db -``` - -### 4. Start the app - -```bash -docker compose up --build -d +docker compose up -d ``` Open: @@ -269,9 +256,20 @@ For LAN access, replace `localhost` with your server IP: http://YOUR_SERVER_IP:6767 ``` +### Option B: Build locally from source + +```bash +git clone https://github.com/nicetry247/offlineacademy.git +cd offlineacademy +cp .env.example .env +mkdir -p My_Courses prisma +touch prisma/dev.db +docker compose up --build -d +``` + ### Custom Course Folder -You can store courses anywhere on the host. Update `docker-compose.yml` and map your folder to `/app/My_Courses` inside the container: +You can store courses anywhere on the host. Update your Compose file and map your folder to `/app/My_Courses` inside the container: ```yaml volumes: @@ -292,6 +290,25 @@ Examples: - C:/Users/you/Videos/Courses:/app/My_Courses ``` +### Publishing to Docker Hub + +Maintainers can publish manually: + +```bash +docker login +docker build -t nicetry247/offlineacademy:latest . +docker push nicetry247/offlineacademy:latest +``` + +You can also automate Docker Hub publishing later with GitHub Actions. To do that, add repository secrets for: + +```text +DOCKERHUB_USERNAME +DOCKERHUB_TOKEN +``` + +Then add a workflow that builds and pushes `nicetry247/offlineacademy:latest` on pushes to `main` and version tags like `v1.0.0`. + --- ## Configuration diff --git a/docker-compose.hub.yml b/docker-compose.hub.yml new file mode 100644 index 0000000..2cd9567 --- /dev/null +++ b/docker-compose.hub.yml @@ -0,0 +1,23 @@ +services: + offlineacademy: + image: nicetry247/offlineacademy:latest + container_name: offlineacademy + restart: unless-stopped + ports: + - "6767:6767" + env_file: + - .env + environment: + NODE_ENV: production + PORT: 6767 + HOSTNAME: 0.0.0.0 + DATABASE_URL: file:./dev.db + COURSES_ROOT: ./My_Courses + NEXT_PUBLIC_APP_URL: http://localhost:6767 + volumes: + # Put your course folders wherever you want on the host, + # then map that folder to /app/My_Courses inside the container. + - ./My_Courses:/app/My_Courses + + # Persist the SQLite database outside the image. + - ./prisma/dev.db:/app/prisma/dev.db