Skip to content

Commit

Permalink
fix dockerfile and dockerignore
Browse files Browse the repository at this point in the history
  • Loading branch information
kylegalbraith committed Sep 22, 2023
1 parent dd5d6a3 commit 04e275f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 24 deletions.
6 changes: 6 additions & 0 deletions node/pnpm-fastify/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules
Dockerfile
.git
.gitignore
dist/**
README.md
36 changes: 12 additions & 24 deletions node/pnpm-fastify/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,39 +1,27 @@
FROM node:20-slim as base
FROM node:20 AS base

ENV PNPM_HOME="/root/.local/share/pnpm"
ENV PATH="${PATH}:${PNPM_HOME}"
FROM base AS deps

RUN corepack enable
RUN pnpm add -g fastify-cli

FROM base as dependencies

WORKDIR /app
COPY package.json pnpm-lock.yaml tsconfig.json ./
RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store pnpm fetch --frozen-lockfile --prod
COPY package.json pnpm-lock.yaml ./
RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store pnpm fetch --frozen-lockfile
RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store pnpm install --frozen-lockfile --prod

FROM base as build
FROM base AS build

RUN corepack enable
WORKDIR /app
COPY package.json pnpm-lock.yaml tsconfig.json ./
COPY package.json pnpm-lock.yaml ./
RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store pnpm fetch --frozen-lockfile
RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store pnpm install --frozen-lockfile
COPY src/ ./src
RUN pnpm build:ts
COPY . .
RUN pnpm build

FROM base

WORKDIR /app
COPY --from=dependencies /app/node_modules /app/node_modules
COPY --from=deps /app/node_modules /app/node_modules
COPY --from=build /app/dist /app/dist
EXPOSE 3000
CMD ["fastify", "start", "-l", "info", "dist/app.js"]

#FROM node:20-slim as build
#
#RUN corepack enable
#WORKDIR /app
#COPY package.json pnpm-lock.yaml ./
#RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store pnpm fetch --frozen-lockfile
#RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store pnpm install --frozen-lockfile --prod
ENV NODE_ENV production
CMD ["node", "./dist/index.js"]

0 comments on commit 04e275f

Please sign in to comment.