37 lines
989 B
Docker
37 lines
989 B
Docker
# ref: https://khromov.se/dockerizing-your-sveltekit-applications-a-practical-guide/
|
|
#
|
|
# Use this image as the platform to build the app
|
|
FROM node:22-alpine AS builder
|
|
|
|
# A small line inside the image to show who made it
|
|
LABEL Developers="Dave Lane, dave@laneventures.nz"
|
|
|
|
# The WORKDIR instruction sets the working directory for everything that will happen next
|
|
WORKDIR /app
|
|
|
|
# Copy all local files into the image
|
|
COPY package*.json .
|
|
|
|
# Clean install all node modules
|
|
RUN npm ci
|
|
|
|
COPY . .
|
|
|
|
# Build SvelteKit app
|
|
RUN npm run build
|
|
|
|
RUN npm prune --production
|
|
|
|
FROM node:22-alpine
|
|
WORKDIR /app
|
|
COPY --from=builder /app/build build/
|
|
COPY --from=builder /app/node_modules node_modules/
|
|
COPY package.json .
|
|
EXPOSE 5050
|
|
ENV NODE_ENV=production
|
|
# The USER instruction sets the user name to use as the default user for the remainder of the current stage
|
|
USER node:node
|
|
# This is the command that will be run inside the image when you tell Docker to start the container
|
|
CMD [ "node", "build" ]
|
|
|
|
|