-
-
Save AzureCloudMonk/f5a8718aaf098f3f67dade52c4c3eefb to your computer and use it in GitHub Desktop.
Revisions
-
duluca revised this gist
Dec 16, 2019 . 1 changed file with 9 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,14 @@ These are generic npm scripts that you can copy & paste into your `package.json` file as-is and get access to convinience scripts to manage your Docker images all in one place. ## How to Use ``` npm i -g mrm-task-npm-docker npx mrm npm-docker ``` ## Contribute Here's the code repository https://github.com/expertly-simple/mrm-task-npm-docker > Looking for _npm scripts for AWS ECS_? Go [here](https://gist.github.com/duluca/2b67eb6c2c85f3d75be8c183ab15266e#file-npm-scripts-for-aws-ecs-md)! **Watch the video**: [Do More With Less JavaScript](https://youtu.be/Sd1aM8181kc?list=PLtevgo7IoQizTQdXtRKEXGguTQbL0F01_) -
duluca revised this gist
Jun 2, 2019 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -6,7 +6,8 @@ These are generic npm scripts that you can copy & paste into your `package.json` **Get the book**: These scripts are referenced in my book _Angular for Enterprise-Ready Web Applications_. You can get it on https://AngularForEnterprise.com. ## Evergreen Docker Containers for Static or Angular/React/Vue/etc SPA Websites > These containers are always up-to-date with the base images from latest `lts` channel for `node` and `alpine`. * `docker pull duluca/minimal-nginx-web-server` * **Documentation:** https://hub.docker.com/r/duluca/minimal-nginx-web-server/ * `docker pull duluca/minimal-node-web-server` -
duluca revised this gist
Jun 2, 2019 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -4,6 +4,8 @@ These are generic npm scripts that you can copy & paste into your `package.json` **Watch the video**: [Do More With Less JavaScript](https://youtu.be/Sd1aM8181kc?list=PLtevgo7IoQizTQdXtRKEXGguTQbL0F01_) **Get the book**: These scripts are referenced in my book _Angular for Enterprise-Ready Web Applications_. You can get it on https://AngularForEnterprise.com. ## Docker Containers for Static or Angular/React/Vue/etc SPA Websites * `docker pull duluca/minimal-nginx-web-server` * **Documentation:** https://hub.docker.com/r/duluca/minimal-nginx-web-server/ -
duluca revised this gist
Jun 2, 2019 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -15,6 +15,7 @@ These are generic npm scripts that you can copy & paste into your `package.json` * **`docker:build`:** Builds your Docker image, using the root `Dockerfile` and tags the image as `latest` and whatever version is specificed in `package.json` like `1.0.0`. * **`docker:run`:** Run the image you built on your local Docker instance. When you run `docker ps` your image will identified by the `imageName` you specify in `package.json`. * **`docker:debug`:** Builds and runs image; tails console logs, so you can see what's happening inside the container; launches target app URL `http://localhost:imagePort` in a browser; all in one command. > Note that on the very first run `docker:debug` may fail. In this case, simple re-run the command. * **`docker:publish`:** Publishes the image to the `imageRepo` specified. This can be on Docker Hub, AWS ECS or any other Docker repository you may create. ## Pre-Requisites -
duluca revised this gist
Jun 2, 2019 . 1 changed file with 17 additions and 11 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -14,7 +14,7 @@ These are generic npm scripts that you can copy & paste into your `package.json` * **Cross-Platform:** Works on Windows 10 and macOS. * **`docker:build`:** Builds your Docker image, using the root `Dockerfile` and tags the image as `latest` and whatever version is specificed in `package.json` like `1.0.0`. * **`docker:run`:** Run the image you built on your local Docker instance. When you run `docker ps` your image will identified by the `imageName` you specify in `package.json`. * **`docker:debug`:** Builds and runs image; tails console logs, so you can see what's happening inside the container; launches target app URL `http://localhost:imagePort` in a browser; all in one command. * **`docker:publish`:** Publishes the image to the `imageRepo` specified. This can be on Docker Hub, AWS ECS or any other Docker repository you may create. ## Pre-Requisites @@ -28,20 +28,21 @@ In your `package.json` file add a new config property with three sub-properties "config": { "imageRepo": "[namespace]/[repository]", "imageName": "custom_app_name", "imagePort": "3000", "internalContainerPort": "3000" }, ``` ### Step 2 Copy & paste these new scripts under the `scripts` property in `package.json`: > Note that `docker:runHelper` assumes that your code is listening to port 3000 as reflected by `internalContainerPort`. If this is not the case, update the value in the scripts. ```json "scripts": { "predocker:build": "npm run build", "docker:build": "cross-conf-env docker image build . -t $npm_package_config_imageRepo:$npm_package_version", "postdocker:build": "npm run docker:tag", "docker:tag": " cross-conf-env docker image tag $npm_package_config_imageRepo:$npm_package_version $npm_package_config_imageRepo:latest", "docker:run": "run-s -c docker:clean docker:runHelper", "docker:runHelper": "cross-conf-env docker run -e NODE_ENV=local --name $npm_package_config_imageName -d -p $npm_package_config_imagePort:$npm_package_config_internalContainerPort $npm_package_config_imageRepo", "predocker:publish": "echo Attention! Ensure `docker login` is correct.", "docker:publish": "cross-conf-env docker image push $npm_package_config_imageRepo:$npm_package_version", "postdocker:publish": "cross-conf-env docker image push $npm_package_config_imageRepo:latest", @@ -64,16 +65,21 @@ You can customize the build command to run your tests before building the image You're done. Now run your scripts. To build and publish an image you only need to use two of the commands frequently. 0. **`npm run docker:build`:** Builds and Tags the image. After first run, you can just use `npm run docker:debug`. 1. **`npm run docker:debug`:** Test (optional), Build, Tag, Run, Tail and launch your app in a browser to test. 2. **`npm run docker:publish`:** Voila, your results are published on the repository you've defined. ## Publish on the Internet You've two options, easy-ish and hard. 1. **Easy-ish:** Use [Cloud Run](https://cloud.google.com/run/) Install the CLI: ```bash $ brew cask install google-cloud-sdk > choco install gcloudsdk ``` Deploy your image using the command below, replacing $IMAGE_NAME with the name of your Docker image, i.e. `duluca/minimal-node-web-server`: ```bash $ gcloud beta run deploy --image $IMAGE_NAME ``` Follow the prompts to login, add billing information and you're good to go! 2. **Hard:** Use [AWS ECS](https://aws.amazon.com/ecs/) This is Amazon's Elastic Container Service and it's pretty excellent to use with Docker. However, it is complicated to setup. But worry not; for step-by-step instructions head over to [npm scripts for AWS ECS](https://gist.github.com/duluca/2b67eb6c2c85f3d75be8c183ab15266e#file-npm-scripts-for-aws-ecs-md). -
duluca revised this gist
Apr 15, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -51,7 +51,7 @@ Copy & paste these new scripts under the `scripts` property in `package.json`: "docker:open:win": "echo Trying to launch on Windows && timeout 2 && start http://localhost:%npm_package_config_imagePort%", "docker:open:mac": "echo Trying to launch on MacOS && sleep 2 && URL=http://localhost:$npm_package_config_imagePort && open $URL", "docker:debugmessage": "echo Docker Debug Completed Successfully! Hit Ctrl+C to terminate log tailing.", "predocker:debug": "run-s docker:build docker:run", "docker:debug": "run-s -cs docker:open:win docker:open:mac docker:debugmessage docker:taillogs" }, ``` -
duluca revised this gist
Feb 25, 2018 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -62,6 +62,7 @@ You can customize the build command to run your tests before building the image ## Running You're done. Now run your scripts. To build and publish an image you only need to use two of the commands frequently. 0. **`npm run docker:build`:** Builds and Tags the image. After first run, you can just use `npm run docker:debug`. 1. **`npm run docker:debug`:** Test (optional), Build, Tag, Run, Tail and launch your app in a browser to test. 2. **`npm run docker:publish`:** Voila, you results are published on the repository you've defined. -
duluca revised this gist
Feb 25, 2018 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -33,6 +33,7 @@ In your `package.json` file add a new config property with three sub-properties ``` ### Step 2 Copy & paste these new scripts under the `scripts` property in `package.json`: > Note that `docker:runHelper` assumes that your code is listening to port 3000. Update the value in the scripts, if this is not the case. ```json "scripts": { "predocker:build": "npm run build", -
duluca revised this gist
Jan 25, 2018 . No changes.There are no files selected for viewing
-
duluca revised this gist
Jan 25, 2018 . 1 changed file with 4 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -5,8 +5,10 @@ These are generic npm scripts that you can copy & paste into your `package.json` **Watch the video**: [Do More With Less JavaScript](https://youtu.be/Sd1aM8181kc?list=PLtevgo7IoQizTQdXtRKEXGguTQbL0F01_) ## Docker Containers for Static or Angular/React/Vue/etc SPA Websites * `docker pull duluca/minimal-nginx-web-server` * **Documentation:** https://hub.docker.com/r/duluca/minimal-nginx-web-server/ * `docker pull duluca/minimal-node-web-server` * **Documentation:** https://hub.docker.com/r/duluca/minimal-node-web-server/ ## Features * **Cross-Platform:** Works on Windows 10 and macOS. -
duluca revised this gist
Jan 25, 2018 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -4,6 +4,10 @@ These are generic npm scripts that you can copy & paste into your `package.json` **Watch the video**: [Do More With Less JavaScript](https://youtu.be/Sd1aM8181kc?list=PLtevgo7IoQizTQdXtRKEXGguTQbL0F01_) ## Docker Containers for Static or Angular/React/Vue/etc SPA Websites * `docker pull duluca/minimal-nginx-web-server` -- Documentation https://hub.docker.com/r/duluca/minimal-nginx-web-server/ * `docker pull duluca/minimal-node-web-server` -- Documentation https://hub.docker.com/r/duluca/minimal-node-web-server/ ## Features * **Cross-Platform:** Works on Windows 10 and macOS. * **`docker:build`:** Builds your Docker image, using the root `Dockerfile` and tags the image as `latest` and whatever version is specificed in `package.json` like `1.0.0`. -
duluca revised this gist
Nov 11, 2017 . 1 changed file with 6 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -35,13 +35,17 @@ Copy & paste these new scripts under the `scripts` property in `package.json`: "docker:tag": " cross-conf-env docker image tag $npm_package_config_imageRepo:$npm_package_version $npm_package_config_imageRepo:latest", "docker:run": "run-s -c docker:clean docker:runHelper", "docker:runHelper": "cross-conf-env docker run -e NODE_ENV=local --name $npm_package_config_imageName -d -p $npm_package_config_imagePort:3000 $npm_package_config_imageRepo", "predocker:publish": "echo Attention! Ensure `docker login` is correct.", "docker:publish": "cross-conf-env docker image push $npm_package_config_imageRepo:$npm_package_version", "postdocker:publish": "cross-conf-env docker image push $npm_package_config_imageRepo:latest", "docker:clean": "cross-conf-env docker rm -f $npm_package_config_imageName", "predocker:taillogs": "echo Web Server Logs:", "docker:taillogs": "cross-conf-env docker logs -f $npm_package_config_imageName", "docker:open:win": "echo Trying to launch on Windows && timeout 2 && start http://localhost:%npm_package_config_imagePort%", "docker:open:mac": "echo Trying to launch on MacOS && sleep 2 && URL=http://localhost:$npm_package_config_imagePort && open $URL", "docker:debugmessage": "echo Docker Debug Completed Successfully! Hit Ctrl+C to terminate log tailing.", "predocker:debug": "run-s -c docker:build docker:run", "docker:debug": "run-s -cs docker:open:win docker:open:mac docker:debugmessage docker:taillogs" }, ``` You can customize the build command to run your tests before building the image like: -
duluca revised this gist
Oct 7, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -35,7 +35,7 @@ Copy & paste these new scripts under the `scripts` property in `package.json`: "docker:tag": " cross-conf-env docker image tag $npm_package_config_imageRepo:$npm_package_version $npm_package_config_imageRepo:latest", "docker:run": "run-s -c docker:clean docker:runHelper", "docker:runHelper": "cross-conf-env docker run -e NODE_ENV=local --name $npm_package_config_imageName -d -p $npm_package_config_imagePort:3000 $npm_package_config_imageRepo", "docker:publish": "cross-conf-env docker image push $npm_package_config_imageRepo", "docker:clean": "cross-conf-env docker rm -f $npm_package_config_imageName", "docker:taillogs": "cross-conf-env docker logs -f $npm_package_config_imageName", "docker:open:win": "echo Trying to launch on Windows && timeout 2 && start http://localhost:%npm_package_config_imagePort%", -
duluca revised this gist
Oct 7, 2017 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -35,7 +35,6 @@ Copy & paste these new scripts under the `scripts` property in `package.json`: "docker:tag": " cross-conf-env docker image tag $npm_package_config_imageRepo:$npm_package_version $npm_package_config_imageRepo:latest", "docker:run": "run-s -c docker:clean docker:runHelper", "docker:runHelper": "cross-conf-env docker run -e NODE_ENV=local --name $npm_package_config_imageName -d -p $npm_package_config_imagePort:3000 $npm_package_config_imageRepo", "docker:publish": "cross-conf-env docker image push $npm_package_config_imageRepo:latest", "docker:clean": "cross-conf-env docker rm -f $npm_package_config_imageName", "docker:taillogs": "cross-conf-env docker logs -f $npm_package_config_imageName", -
duluca revised this gist
Oct 7, 2017 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -41,7 +41,6 @@ Copy & paste these new scripts under the `scripts` property in `package.json`: "docker:taillogs": "cross-conf-env docker logs -f $npm_package_config_imageName", "docker:open:win": "echo Trying to launch on Windows && timeout 2 && start http://localhost:%npm_package_config_imagePort%", "docker:open:mac": "echo Trying to launch on MacOS && sleep 2 && URL=http://localhost:$npm_package_config_imagePort && open $URL", "predocker:debug": "run-s -c docker:build docker:run", "docker:debug": "run-s -cs docker:open:win docker:open:mac docker:taillogs" }, -
duluca revised this gist
Sep 30, 2017 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -42,8 +42,8 @@ Copy & paste these new scripts under the `scripts` property in `package.json`: "docker:open:win": "echo Trying to launch on Windows && timeout 2 && start http://localhost:%npm_package_config_imagePort%", "docker:open:mac": "echo Trying to launch on MacOS && sleep 2 && URL=http://localhost:$npm_package_config_imagePort && open $URL", "predocker:debug": "run-s docker:build docker:run", "predocker:debug": "run-s -c docker:build docker:run", "docker:debug": "run-s -cs docker:open:win docker:open:mac docker:taillogs" }, ``` You can customize the build command to run your tests before building the image like: -
duluca revised this gist
Sep 30, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -29,7 +29,7 @@ In your `package.json` file add a new config property with three sub-properties Copy & paste these new scripts under the `scripts` property in `package.json`: ```json "scripts": { "predocker:build": "npm run build", "docker:build": "cross-conf-env docker image build . -t $npm_package_config_imageRepo:$npm_package_version", "postdocker:build": "npm run docker:tag", "docker:tag": " cross-conf-env docker image tag $npm_package_config_imageRepo:$npm_package_version $npm_package_config_imageRepo:latest", -
duluca revised this gist
Sep 30, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -20,7 +20,7 @@ These are generic npm scripts that you can copy & paste into your `package.json` In your `package.json` file add a new config property with three sub-properties using your own values, as shown below: ```json "config": { "imageRepo": "[namespace]/[repository]", "imageName": "custom_app_name", "imagePort": "0000" }, -
duluca revised this gist
Sep 29, 2017 . 1 changed file with 0 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -19,19 +19,16 @@ These are generic npm scripts that you can copy & paste into your `package.json` ### Step 1 In your `package.json` file add a new config property with three sub-properties using your own values, as shown below: ```json "config": { "imageRepo": "[repository]/[image_name]", "imageName": "custom_app_name", "imagePort": "0000" }, ``` ### Step 2 Copy & paste these new scripts under the `scripts` property in `package.json`: ```json "scripts": { "predocker:build": "npm run build -- --prod", "docker:build": "cross-conf-env docker image build . -t $npm_package_config_imageRepo:$npm_package_version", "postdocker:build": "npm run docker:tag", @@ -47,7 +44,6 @@ Copy & paste these new scripts under the `scripts` property in `package.json`: "predocker:debug": "run-s docker:build docker:run", "docker:debug": "run-p -cs docker:open:win docker:open:mac", "postdocker:debug": "npm run docker:taillogs", }, ``` You can customize the build command to run your tests before building the image like: -
duluca revised this gist
Sep 29, 2017 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -24,13 +24,14 @@ In your `package.json` file add a new config property with three sub-properties "imageRepo": "[repository]/[image_name]", "imageName": "custom_app_name", "imagePort": "0000" }, ... ``` ### Step 2 Copy & paste these new scripts under the `scripts` property in `package.json`: ```json "scripts": { ... "predocker:build": "npm run build -- --prod", "docker:build": "cross-conf-env docker image build . -t $npm_package_config_imageRepo:$npm_package_version", "postdocker:build": "npm run docker:tag", @@ -46,6 +47,7 @@ Copy & paste these new scripts under the `scripts` property in `package.json`: "predocker:debug": "run-s docker:build docker:run", "docker:debug": "run-p -cs docker:open:win docker:open:mac", "postdocker:debug": "npm run docker:taillogs", ... }, ``` You can customize the build command to run your tests before building the image like: -
duluca revised this gist
Sep 29, 2017 . 1 changed file with 26 additions and 14 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -5,40 +5,52 @@ These are generic npm scripts that you can copy & paste into your `package.json` **Watch the video**: [Do More With Less JavaScript](https://youtu.be/Sd1aM8181kc?list=PLtevgo7IoQizTQdXtRKEXGguTQbL0F01_) ## Features * **Cross-Platform:** Works on Windows 10 and macOS. * **`docker:build`:** Builds your Docker image, using the root `Dockerfile` and tags the image as `latest` and whatever version is specificed in `package.json` like `1.0.0`. * **`docker:run`:** Run the image you built on your local Docker instance. When you run `docker ps` your image will identified by the `imageName` you specify in `package.json`. * **`docker:debug`:** Builds and runs image; tails console logs, so you can see what's happening inside the container; launche target app URL `http://localhost:imagePort` in a browser; all in one command. * **`docker:publish`:** Publishes the image to the `imageRepo` specified. This can be on Docker Hub, AWS ECS or any other Docker repository you may create. ## Pre-Requisites - Install Docker for [Mac](https://www.docker.com/docker-mac) or [Windows](https://www.docker.com/docker-windows) - `npm i --save-dev cross-conf-env npm-run-all`: Needed to ensure cross platform functionality for scripts. ## Configuring Package.json in 2-steps ### Step 1 In your `package.json` file add a new config property with three sub-properties using your own values, as shown below: ```json ... "config": { "imageRepo": "[repository]/[image_name]", "imageName": "custom_app_name", "imagePort": "0000" } ... ``` ### Step 2 Copy & paste these new scripts under the `scripts` property in `package.json`: ```json "scripts": { "predocker:build": "npm run build -- --prod", "docker:build": "cross-conf-env docker image build . -t $npm_package_config_imageRepo:$npm_package_version", "postdocker:build": "npm run docker:tag", "docker:tag": " cross-conf-env docker image tag $npm_package_config_imageRepo:$npm_package_version $npm_package_config_imageRepo:latest", "docker:run": "run-s -c docker:clean docker:runHelper", "docker:runHelper": "cross-conf-env docker run -e NODE_ENV=local --name $npm_package_config_imageName -d -p $npm_package_config_imagePort:3000 $npm_package_config_imageRepo", "predocker:publish": "echo Attention! Ensure `docker login` is correct.", "docker:publish": "cross-conf-env docker image push $npm_package_config_imageRepo:latest", "docker:clean": "cross-conf-env docker rm -f $npm_package_config_imageName", "docker:taillogs": "cross-conf-env docker logs -f $npm_package_config_imageName", "docker:open:win": "echo Trying to launch on Windows && timeout 2 && start http://localhost:%npm_package_config_imagePort%", "docker:open:mac": "echo Trying to launch on MacOS && sleep 2 && URL=http://localhost:$npm_package_config_imagePort && open $URL", "predocker:debug": "run-s docker:build docker:run", "docker:debug": "run-p -cs docker:open:win docker:open:mac", "postdocker:debug": "npm run docker:taillogs", }, ``` You can customize the build command to run your tests before building the image like: ```json "predocker:build": "npm run build -- --prod && npm test", ``` ## Running -
duluca revised this gist
Aug 22, 2017 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -2,6 +2,8 @@ These are generic npm scripts that you can copy & paste into your `package.json` > Looking for _npm scripts for AWS ECS_? Go [here](https://gist.github.com/duluca/2b67eb6c2c85f3d75be8c183ab15266e#file-npm-scripts-for-aws-ecs-md)! **Watch the video**: [Do More With Less JavaScript](https://youtu.be/Sd1aM8181kc?list=PLtevgo7IoQizTQdXtRKEXGguTQbL0F01_) ## Features * **`docker:build`:** Builds your Docker image, using the root `Dockerfile` and tags the image as `latest` and whatever version is specificed in `package.json` like `1.0.0`. * **`docker:run`:** Run the image you built on your local Docker instance. When you run `docker ps` your image will identified by the `imageName` you specify in `package.json`. -
duluca revised this gist
Aug 11, 2017 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -46,12 +46,12 @@ You're done. Now run your scripts. To build and publish an image you only need t ## Publish on the Internet You've two options, easy and hard. 1. **Easy:** Use [now.sh](https://zeit.co/now) After you install the cli tools and login. You'll need to run the following command on the same folder as your `Dockerfile`: ```bash $ now ``` That's it! 2. **Hard:** Use [AWS ECS](https://aws.amazon.com/ecs/) This is Amazon's Elastic Container Service and it's pretty excellent to use with Docker. However, it is complicated to setup. But worry not for step-by-step instructions head over to [npm scripts for AWS ECS](https://gist.github.com/duluca/2b67eb6c2c85f3d75be8c183ab15266e#file-npm-scripts-for-aws-ecs-md). -
duluca revised this gist
Aug 11, 2017 . 1 changed file with 7 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -3,10 +3,10 @@ These are generic npm scripts that you can copy & paste into your `package.json` > Looking for _npm scripts for AWS ECS_? Go [here](https://gist.github.com/duluca/2b67eb6c2c85f3d75be8c183ab15266e#file-npm-scripts-for-aws-ecs-md)! ## Features * **`docker:build`:** Builds your Docker image, using the root `Dockerfile` and tags the image as `latest` and whatever version is specificed in `package.json` like `1.0.0`. * **`docker:run`:** Run the image you built on your local Docker instance. When you run `docker ps` your image will identified by the `imageName` you specify in `package.json`. * **`docker:debug`:** Builds and runs image; tails console logs, so you can see what's happening inside the container; launche target app URL `http://localhost:imagePort` in a browser; all in one command. * **`docker:publish`:** Publishes the image to the `imageRepo` specified. This can be on Docker Hub, AWS ECS or any other Docker repository you may create. ## Pre-Requisites - Install Docker for [Mac](https://www.docker.com/docker-mac) or [Windows](https://www.docker.com/docker-windows) @@ -24,7 +24,6 @@ In your `package.json` file add three new properties using your own values, as s Copy & paste these new scripts under the `scripts` property in `package.json`: ```json "scripts": { "docker:build": "with-package docker image build . -t pkg.imageRepo:pkg.version && npm run docker:tag", "docker:tag": "with-package docker image tag pkg.imageRepo:pkg.version pkg.imageRepo:latest", "docker:run": "npm run docker:clean && npm run docker:runHelper", @@ -42,8 +41,8 @@ You can customize the build command to run your tests before building the image ## Running You're done. Now run your scripts. To build and publish an image you only need to use two of the commands frequently. 1. **`npm run docker:debug`:** Test (optional), Build, Tag, Run, Tail and launch your app in a browser to test. 2. **`npm run docker:publish`:** Voila, you results are published on the repository you've defined. ## Publish on the Internet You've two options, easy and hard. @@ -53,5 +52,6 @@ After you install the cli tools and login. You'll need to run the following comm $ now ``` That's it! 2. Hard: Use [AWS ECS](https://aws.amazon.com/ecs/) This is Amazon's Elastic Container Service and it's pretty excellent to use with Docker. However, it is complicated to setup. But worry not for step-by-step instructions head over to [npm scripts for AWS ECS](https://gist.github.com/duluca/2b67eb6c2c85f3d75be8c183ab15266e#file-npm-scripts-for-aws-ecs-md). -
duluca revised this gist
Aug 11, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ These are generic npm scripts that you can copy & paste into your `package.json` > Looking for _npm scripts for AWS ECS_? Go [here](https://gist.github.com/duluca/2b67eb6c2c85f3d75be8c183ab15266e#file-npm-scripts-for-aws-ecs-md)! ## Features * *`docker:build`*: Builds your Docker image, using the root `Dockerfile` and tags the image as `latest` and whatever version is specificed in `package.json` like `1.0.0`. * `npm run docker:run`: Run the image you built on your local Docker instance. When you run `docker ps` your image will identified by the `imageName` you specify in `package.json`. * `npm run docker:debug`: Builds and runs image; tails console logs, so you can see what's happening inside the container; launche target app URL `http://localhost:imagePort` in a browser; all in one command. * `npm run docker:publish`: Publishes the image to the `imageRepo` specified. This can be on Docker Hub, AWS ECS or any other Docker repository you may create. -
duluca revised this gist
Aug 11, 2017 . 1 changed file with 14 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,12 +1,15 @@ These are generic npm scripts that you can copy & paste into your `package.json` file as-is and get access to convinience scripts to manage your Docker images all in one place. > Looking for _npm scripts for AWS ECS_? Go [here](https://gist.github.com/duluca/2b67eb6c2c85f3d75be8c183ab15266e#file-npm-scripts-for-aws-ecs-md)! ## Features * `npm run docker:build`: Builds your Docker image, using the root `Dockerfile` and tags the image as `latest` and whatever version is specificed in `package.json` like `1.0.0`. * `npm run docker:run`: Run the image you built on your local Docker instance. When you run `docker ps` your image will identified by the `imageName` you specify in `package.json`. * `npm run docker:debug`: Builds and runs image; tails console logs, so you can see what's happening inside the container; launche target app URL `http://localhost:imagePort` in a browser; all in one command. * `npm run docker:publish`: Publishes the image to the `imageRepo` specified. This can be on Docker Hub, AWS ECS or any other Docker repository you may create. ## Pre-Requisites - Install Docker for [Mac](https://www.docker.com/docker-mac) or [Windows](https://www.docker.com/docker-windows) - `npm i --save-dev with-package`: Needed to access `package.json` properties programmatically. ## Configuring Package.json in 2-steps @@ -42,5 +45,13 @@ You're done. Now run your scripts. To build and publish an image you only need t 1. `npm run docker:debug`: [Test], Build, Tag, Run, Tail and launch your app in a browser to test. 2. `npm run docker:publish`: Voila, you results are published on the repository you've defined. ## Publish on the Internet You've two options, easy and hard. 1. Easy: Use [now.sh](https://zeit.co/now) After you install the cli tools and login. You'll need to run the following command on the same folder as your `Dockerfile`: ```bash $ now ``` That's it! 2. Hard: Use [AWS ECS](https://aws.amazon.com/ecs/) This is Amazon's Elastic Container Service and it's pretty excellent to use with Docker. However, it is complicated to setup. But worry not for step-by-step instructions head over to [npm scripts for AWS ECS](https://gist.github.com/duluca/2b67eb6c2c85f3d75be8c183ab15266e#file-npm-scripts-for-aws-ecs-md). -
duluca revised this gist
Aug 11, 2017 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,10 +1,10 @@ These are generic npm scripts that you can copy & paste into your `package.json` file as-is and get access to convinience scripts to manage your Docker images all in one place. ## Features * `npm run docker:build`: Builds your Docker image, using the root `Dockerfile` and tags the image as `latest` and whatever version is specificed in `package.json` like `1.0.0`. * `npm run docker:run`: Run the image you built on your local Docker instance. When you run `docker ps` your image will identified by the `imageName` you specify in `package.json`. * `npm run docker:debug`: Builds and runs image; tails console logs, so you can see what's happening inside the container; launche target app URL `http://localhost:imagePort` in a browser; all in one command. * `npm run docker:publish`: Publishes the image to the `imageRepo` specified. This can be on Docker Hub, AWS ECS or any other Docker repository you may create. ## Pre-Requisite - `npm i --save-dev with-package`: Needed to access `package.json` properties programmatically. -
duluca revised this gist
Aug 11, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -18,7 +18,7 @@ In your `package.json` file add three new properties using your own values, as s "imagePort": "0000", ``` ### Step 2 Copy & paste these new scripts under the `scripts` property in `package.json`: ```json "scripts": { ... -
duluca created this gist
Aug 11, 2017 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,46 @@ These are generic npm scripts that you can copy & paste into your `package.json` file as-is and get access to convinience scripts to manage your Docker images all in one place. ## Features - `npm run docker:build`: Builds your Docker image, using the root `Dockerfile` and tags the image as `latest` and whatever version is specificed in `package.json` like `1.0.0`. - `npm run docker:run`: Run the image you built on your local Docker instance. When you run `docker ps` your image will identified by the `imageName` you specify in `package.json`. - `npm run docker:debug`: Builds and runs image; tails console logs, so you can see what's happening inside the container; launche target app URL `http://localhost:imagePort` in a browser; all in one command. - `npm run docker:publish`: Publishes the image to the `imageRepo` specified. This can be on Docker Hub, AWS ECS or any other Docker repository you may create. ## Pre-Requisite - `npm i --save-dev with-package`: Needed to access `package.json` properties programmatically. ## Configuring Package.json in 2-steps ### Step 1 In your `package.json` file add three new properties using your own values, as shown below: ```json "imageRepo": "[repository]/[image_name]", "imageName": "custom_app_name", "imagePort": "0000", ``` ### Step 2 Under `scripts` copy & paste add these new scripts in: ```json "scripts": { ... "docker:build": "with-package docker image build . -t pkg.imageRepo:pkg.version && npm run docker:tag", "docker:tag": "with-package docker image tag pkg.imageRepo:pkg.version pkg.imageRepo:latest", "docker:run": "npm run docker:clean && npm run docker:runHelper", "docker:runHelper": "with-package docker run --name pkg.imageName -d -p pkg.imagePort:3000 pkg.imageRepo", "docker:publish": "with-package docker image push pkg.imageRepo", "docker:clean": "with-package docker rm -f pkg.imageName || true", "docker:taillogs": "with-package docker logs -f pkg.imageName", "docker:debug": "npm run docker:build && npm run docker:run && sleep 1 && with-package open 'http://localhost:pkg.imagePort' && npm run docker:taillogs" }, ``` You can customize the build command to run your tests before building the image like: ```json "docker:build": "npm test && with-package docker image build . -t pkg.imageRepo:pkg.version && npm run docker:tag", ``` ## Running You're done. Now run your scripts. To build and publish an image you only need to use two of the commands frequently. 1. `npm run docker:debug`: [Test], Build, Tag, Run, Tail and launch your app in a browser to test. 2. `npm run docker:publish`: Voila, you results are published on the repository you've defined. ## AWS ECS If you then need release your published image on AWS ECS see this gist [here]().