From 2f90e3f1a2800abe86ae71180bdbdcf92b14b829 Mon Sep 17 00:00:00 2001 From: WanQuanXie Date: Wed, 8 May 2024 18:07:39 +0800 Subject: [PATCH] build(app): optimize app docker image size export app static pages and deploy with Nginx image, instead of host `next start` service --- app.dockerfile | 6 ++++-- docker-compose.yaml | 2 +- ui/next.config.mjs | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app.dockerfile b/app.dockerfile index 105cf86..9452f94 100644 --- a/app.dockerfile +++ b/app.dockerfile @@ -1,4 +1,4 @@ -FROM node:alpine +FROM node:alpine as builder ARG NEXT_PUBLIC_WS_URL ARG NEXT_PUBLIC_API_URL @@ -12,4 +12,6 @@ COPY ui /home/perplexica/ RUN yarn install RUN yarn build -CMD ["yarn", "start"] \ No newline at end of file +FROM nginx:stable-alpine-slim + +COPY --from=builder /home/perplexica/out /usr/share/nginx/html \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml index 5eef31e..61c7138 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -31,7 +31,7 @@ services: depends_on: - perplexica-backend ports: - - 3000:3000 + - 3000:80 networks: - perplexica-network diff --git a/ui/next.config.mjs b/ui/next.config.mjs index c3f2e1a..b099816 100644 --- a/ui/next.config.mjs +++ b/ui/next.config.mjs @@ -1,5 +1,6 @@ /** @type {import('next').NextConfig} */ const nextConfig = { + output: 'export', images: { remotePatterns: [ {