Skip to content

Commit

Permalink
fix(docker): only include production dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
dargmuesli committed Dec 27, 2022
1 parent 49f44a6 commit 5a1fc63
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
17 changes: 15 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ VOLUME /srv/app
ENTRYPOINT ["node", "./src/generator.cjs"]


FROM node:19.3.0-alpine@sha256:3ed634e0f15d3e05a1918c3949963508f7ed56350cf94156e6d804ae577849fa AS build
FROM node:19.3.0-alpine@sha256:3ed634e0f15d3e05a1918c3949963508f7ed56350cf94156e6d804ae577849fa AS prepare

WORKDIR /srv/app/

Expand All @@ -21,11 +21,24 @@ COPY ./ ./
RUN pnpm install --offline


FROM node:19.3.0-alpine@sha256:3ed634e0f15d3e05a1918c3949963508f7ed56350cf94156e6d804ae577849fa AS build

WORKDIR /srv/app/

COPY --from=prepare /srv/app/ ./

ENV CI=1
ENV NODE_ENV=production

RUN npm install -g pnpm && \
pnpm install --offline


FROM node:19.3.0-alpine@sha256:3ed634e0f15d3e05a1918c3949963508f7ed56350cf94156e6d804ae577849fa AS test

WORKDIR /srv/app/

COPY --from=build /srv/app/ ./
COPY --from=prepare /srv/app/ ./

RUN npm install -g pnpm && \
pnpm run test
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"packageManager": "pnpm@7.20.0",
"scripts": {
"postinstall": "if [ -d '.git' ] && [ -d '.husky' ]; then husky install && shx rm -rf .git/hooks && shx ln -s ../.husky .git/hooks; fi",
"postinstall": "if [ ! \"$CI\" ]; then husky install && shx rm -rf .git/hooks && shx ln -s ../.husky .git/hooks; fi",
"test": "node src/generator.cjs -p test/example_stack -v"
},
"dependencies": {
Expand Down

0 comments on commit 5a1fc63

Please sign in to comment.