mirror of
https://github.com/nicetry247/offlineacademy.git
synced 2026-07-26 11:58:44 +00:00
build: fix Docker image build and add Docker Hub compose
This commit is contained in:
+19
-1
@@ -6,7 +6,16 @@
|
|||||||
FROM node:22-bookworm-slim AS deps
|
FROM node:22-bookworm-slim AS deps
|
||||||
WORKDIR /app
|
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 package.json package-lock.json ./
|
||||||
|
COPY prisma ./prisma
|
||||||
RUN npm ci --no-audit --no-fund
|
RUN npm ci --no-audit --no-fund
|
||||||
|
|
||||||
# -----------------------------
|
# -----------------------------
|
||||||
@@ -17,7 +26,13 @@ WORKDIR /app
|
|||||||
|
|
||||||
ENV NEXT_TELEMETRY_DISABLED=1
|
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/node_modules ./node_modules
|
||||||
|
COPY --from=deps /app/package.json ./package.json
|
||||||
|
COPY --from=deps /app/package-lock.json ./package-lock.json
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
RUN npx prisma generate
|
RUN npx prisma generate
|
||||||
@@ -34,7 +49,10 @@ ENV NEXT_TELEMETRY_DISABLED=1
|
|||||||
ENV PORT=6767
|
ENV PORT=6767
|
||||||
ENV HOSTNAME=0.0.0.0
|
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
|
&& useradd --system --uid 1001 --gid nodejs nextjs
|
||||||
|
|
||||||
# Next.js standalone output
|
# Next.js standalone output
|
||||||
|
|||||||
@@ -231,30 +231,17 @@ http://localhost:6767
|
|||||||
|
|
||||||
Docker is the recommended deployment path for most users.
|
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
|
```bash
|
||||||
git clone https://github.com/YOUR_USERNAME/offlineacademy.git
|
mkdir -p offlineacademy/My_Courses offlineacademy/prisma
|
||||||
cd offlineacademy
|
cd offlineacademy
|
||||||
```
|
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
|
||||||
### 2. Create `.env`
|
|
||||||
|
|
||||||
```bash
|
|
||||||
cp .env.example .env
|
|
||||||
```
|
|
||||||
|
|
||||||
### 3. Create local folders
|
|
||||||
|
|
||||||
```bash
|
|
||||||
mkdir -p My_Courses prisma
|
|
||||||
touch prisma/dev.db
|
touch prisma/dev.db
|
||||||
```
|
docker compose up -d
|
||||||
|
|
||||||
### 4. Start the app
|
|
||||||
|
|
||||||
```bash
|
|
||||||
docker compose up --build -d
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Open:
|
Open:
|
||||||
@@ -269,9 +256,20 @@ For LAN access, replace `localhost` with your server IP:
|
|||||||
http://YOUR_SERVER_IP:6767
|
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
|
### 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
|
```yaml
|
||||||
volumes:
|
volumes:
|
||||||
@@ -292,6 +290,25 @@ Examples:
|
|||||||
- C:/Users/you/Videos/Courses:/app/My_Courses
|
- 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
|
## Configuration
|
||||||
|
|||||||
@@ -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
|
||||||
Reference in New Issue
Block a user