Last active
November 12, 2019 17:49
-
-
Save rxgx/577520c3c2ae1d78499df853df3bab63 to your computer and use it in GitHub Desktop.
NodeJS Docker & Make Files
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
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"] |
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
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