From 09e2716e4645bc14adc0762d19f22f980a45b252 Mon Sep 17 00:00:00 2001 From: cdricms <36056008+cdricms@users.noreply.github.com> Date: Mon, 13 Jan 2025 21:31:01 +0100 Subject: [PATCH] Reduced docker image size --- .dockerignore | 1 + Dockerfile | 10 +++++++++- latosa-frontend/next.config.ts | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..ce2c29a --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +./latosa-frontend/node_modules/ diff --git a/Dockerfile b/Dockerfile index f32490b..cd099dd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,13 +7,21 @@ WORKDIR /app # Copy project files COPY ./latosa-frontend/ . +ENV NODE_ENV=production RUN deno install # Install Next.js dependencies RUN deno task build +# Move everything to the standalone +RUN cp -r public .next/standalone/public +RUN cp -r .next/static .next/standalone/.next/static +RUN mv .next/standalone/server.js .next/standalone/server.cjs + +RUN rm -r ./node_modules + # Expose the default Next.js port EXPOSE 3000 # Start the Next.js app -CMD ["deno", "task", "start"] +CMD ["deno", "run", "--allow-env", "--allow-read", "--allow-sys", "--allow-net", ".next/standalone/server.cjs"] diff --git a/latosa-frontend/next.config.ts b/latosa-frontend/next.config.ts index 7921f35..4119f6e 100644 --- a/latosa-frontend/next.config.ts +++ b/latosa-frontend/next.config.ts @@ -2,6 +2,7 @@ import type { NextConfig } from "next"; const nextConfig: NextConfig = { /* config options here */ + output: "standalone", }; export default nextConfig;