Skip to content

Commit

Permalink
Optimize frontend docker (#165)
Browse files Browse the repository at this point in the history
  • Loading branch information
akshay288 authored Dec 3, 2022
1 parent 94e7aad commit fcc38ef
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
28 changes: 22 additions & 6 deletions deploy/frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,38 @@
FROM node:alpine
FROM node:alpine AS builder

RUN apk add --no-cache libc6-compat

WORKDIR /usr/src/app

ADD ../../../frontend frontend
ADD ../../../common common

WORKDIR /usr/src/app/common
RUN yarn
RUN yarn install --frozen-lockfile
RUN yarn build

WORKDIR /usr/src/app/frontend
RUN echo 'BACKEND_URL=http://backend:8080' >> .env
RUN echo 'NODE_ENV=production' >> .env
RUN yarn
RUN yarn install --frozen-lockfile
RUN yarn build
RUN rm -rf src
RUN yarn cache clean

FROM node:alpine

WORKDIR /usr/src/app

WORKDIR /usr/src/app/frontend
COPY --from=builder /usr/src/app/frontend/public ./public
COPY --from=builder /usr/src/app/frontend/package.json ./package.json
COPY --from=builder /usr/src/app/frontend/.next/standalone ./
COPY --from=builder /usr/src/app/frontend/.next/static ./.next/static

WORKDIR /usr/src/app/common
COPY --from=builder /usr/src/app/common/package.json ./package.json
COPY --from=builder /usr/src/app/common/dist ./dist
COPY --from=builder /usr/src/app/common/node_modules ./node_modules

WORKDIR /usr/src/app/frontend
EXPOSE 8080

CMD [ "yarn", "start" ]
CMD [ "node", "server.js" ]
1 change: 1 addition & 0 deletions frontend/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ module.exports = withBundleAnalyzer({
}
return config
},
output: 'standalone',
})

0 comments on commit fcc38ef

Please sign in to comment.