From 69f6c90eda948748cd04196997e7976f2226cd20 Mon Sep 17 00:00:00 2001 From: thanhvudaynee Date: Sun, 17 May 2026 21:01:33 +0700 Subject: [PATCH] feat: add Docker support and implement movie detail and playback pages --- .dockerignore | 12 +++ Dockerfile | 24 ++++++ README.md | 33 +++++++- app/pages/phim/[slug].vue | 159 ++++++++++++++++++++-------------- app/pages/xem/[slug].vue | 174 ++++++++++++++++++++++++++++++++++++++ docker-compose.yml | 15 ++++ nuxt.config.ts | 4 + package-lock.json | 2 +- package.json | 6 +- 9 files changed, 361 insertions(+), 68 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 app/pages/xem/[slug].vue create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..3cc1713 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,12 @@ +.git +.nuxt +.output +.nitro +.cache +node_modules +npm-debug.log +*.log +.env +.env.* +Dockerfile +docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..054df42 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +FROM node:22-alpine AS deps +WORKDIR /app +COPY package*.json ./ +RUN npm ci + +FROM node:22-alpine AS builder +WORKDIR /app +ENV NODE_ENV=production +COPY --from=deps /app/node_modules ./node_modules +COPY . . +RUN npm run build + +FROM node:22-alpine AS runner +WORKDIR /app +ENV NODE_ENV=production +ENV HOST=0.0.0.0 +ENV PORT=3002 +ENV NITRO_HOST=0.0.0.0 +ENV NITRO_PORT=3002 + +COPY --from=builder /app/.output ./.output + +EXPOSE 3002 +CMD ["node", ".output/server/index.mjs"] diff --git a/README.md b/README.md index 4c9de81..c1641b8 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ npm run dev The app will usually be available at: ```text -http://localhost:3000 +http://localhost:3002 ``` ## Production Build @@ -75,6 +75,36 @@ Preview the production build locally: npm run preview ``` +Run the production server after building: + +```bash +npm run start +``` + +The production server listens on port `3002` by default. + +## Docker + +Build and run with Docker Compose: + +```bash +docker compose up -d --build +``` + +The container exposes the app at: + +```text +http://localhost:3002 +``` + +Stop the container: + +```bash +docker compose down +``` + +The Compose service is named `kr-phim` and maps host port `3002` to container port `3002`. + ## Available Routes - `/` - Home page with hero carousel and movie rows. @@ -101,6 +131,7 @@ If one source is unavailable, the list endpoint still returns data from the othe npm run dev # Start Nuxt development server npm run build # Build for production npm run preview # Preview the production build +npm run start # Start the built Nitro server npm run generate # Generate a static build when supported ``` diff --git a/app/pages/phim/[slug].vue b/app/pages/phim/[slug].vue index 1c78d63..68e5956 100644 --- a/app/pages/phim/[slug].vue +++ b/app/pages/phim/[slug].vue @@ -1,7 +1,8 @@