mirror of
https://github.com/Roslund/meshtastic-map.git
synced 2026-03-28 17:43:03 +01:00
Optimize Dockerfile with multi-stage build
Also: * Skips installing dev dependencies * Runs as non root
This commit is contained in:
14
Dockerfile
14
Dockerfile
@@ -1,16 +1,24 @@
|
||||
FROM node:lts-alpine
|
||||
FROM node:lts-alpine AS build
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy only package files and install deps
|
||||
# This layer will be cached as long as package*.json don't change
|
||||
COPY package*.json package-lock.json* ./
|
||||
RUN npm ci
|
||||
RUN --mount=type=cache,target=/root/.npm npm ci --omit=dev
|
||||
|
||||
# Copy the rest of your source
|
||||
COPY . .
|
||||
|
||||
FROM node:lts-alpine
|
||||
|
||||
RUN apk add --no-cache openssl
|
||||
|
||||
USER node:node
|
||||
|
||||
EXPOSE 8080
|
||||
WORKDIR /app
|
||||
|
||||
COPY --from=build /app .
|
||||
|
||||
|
||||
EXPOSE 8080
|
||||
Reference in New Issue
Block a user