Skip to content

Instantly share code, notes, and snippets.

@itxtoledo
Created December 23, 2023 03:00
Show Gist options
  • Save itxtoledo/63cb5cbd431070fede2345247cd71254 to your computer and use it in GitHub Desktop.
Save itxtoledo/63cb5cbd431070fede2345247cd71254 to your computer and use it in GitHub Desktop.
Dockerfile nodejs yarn
FROM node:18.0.0-alpine
ARG SSH_KEY
RUN apk add --no-cache dumb-init
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
WORKDIR /usr/src/app
# Install openssh
RUN apk add --no-cache openssh
# Add github to known hosts
RUN mkdir -p -m 0600 ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts
COPY . .
# yarn and yarn build will install, build and remove dev dependencies
RUN ssh-agent sh -c 'echo $SSH_KEY | base64 -d | ssh-add - ; yarn && yarn build'
ENV NODE_ENV=production
CMD yarn start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment