2024-11-26 15:58:38 +13:00
|
|
|
# ref: https://khromov.se/dockerizing-your-sveltekit-applications-a-practical-guide/
|
|
|
|
#
|
2024-08-29 11:40:28 +12:00
|
|
|
# Use this image as the platform to build the app
|
2024-11-26 15:58:38 +13:00
|
|
|
FROM node:22-alpine AS builder
|
2024-08-16 17:01:16 +12:00
|
|
|
|
2024-08-29 11:40:28 +12:00
|
|
|
# A small line inside the image to show who made it
|
|
|
|
LABEL Developers="Dave Lane, dave@laneventures.nz"
|
2024-08-16 17:01:16 +12:00
|
|
|
|
2024-08-29 11:40:28 +12:00
|
|
|
# The WORKDIR instruction sets the working directory for everything that will happen next
|
2024-08-16 17:01:16 +12:00
|
|
|
WORKDIR /app
|
|
|
|
|
2024-08-29 11:40:28 +12:00
|
|
|
# Copy all local files into the image
|
2024-11-26 15:58:38 +13:00
|
|
|
COPY package*.json .
|
2024-08-16 17:01:16 +12:00
|
|
|
|
2024-08-29 11:40:28 +12:00
|
|
|
# Clean install all node modules
|
|
|
|
RUN npm ci
|
|
|
|
|
2024-11-26 15:58:38 +13:00
|
|
|
COPY . .
|
|
|
|
|
2024-08-29 11:40:28 +12:00
|
|
|
# Build SvelteKit app
|
|
|
|
RUN npm run build
|
|
|
|
|
2024-11-26 15:58:38 +13:00
|
|
|
RUN npm prune --production
|
2024-08-29 11:40:28 +12:00
|
|
|
|
2024-11-26 15:58:38 +13:00
|
|
|
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
|
2024-08-29 11:40:28 +12:00
|
|
|
# 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
|
2024-11-26 15:58:38 +13:00
|
|
|
CMD [ "node", "build" ]
|
|
|
|
|
|
|
|
|