mirror of
https://github.com/hknsh/project-knedita.git
synced 2024-11-28 17:41:15 +00:00
feat: changed npm to bun in docker
This commit is contained in:
parent
8e7be25088
commit
c88b6d7577
2 changed files with 37 additions and 41 deletions
68
Dockerfile
68
Dockerfile
|
@ -1,50 +1,38 @@
|
|||
# LOCAL
|
||||
FROM node:20-alpine AS dev
|
||||
|
||||
FROM oven/bun:latest AS base
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
COPY --chown=node:node package*.json ./
|
||||
COPY --chown=node:node prisma ./prisma/
|
||||
# Install deps into tmp dir
|
||||
FROM base AS install
|
||||
RUN mkdir -p /temp/dev
|
||||
COPY package.json bun.lockb docker.env /temp/dev/
|
||||
RUN cd /temp/dev && bun install --frozen-lockfile
|
||||
|
||||
RUN npm ci
|
||||
# Install without dev deps
|
||||
RUN mkdir -p /temp/prod
|
||||
COPY package.json bun.lockb /temp/prod/
|
||||
COPY .husky/ /temp/prod/.husky/
|
||||
RUN bun install husky -g
|
||||
RUN cd /temp/prod && bun install --frozen-lockfile --production
|
||||
|
||||
COPY --chown=node:node . .
|
||||
|
||||
USER node
|
||||
|
||||
# BUILD
|
||||
FROM node:20-alpine AS build
|
||||
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
COPY --chown=node:node package*.json ./
|
||||
COPY --chown=node:node --from=dev /usr/src/app/node_modules ./node_modules
|
||||
COPY --chown=node:node --from=dev /usr/src/app/prisma ./prisma/
|
||||
COPY --chown=node:node .husky ./.husky
|
||||
COPY --chown=node:node tsconfig.json tsconfig.build.json ./
|
||||
COPY --chown=node:node docker.env ./.env
|
||||
COPY --chown=node:node . .
|
||||
|
||||
RUN npm install husky -g
|
||||
|
||||
RUN npm run prisma:generate
|
||||
|
||||
RUN npm run build
|
||||
# Copy node_modules from temp directory
|
||||
FROM base AS prerelase
|
||||
COPY --from=install /temp/dev/node_modules node_modules
|
||||
COPY --from=install /temp/dev/docker.env .env
|
||||
COPY . .
|
||||
|
||||
ENV NODE_ENV production
|
||||
|
||||
RUN npm ci --only=production && npm cache clean --force
|
||||
RUN bun migrate:deploy
|
||||
|
||||
USER node
|
||||
RUN bun run build
|
||||
|
||||
# PROD
|
||||
FROM node:20-alpine as production
|
||||
# Copy production deps
|
||||
FROM base AS release
|
||||
COPY --from=install /temp/prod/node_modules node_modules
|
||||
COPY --from=prerelase /usr/src/app/dist dist
|
||||
COPY --from=prerelase /usr/src/app/prisma prisma
|
||||
COPY --from=prerelase /usr/src/app/.husky ./.husky
|
||||
COPY --from=prerelase /usr/src/app/.env ./.env
|
||||
COPY --from=prerelase /usr/src/app/package*.json ./
|
||||
|
||||
COPY --chown=node:node --from=build /usr/src/app/node_modules ./node_modules
|
||||
COPY --chown=node:node --from=build /usr/src/app/dist ./dist
|
||||
COPY --chown=node:node --from=build /usr/src/app/prisma ./prisma
|
||||
COPY --chown=node:node --from=build /usr/src/app/.husky ./.husky
|
||||
COPY --chown=node:node --from=build /usr/src/app/.env ./
|
||||
COPY --chown=node:node --from=build /usr/src/app/package*.json ./
|
||||
|
||||
CMD ["npm", "run" , "prod"]
|
||||
CMD [ "bun", "dist/main.js" ]
|
|
@ -5,7 +5,9 @@ networks:
|
|||
minio_network:
|
||||
name: minio_network
|
||||
driver: bridge
|
||||
|
||||
backend-network:
|
||||
driver: bridge
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:alpine
|
||||
|
@ -17,6 +19,8 @@ services:
|
|||
- docker.env
|
||||
volumes:
|
||||
- postgres:/var/lib/postgresql/data
|
||||
networks:
|
||||
- backend-network
|
||||
|
||||
minio:
|
||||
image: bitnami/minio
|
||||
|
@ -40,6 +44,8 @@ services:
|
|||
command: redis-server --save 20 1 --loglevel warning --requirepass not_a_production_pass
|
||||
volumes:
|
||||
- redis:/data
|
||||
networks:
|
||||
- backend-network
|
||||
|
||||
api:
|
||||
container_name: api
|
||||
|
@ -55,6 +61,8 @@ services:
|
|||
- minio
|
||||
env_file:
|
||||
- docker.env
|
||||
networks:
|
||||
- backend-network
|
||||
|
||||
volumes:
|
||||
postgres:
|
||||
|
|
Loading…
Reference in a new issue