Skip to content

Instantly share code, notes, and snippets.

@efossas
Last active August 19, 2018 16:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save efossas/4c81794ae962c5148c23ec4934121422 to your computer and use it in GitHub Desktop.
Save efossas/4c81794ae962c5148c23ec4934121422 to your computer and use it in GitHub Desktop.
Dockerfile
# the FROM instruction sets the original image to start with
# namespace/image:tag
# without a namespace, the image is must be an official docker image. https://docs.docker.com/docker-hub/official_repos/
# without a tag, 'latest' is the default
# so here, we'll use a container with node installed on it, using the Alpine OS, which is very lightweight
FROM node:alpine
# the RUN instruction runs a command
# here we use the apk package manager to install git and other tools
RUN apk update && apk upgrade && apk add coreutils git openssl wget
# here we'll copy this git repo with our application code into the image in the directory /crud
RUN git clone https://github.com/efossas/CRUD /crud
# the WORKDIR instruction sets the directory from which commands will run from
WORKDIR /crud
# now that our working directory is /crud, we can run 'npm install' to install node dependencies in the /crud directory
RUN npm install --unsafe-perm
# although we don't actually use ssl directly,
# the Node+Express server we'll run enables https, so we need to generate ssl self signed certificates
RUN chmod 744 /crud/gencert.sh
RUN ash /crud/gencert.sh 'localhost'
# the CMD instruction changes the main process of the container
# here, we change the process to 'npm' with the argument 'start'
# this will in turn run server.js (this is set in package.json)
CMD ["npm","start"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment