Created
June 20, 2019 16:31
-
-
Save lucmski/b4a143b0bf026448f159e6bf463ed0c2 to your computer and use it in GitHub Desktop.
Example of dockerfile for front/backend in node.js v11.x and alpine
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM node:11-alpine as builder | |
ENV NODE_ENV=production | |
WORKDIR /usr/src/app | |
COPY front/package.json front/yarn.lock ./front/ | |
COPY server/package.json server/yarn.lock ./server/ | |
WORKDIR /usr/src/app/server | |
RUN yarn --frozen-lockfile | |
WORKDIR /usr/src/app/front | |
RUN yarn --frozen-lockfile | |
WORKDIR /usr/src/app/ | |
COPY ./front ./front | |
COPY ./server ./server | |
WORKDIR /usr/src/app/server | |
RUN yarn run build | |
WORKDIR /usr/src/app/front | |
RUN yarn run build | |
# Production | |
FROM node:11-alpine | |
ENV NODE_ENV=production | |
WORKDIR /usr/src/app | |
COPY server/package.json server/yarn.lock ./ | |
RUN yarn install --production --frozen-lockfile | |
COPY --from=builder /usr/src/app/server/dist/ /usr/src/app/ | |
COPY --from=builder /usr/src/app/front/build /usr/src/app/www/ | |
EXPOSE 8080 | |
CMD ["node", "server.js"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment