feat: leverage next standalone output for smaller image size

This commit is contained in:
Nicolas Meienberger 2022-10-15 11:54:45 +02:00
parent 440cf635c3
commit 84ceb52088
6 changed files with 18 additions and 16 deletions

View file

@ -5,5 +5,8 @@
node_modules
.next
dist/
**/dist/
**/next/
# all docker-compose files
docker-compose*.yml
Dockerfile*
.dockerignore

View file

@ -1,4 +1,4 @@
FROM node:18 AS build
FROM node:18 AS builder
RUN npm install node-gyp -g
@ -35,13 +35,13 @@ WORKDIR /api
COPY ./packages/system-api/package*.json /api/
RUN npm install --omit=dev
COPY --from=builder /api/dist /api/dist
WORKDIR /dashboard
COPY ./packages/dashboard/package*.json /dashboard/
RUN npm install --omit=dev
COPY --from=build /api/dist /api/dist
COPY --from=build /dashboard/.next /dashboard/.next
COPY ./packages/dashboard /dashboard
COPY --from=builder /dashboard/next.config.js ./
COPY --from=builder /dashboard/public ./public
COPY --from=builder /dashboard/package.json ./package.json
COPY --from=builder --chown=node:node /dashboard/.next/standalone ./
COPY --from=builder --chown=node:node /dashboard/.next/static ./.next/static
WORKDIR /

View file

@ -85,7 +85,7 @@ services:
dashboard:
image: meienberger/runtipi:rc-${TIPI_VERSION}
command: /bin/sh -c "cd /dashboard && npm run start"
command: /bin/sh -c "cd /dashboard && node server.js"
container_name: dashboard
networks:
- tipi_main_network

View file

@ -85,7 +85,7 @@ services:
dashboard:
image: meienberger/runtipi:${TIPI_VERSION}
command: /bin/sh -c "cd /dashboard && npm run start"
command: /bin/sh -c "cd /dashboard && node server.js"
restart: unless-stopped
container_name: dashboard
networks:

View file

@ -1,7 +1,6 @@
/** @type {import('next').NextConfig} */
const { INTERNAL_IP, DOMAIN, NGINX_PORT } = process.env;
const nextConfig = {
output: 'standalone',
webpackDevMiddleware: (config) => {
config.watchOptions = {
poll: 1000,

View file

@ -1,6 +1,6 @@
{
"name": "dashboard",
"version": "0.7.0",
"version": "0.7.1",
"private": true,
"scripts": {
"test": "jest --colors",
@ -22,7 +22,7 @@
"framer-motion": "^6",
"graphql": "^15.8.0",
"graphql-tag": "^2.12.6",
"next": "12.1.6",
"next": "12.3.1",
"react": "18.1.0",
"react-dom": "18.1.0",
"react-final-form": "^6.5.9",