├── CHANGELOG.md ├── CONTRIBUTING.md ├── Dockerfile ├── Dockerfile-app ├── Dockerfile-base ├── LICENSE.md ├── README.md ├── package.json ├── server.js ├── taskmulti-multiregistry.yaml └── taskmulti.yaml /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## [project-title] Changelog 2 | 3 | 4 | # x.y.z (yyyy-mm-dd) 5 | 6 | *Features* 7 | * ... 8 | 9 | *Bug Fixes* 10 | * ... 11 | 12 | *Breaking Changes* 13 | * ... 14 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to [project-title] 2 | 3 | This project welcomes contributions and suggestions. Most contributions require you to agree to a 4 | Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us 5 | the rights to use your contribution. For details, visit https://cla.microsoft.com. 6 | 7 | When you submit a pull request, a CLA-bot will automatically determine whether you need to provide 8 | a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions 9 | provided by the bot. You will only need to do this once across all repos using our CLA. 10 | 11 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). 12 | For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or 13 | contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. 14 | 15 | - [Code of Conduct](#coc) 16 | - [Issues and Bugs](#issue) 17 | - [Feature Requests](#feature) 18 | - [Submission Guidelines](#submit) 19 | 20 | ## Code of Conduct 21 | Help us keep this project open and inclusive. Please read and follow our [Code of Conduct](https://opensource.microsoft.com/codeofconduct/). 22 | 23 | ## Found an Issue? 24 | If you find a bug in the source code or a mistake in the documentation, you can help us by 25 | [submitting an issue](#submit-issue) to the GitHub Repository. Even better, you can 26 | [submit a Pull Request](#submit-pr) with a fix. 27 | 28 | ## Want a Feature? 29 | You can *request* a new feature by [submitting an issue](#submit-issue) to the GitHub 30 | Repository. If you would like to *implement* a new feature, please submit an issue with 31 | a proposal for your work first, to be sure that we can use it. 32 | 33 | * **Small Features** can be crafted and directly [submitted as a Pull Request](#submit-pr). 34 | 35 | ## Submission Guidelines 36 | 37 | ### Submitting an Issue 38 | Before you submit an issue, search the archive, maybe your question was already answered. 39 | 40 | If your issue appears to be a bug, and hasn't been reported, open a new issue. 41 | Help us to maximize the effort we can spend fixing issues and adding new 42 | features, by not reporting duplicate issues. Providing the following information will increase the 43 | chances of your issue being dealt with quickly: 44 | 45 | * **Overview of the Issue** - if an error is being thrown a non-minified stack trace helps 46 | * **Version** - what version is affected (e.g. 0.1.2) 47 | * **Motivation for or Use Case** - explain what are you trying to do and why the current behavior is a bug for you 48 | * **Browsers and Operating System** - is this a problem with all browsers? 49 | * **Reproduce the Error** - provide a live example or a unambiguous set of steps 50 | * **Related Issues** - has a similar issue been reported before? 51 | * **Suggest a Fix** - if you can't fix the bug yourself, perhaps you can point to what might be 52 | causing the problem (line of code or commit) 53 | 54 | You can file new issues by providing the above information at the corresponding repository's issues link: https://github.com/[organization-name]/[repository-name]/issues/new]. 55 | 56 | ### Submitting a Pull Request (PR) 57 | Before you submit your Pull Request (PR) consider the following guidelines: 58 | 59 | * Search the repository (https://github.com/[organization-name]/[repository-name]/pulls) for an open or closed PR 60 | that relates to your submission. You don't want to duplicate effort. 61 | 62 | * Make your changes in a new git fork: 63 | 64 | * Commit your changes using a descriptive commit message 65 | * Push your fork to GitHub: 66 | * In GitHub, create a pull request 67 | * If we suggest changes then: 68 | * Make the required updates. 69 | * Rebase your fork and force push to your GitHub repository (this will update your Pull Request): 70 | 71 | ```shell 72 | git rebase master -i 73 | git push -f 74 | ``` 75 | 76 | That's it! Thank you for your contribution! 77 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:15-alpine 2 | 3 | COPY . /src 4 | RUN cd /src && npm install 5 | EXPOSE 80 6 | CMD ["node", "/src/server.js"] 7 | -------------------------------------------------------------------------------- /Dockerfile-app: -------------------------------------------------------------------------------- 1 | ARG REGISTRY_NAME 2 | FROM ${REGISTRY_NAME}/baseimages/node:15-alpine 3 | 4 | COPY . /src 5 | RUN cd /src && npm install 6 | EXPOSE 80 7 | CMD ["node", "/src/server.js"] 8 | -------------------------------------------------------------------------------- /Dockerfile-base: -------------------------------------------------------------------------------- 1 | FROM node:15-alpine 2 | ENV NODE_VERSION 15.2.1 3 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Microsoft Corporation. All rights reserved. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | --- 2 | page_type: sample 3 | languages: 4 | - javascript 5 | products: 6 | - azure 7 | description: "This Node.js application is for use in demonstrating scenarios for Azure Container Registry Tasks." 8 | urlFragment: acr-build-helloworld-node 9 | --- 10 | 11 | 12 | # ACR Build Hello World 13 | 14 | This Node.js application is for use in demonstrating scenarios for Azure Container Registry Tasks. [ACR Tasks](https://docs.microsoft.com/azure/container-registry/container-registry-tasks-overview) is a suite of features within [Azure Container Registry](https://azure.microsoft.com/services/container-registry/) for performing Docker container builds on [Azure](https://azure.com), as well as automated OS and framework patching for Docker containers. 15 | 16 | ## Features 17 | 18 | This project includes the following Dockerfiles: 19 | 20 | * *Dockerfile* - Non-parameterized Dockerfile for building the application. References a base image in Docker Hub. 21 | * *Dockerfile-app* - Parameterized, accepts the `REGISTRY_NAME` argument to specify the FQDN of the container registry from which the base image is pulled. 22 | * *Dockerfile-base* - Defines a base image for the application defined in *Dockerfile-app*. 23 | 24 | This project also includes the following YAML files: 25 | 26 | * *taskmulti.yaml* - Specifies a multistep task to build, run, and push a container image specified by *Dockerfile*. 27 | * *taskmulti-multiregistry.yaml* - Specifies a multistep task to build, run, and push container images specified by *Dockerfile* to multiple registries. 28 | 29 | ## Getting Started 30 | 31 | ### Companion articles 32 | 33 | This project is intended for use with the following articles on [docs.microsoft.com][docs]: 34 | 35 | * [Build container images in the cloud with Azure Container Registry Tasks][build-quick] 36 | * [Automate container image builds in the cloud when you commit source code][build-task] 37 | * [Run a multi-step container workflow in the cloud when you commit source code][multi-step] 38 | * [Automate container image builds when a base image is updated in an Azure container registry][build-base] 39 | 40 | ### Quickstart 41 | 42 | Although intended for use with the companion articles, you can perform the following steps to run the sample application. These steps require a local [Docker](http://docker.com) installation. 43 | 44 | 1. `git clone https://github.com/Azure-Samples/acr-build-helloworld-node` 45 | 1. `cd acr-build-helloworld-node` 46 | 1. `docker build -t helloacrbuild:v1 .` 47 | 1. `docker run -d -p 8080:80 helloacrbuild:v1` 48 | 1. Navigate to http://localhost:8080 to view the running application 49 | 50 | ## Resources 51 | 52 | [Azure Container Registry](https://azure.microsoft.com/services/container-registry/) 53 | 54 | [Azure Container Registry documentation](https://docs.microsoft.com/azure/container-registry/) 55 | 56 | 57 | [build-quick]: https://docs.microsoft.com/azure/container-registry/container-registry-tutorial-quick-build 58 | [build-task]: https://docs.microsoft.com/azure/container-registry/container-registry-tutorial-build-task 59 | [build-base]: https://docs.microsoft.com/azure/container-registry/container-registry-tutorial-base-image-update 60 | [multi-step]: https://docs.microsoft.com/azure/container-registry/container-registry-tutorial-multistep-task 61 | [docs]: http://docs.microsoft.com 62 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "helloworld", 3 | "version": "1.0.0", 4 | "description": "Sample app for ACR Build", 5 | "main": "server.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "start": "node server.js" 9 | }, 10 | "license": "MIT" 11 | } 12 | -------------------------------------------------------------------------------- /server.js: -------------------------------------------------------------------------------- 1 | const http = require('http') 2 | 3 | const port = 80 4 | 5 | const server = http.createServer((request, response) => { 6 | response.writeHead(200, {'Content-Type': 'text/plain'}) 7 | response.write('Hello World\n') 8 | response.end('Version: ' + process.env.NODE_VERSION + '\n') 9 | }) 10 | 11 | server.listen(port) 12 | 13 | console.log(`Server running at http://localhost: ${port}`) 14 | -------------------------------------------------------------------------------- /taskmulti-multiregistry.yaml: -------------------------------------------------------------------------------- 1 | version: v1.0.0 2 | steps: 3 | # Build target images 4 | - build: -t {{.Run.Registry}}/hello-world:{{.Run.ID}} -f Dockerfile . 5 | - build: -t {{.Values.regDate}}/hello-world:{{.Run.Date}} -f Dockerfile . 6 | # Run image 7 | - cmd: -t {{.Run.Registry}}/hello-world:{{.Run.ID}} 8 | id: test 9 | detach: true 10 | ports: ["8080:80"] 11 | - cmd: docker stop test 12 | # Push images 13 | - push: 14 | - {{.Run.Registry}}/hello-world:{{.Run.ID}} 15 | - {{.Values.regDate}}/hello-world:{{.Run.Date}} -------------------------------------------------------------------------------- /taskmulti.yaml: -------------------------------------------------------------------------------- 1 | version: v1.0.0 2 | steps: 3 | # Build target image 4 | - build: -t {{.Run.Registry}}/hello-world:{{.Run.ID}} -f Dockerfile . 5 | # Run image 6 | - cmd: -t {{.Run.Registry}}/hello-world:{{.Run.ID}} 7 | id: test 8 | detach: true 9 | ports: ["8080:80"] 10 | - cmd: docker stop test 11 | # Push image 12 | - push: 13 | - {{.Run.Registry}}/hello-world:{{.Run.ID}} --------------------------------------------------------------------------------