Browse Source

workflow: docker build quicker

master 1.5.0
OhYee 9 months ago
parent
commit
b890eff1ed
Signed by: OhYee
GPG Key ID: 5A9E1F63ED274FBB
  1. 1
      .dockerignore
  2. 33
      Dockerfile
  3. 2
      build.bash

1
.dockerignore

@ -0,0 +1 @@ @@ -0,0 +1 @@
node_modules

33
Dockerfile

@ -1,31 +1,40 @@ @@ -1,31 +1,40 @@
# syntax=docker/dockerfile:experimental
FROM node:16.5.0 AS builder
FROM node:16.5.0 AS deps
WORKDIR /data/blotter_page
# deps cache
COPY ./package.json ./yarn.lock ./
RUN yarn --global
RUN yarn install --frozen-lockfile
FROM node:16.5.0 AS builder
WORKDIR /data/blotter_page
# build code
COPY ./ /data/blotter_page
COPY --from=deps /data/blotter_page/node_modules ./node_modules
RUN yarn build && yarn install --production --ignore-scripts --prefer-offline
FROM node:16.5.0 AS prod_deps
WORKDIR /data/blotter_page
RUN yarn --global && yarn build
# deps cache
COPY ./package.json ./yarn.lock ./
RUN yarn install --frozen-lockfile --prod
FROM node:16.5.0 AS prod
ENV backendURI="http://backend:50000"
WORKDIR /data/blotter_page
ENTRYPOINT [ "yarn", "start" ]
# dev cache
COPY --from=builder /data/blotter_page/package.json /data/blotter_page/package.json
COPY --from=builder /data/blotter_page/yarn.lock /data/blotter_page/yarn.lock
RUN yarn --prod
COPY --from=builder /data/blotter_page/.next /data/blotter_page/.next
COPY --from=builder /data/blotter_page/next.config.js /data/blotter_page/next.config.js
COPY --from=prod_deps /data/blotter_page/package.json /data/blotter_page/yarn.lock ./
COPY --from=prod_deps /data/blotter_page/node_modules ./node_modules
ENTRYPOINT [ "yarn", "start" ]
COPY --from=builder /data/blotter_page/next.config.js ./
COPY --from=builder /data/blotter_page/.next ./.next

2
build.bash

@ -8,4 +8,4 @@ fi @@ -8,4 +8,4 @@ fi
IMAGE="ohyee/blotter_page:${TAG}"
echo $IMAGE
docker build --no-cache -t ${IMAGE} .
docker build -t ${IMAGE} .
Loading…
Cancel
Save