Skip to content

Commit

Permalink
Fix docker image generation. Try to reduce docker image file as much …
Browse files Browse the repository at this point in the history
…as possible
  • Loading branch information
Victor Cabezas committed Oct 25, 2021
1 parent f60ec47 commit ae1883e
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,35 @@ LABEL org.opencontainers.image.authors="[email protected]"
# Create app directory
WORKDIR /usr/src/app

COPY cli/ ./
COPY tsconfig.json /usr/src/tsconfig.json
RUN mkdir ./template

# Cleanup stuff from development environment
RUN find . -name node_modules -type d | xargs rm -rf && \
find . -name package-lock.json -delete
COPY cli/package.json cli/tsconfig.json cli/src/ cli/bin/ ./
COPY cli/src/ ./src/
COPY cli/bin/ ./bin/
COPY cli/template/package.json cli/template/tsconfig.json cli/template/next*.js ./template/
COPY cli/template/src/ ./template/src/
COPY tsconfig.json /usr/src/tsconfig.json

#---- Dependencies ----
FROM base AS dependencies

RUN npm install --only=production && \
cp -R node_modules prod_node_modules

# install ALL node_modules, including 'devDependencies'
RUN npm install && \
cd template && yarn install --prod && \
cd template && yarn install && \
cd .. && npm run build

# RUN rm -rf node_modules/* && \
# npm install --only=production && \
# cd template && yarn install --production
#

#---- Production ----
FROM base AS release
# copy production node_modules
COPY --from=dependencies /usr/src/app/prod_node_modules ./node_modules
COPY --from=dependencies /usr/src/app/node_modules ./node_modules
COPY --from=dependencies /usr/src/app/template/node_modules ./template/node_modules
COPY --from=dependencies /usr/src/app/dist ./dist
COPY --from=dependencies /usr/src/app/template/dist ./template/dist

RUN npm link --only=production

Expand Down

0 comments on commit ae1883e

Please sign in to comment.