Skip to content

Instantly share code, notes, and snippets.

@rxgx
Last active November 12, 2019 17:49
Show Gist options
  • Save rxgx/577520c3c2ae1d78499df853df3bab63 to your computer and use it in GitHub Desktop.
Save rxgx/577520c3c2ae1d78499df853df3bab63 to your computer and use it in GitHub Desktop.
NodeJS Docker & Make Files
FROM node:lts
# Copy the working directory
RUN mkdir /usr/src/app
WORKDIR /usr/src/app
COPY . /usr/src/app
RUN npm ci --no-progress
RUN npm run build --if-exists
# Exposes a port to other containers but your app may use any port specified in it
EXPOSE 30000
#set the node version, update the global npm packages, install/update the app's npm and bower packages, run the app in production mode
CMD ["npm", "start"]
CONTAINER=project
IMAGE=project-node
PORT=30000
docker-browse:
open "http://`docker-machine ip $DOCKER_MACHINE_NAME`:$(PORT)"
docker-clean:
docker rm -v $(docker ps -a -q -f status=exited)
docker-container:
docker run -d \
-p :$(PORT):$(PORT) \
--name $(CONTAINER) \
$(IMAGE)
docker-image:
docker build -t $(IMAGE) .
docker-logs:
docker logs $(CONTAINER)
docker-kill:
docker kill $(CONTAINER)
docker-prune:
docker rmi $(docker images -f "dangling=true" -q)
docker-start:
docker start $(CONTAINER)
docker-stop:
docker stop $(CONTAINER)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment