docker: update dockerfile to use pnpm features
This commit is contained in:
parent
c751837ed8
commit
985f6e385d
2 changed files with 42 additions and 11 deletions
21
.dockerignore
Normal file
21
.dockerignore
Normal file
|
@ -0,0 +1,21 @@
|
|||
# OS directory info files
|
||||
.DS_Store
|
||||
desktop.ini
|
||||
|
||||
# node
|
||||
node_modules
|
||||
|
||||
# static build
|
||||
build
|
||||
|
||||
# secrets
|
||||
.env
|
||||
.env.*
|
||||
!.env.example
|
||||
cookies.json
|
||||
|
||||
# docker
|
||||
docker-compose.yml
|
||||
|
||||
# ide
|
||||
.vscode
|
30
Dockerfile
30
Dockerfile
|
@ -1,15 +1,25 @@
|
|||
FROM node:18-bullseye-slim
|
||||
FROM node:20-bullseye-slim AS base
|
||||
ENV PNPM_HOME="/pnpm"
|
||||
ENV PATH="$PNPM_HOME:$PATH"
|
||||
|
||||
FROM base AS build
|
||||
WORKDIR /app
|
||||
COPY . /app
|
||||
|
||||
RUN corepack enable
|
||||
RUN apt-get update && \
|
||||
apt-get install -y python3 build-essential
|
||||
|
||||
RUN --mount=type=cache,id=pnpm,target=/pnpm/store \
|
||||
pnpm install --prod --frozen-lockfile
|
||||
|
||||
RUN pnpm deploy --filter=@imput/cobalt-api --prod /prod/api
|
||||
|
||||
FROM base AS api
|
||||
WORKDIR /app
|
||||
|
||||
COPY package*.json ./
|
||||
COPY --from=build /prod/api /app
|
||||
COPY --from=build /app/.git /app/.git
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -y git python3 build-essential && \
|
||||
npm ci && \
|
||||
npm cache clean --force && \
|
||||
apt purge --autoremove -y python3 build-essential && \
|
||||
rm -rf ~/.cache/ /var/lib/apt/lists/*
|
||||
|
||||
COPY . .
|
||||
EXPOSE 9000
|
||||
CMD [ "node", "src/cobalt" ]
|
Loading…
Reference in a new issue