Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nonroot User in Docker Image #133

Merged
merged 1 commit into from
Oct 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 6 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@ RUN npm run build

FROM node:16-alpine3.15
RUN apk add curl
WORKDIR /root
WORKDIR /app
ADD package*.json ./
RUN npm install --production
COPY --from=solidity-builder /home/node/contracts contracts/source
COPY --from=solidity-builder /home/node/artifacts/contracts/ERC1155MixedFungible.sol contracts
COPY --from=builder /root/dist dist
COPY --from=builder /root/.env /root/.env
COPY --from=builder /root/.env /app/.env
RUN chgrp -R 0 /app/ \
&& chmod -R g+rwX /app/
USER 1001
Comment on lines +26 to +28
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this one might have the same problem as the other PR that you fixed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should not because in this one we're assuming the USER till after we've done everything else.

I may refactor one or the other Dockerfiles to be more consistent with when we do npm i's and with what users once I've tested out these images at runtime. Because right now these similar runtimes go about their dockerfiles / bundling a bit different for reasons I don't yet appreciate.

EXPOSE 3000
CMD ["npm", "run", "start:prod"]
CMD ["node", "dist/src/main"]