mirror of
https://github.com/kind-0/nsecbunkerd.git
synced 2025-03-17 21:32:53 +01:00
reduce Docker image size and use alpine as base
This commit is contained in:
parent
07008012de
commit
1652419cd3
34
Dockerfile
34
Dockerfile
@ -1,24 +1,42 @@
|
||||
FROM node:19-buster-slim as build
|
||||
FROM node:20-alpine AS build
|
||||
WORKDIR /app
|
||||
|
||||
RUN apt-get update -y && apt-get install -y openssl python3 build-essential make gcc
|
||||
# Install dependencies
|
||||
RUN apk update && \
|
||||
apk add --no-cache openssl python3 make g++ \
|
||||
&& ln -sf python3 /usr/bin/python
|
||||
|
||||
# Copy package files and install dependencies
|
||||
COPY package.json package-lock.json ./
|
||||
RUN npm i
|
||||
|
||||
RUN apt-get purge -y gcc make build-essential && apt-get autoremove -y
|
||||
RUN npm install
|
||||
|
||||
# Copy application files
|
||||
COPY src/ src/
|
||||
COPY scripts scripts/
|
||||
COPY scripts/ scripts/
|
||||
COPY prisma/schema.prisma prisma/
|
||||
COPY tsconfig.json ./
|
||||
|
||||
# Generate prisma client and build the application
|
||||
RUN npx prisma generate
|
||||
|
||||
RUN npm run build
|
||||
|
||||
RUN npm i
|
||||
# Runtime stage
|
||||
FROM node:20-alpine
|
||||
WORKDIR /app
|
||||
|
||||
RUN apk update && \
|
||||
apk add --no-cache openssl
|
||||
|
||||
# Copy built files from the build stage
|
||||
COPY --from=build /app .
|
||||
|
||||
# Install only runtime dependencies
|
||||
RUN npm install --only=production
|
||||
|
||||
# Copy and run migrations
|
||||
COPY --from=build /app/prisma ./prisma
|
||||
RUN npx prisma migrate deploy
|
||||
|
||||
# Set entrypoint
|
||||
ENTRYPOINT [ "node", "scripts/start.js" ]
|
||||
CMD ["start"]
|
||||
|
Loading…
x
Reference in New Issue
Block a user