Skip to content

Commit

Permalink
chore: docker再拆一个构建阶段
Browse files Browse the repository at this point in the history
  • Loading branch information
bangbang93 committed Aug 16, 2024
1 parent abcd0a5 commit a645ff8
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,19 @@ RUN npm ci
COPY src ./src
RUN npm run build

FROM $BASE_IMAGE AS modules
WORKDIR /opt/openbmclapi

RUN apt update && \
apt install -y build-essential python3
COPY package-lock.json package.json ./
RUN npm ci --omit=dev

FROM $BASE_IMAGE AS build

RUN apt-get update && \
apt-get install -y nginx tini
apt-get install -y nginx tini && \
rm -rf /var/lib/apt/lists/*

ARG USER=${USER:-root}

Expand All @@ -21,9 +30,7 @@ RUN chown -R $USER /var/log/nginx /var/lib/nginx
USER $USER

WORKDIR /opt/openbmclapi
COPY package-lock.json package.json ./
RUN npm ci --omit=dev

COPY --from=modules /opt/openbmclapi/node_modules ./node_modules
COPY --from=install /opt/openbmclapi/dist ./dist
COPY nginx/ /opt/openbmclapi/nginx

Expand Down

0 comments on commit a645ff8

Please sign in to comment.