forked from hieven/terraform-visual
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix docker image generation. Try to reduce docker image file as much …
…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.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
||
|