mirror of
https://github.com/aljazceru/nsecbunkerd.git
synced 2025-12-17 06:04:22 +01:00
Merge pull request #18 from fishcakeday/make-docker-smaller
reduce Docker image size and use alpine as base
This commit is contained in:
34
Dockerfile
34
Dockerfile
@@ -1,24 +1,42 @@
|
|||||||
FROM node:19-buster-slim as build
|
FROM node:20-alpine AS build
|
||||||
WORKDIR /app
|
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 ./
|
COPY package.json package-lock.json ./
|
||||||
RUN npm i
|
RUN npm install
|
||||||
|
|
||||||
RUN apt-get purge -y gcc make build-essential && apt-get autoremove -y
|
|
||||||
|
|
||||||
|
# Copy application files
|
||||||
COPY src/ src/
|
COPY src/ src/
|
||||||
COPY scripts scripts/
|
COPY scripts/ scripts/
|
||||||
COPY prisma/schema.prisma prisma/
|
COPY prisma/schema.prisma prisma/
|
||||||
COPY tsconfig.json ./
|
COPY tsconfig.json ./
|
||||||
|
|
||||||
|
# Generate prisma client and build the application
|
||||||
RUN npx prisma generate
|
RUN npx prisma generate
|
||||||
|
|
||||||
RUN npm run build
|
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
|
RUN npx prisma migrate deploy
|
||||||
|
|
||||||
|
# Set entrypoint
|
||||||
ENTRYPOINT [ "node", "scripts/start.js" ]
|
ENTRYPOINT [ "node", "scripts/start.js" ]
|
||||||
CMD ["start"]
|
CMD ["start"]
|
||||||
|
|||||||
Reference in New Issue
Block a user