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 oven/bun:latest AS base
|
||||||
FROM node:20-alpine AS dev
|
|
||||||
|
|
||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
COPY --chown=node:node package*.json ./
|
# Install deps into tmp dir
|
||||||
COPY --chown=node:node prisma ./prisma/
|
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 . .
|
# Copy node_modules from temp directory
|
||||||
|
FROM base AS prerelase
|
||||||
USER node
|
COPY --from=install /temp/dev/node_modules node_modules
|
||||||
|
COPY --from=install /temp/dev/docker.env .env
|
||||||
# BUILD
|
COPY . .
|
||||||
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
|
|
||||||
|
|
||||||
ENV NODE_ENV production
|
ENV NODE_ENV production
|
||||||
|
|
||||||
RUN npm ci --only=production && npm cache clean --force
|
RUN bun migrate:deploy
|
||||||
|
|
||||||
USER node
|
RUN bun run build
|
||||||
|
|
||||||
# PROD
|
# Copy production deps
|
||||||
FROM node:20-alpine as production
|
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
|
CMD [ "bun", "dist/main.js" ]
|
||||||
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"]
|
|
|
@ -5,6 +5,8 @@ networks:
|
||||||
minio_network:
|
minio_network:
|
||||||
name: minio_network
|
name: minio_network
|
||||||
driver: bridge
|
driver: bridge
|
||||||
|
backend-network:
|
||||||
|
driver: bridge
|
||||||
|
|
||||||
services:
|
services:
|
||||||
postgres:
|
postgres:
|
||||||
|
@ -17,6 +19,8 @@ services:
|
||||||
- docker.env
|
- docker.env
|
||||||
volumes:
|
volumes:
|
||||||
- postgres:/var/lib/postgresql/data
|
- postgres:/var/lib/postgresql/data
|
||||||
|
networks:
|
||||||
|
- backend-network
|
||||||
|
|
||||||
minio:
|
minio:
|
||||||
image: bitnami/minio
|
image: bitnami/minio
|
||||||
|
@ -40,6 +44,8 @@ services:
|
||||||
command: redis-server --save 20 1 --loglevel warning --requirepass not_a_production_pass
|
command: redis-server --save 20 1 --loglevel warning --requirepass not_a_production_pass
|
||||||
volumes:
|
volumes:
|
||||||
- redis:/data
|
- redis:/data
|
||||||
|
networks:
|
||||||
|
- backend-network
|
||||||
|
|
||||||
api:
|
api:
|
||||||
container_name: api
|
container_name: api
|
||||||
|
@ -55,6 +61,8 @@ services:
|
||||||
- minio
|
- minio
|
||||||
env_file:
|
env_file:
|
||||||
- docker.env
|
- docker.env
|
||||||
|
networks:
|
||||||
|
- backend-network
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
postgres:
|
postgres:
|
||||||
|
|
Loading…
Reference in a new issue