Skip to content

Commit

Permalink
Prune npm dev dependencies after build
Browse files Browse the repository at this point in the history
  • Loading branch information
Radiokot committed Dec 3, 2023
1 parent ab03421 commit 50a4b24
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
# use LTS Node image to use as a builder
FROM node:18.18-buster-slim AS builder
# use Node 18 image as a builder
FROM 18-alpine AS builder

# work under the /app directory
WORKDIR /app

# copy files required to install dependencies first
COPY package.json package-lock.json svelte.config.js ./

# install the dependencies for production
RUN npm i -p
# install the dependencies, including dev ones.
# SvelteKit package itself is a dev dependency and we need it for building the app.
RUN npm ci

# copy all the sources
COPY . .

# build the app
RUN npm run build

# delete all the dev dependencies from the "node_modules",
# they are no longer needed.
RUN npm prune --production

# take the distroless Node 18 image
FROM gcr.io/distroless/nodejs18-debian11

Expand Down

0 comments on commit 50a4b24

Please sign in to comment.