Skip to content

Commit

Permalink
reduce docker image size
Browse files Browse the repository at this point in the history
  • Loading branch information
Aituglo committed Oct 28, 2024
1 parent b6d7403 commit fecff54
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 29 deletions.
27 changes: 11 additions & 16 deletions gateway/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,35 +1,30 @@
FROM node:18-alpine AS development

FROM node:18-alpine AS base
WORKDIR /gateway

FROM base AS deps

COPY package.json ./
COPY yarn.lock ./

RUN yarn install
RUN yarn install --immutable --immutable-cache --check-cache

FROM deps AS build

COPY . .

RUN yarn prisma:generate
RUN yarn build

CMD ["yarn", "start:dev"]

FROM node:18-alpine AS build

WORKDIR /gateway

COPY package.json ./
COPY yarn.lock ./

RUN yarn install --immutable --immutable-cache --check-cache
FROM base AS development

COPY --from=deps /gateway/node_modules /gateway/node_modules
COPY . .

RUN yarn prisma:generate
RUN yarn build

FROM build AS production
CMD ["yarn", "start:dev"]

WORKDIR /gateway
FROM base AS production

COPY --from=build /gateway/dist ./dist
COPY --from=build /gateway/node_modules ./node_modules
Expand Down
24 changes: 11 additions & 13 deletions web/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
FROM node:18-alpine AS development

FROM node:18-alpine AS base
WORKDIR /web

FROM base AS deps

COPY package.json ./
COPY yarn.lock ./

RUN yarn install
RUN yarn install --immutable --immutable-cache --check-cache

COPY . .
FROM deps AS build

CMD ["yarn", "dev"]
COPY . .

FROM node:18-alpine AS build
RUN yarn build

WORKDIR /web
FROM base AS development

COPY package.json ./
COPY yarn.lock ./
RUN yarn install --immutable --immutable-cache --check-cache
COPY --from=build /web/node_modules /web/node_modules

COPY . .

RUN yarn build
CMD ["yarn", "dev"]

FROM build AS production
FROM base AS production

WORKDIR /web
COPY --from=build /web/.next/standalone /web/build
RUN mkdir -p /web/build/.next
COPY --from=build /web/.next/static /web/build/.next/static
Expand Down

0 comments on commit fecff54

Please sign in to comment.