Last active
August 19, 2018 16:55
-
-
Save efossas/4c81794ae962c5148c23ec4934121422 to your computer and use it in GitHub Desktop.
Dockerfile
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
# 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