├── .dockerignore ├── .github └── workflows │ └── build-deploy.yml ├── .gitignore ├── Dockerfile ├── LICENSE ├── README.md ├── app.js ├── package-lock.json ├── package.json └── static └── skel.html /.dockerignore: -------------------------------------------------------------------------------- 1 | **/node_modules/ 2 | **/dist 3 | npm-debug.log 4 | .coverage 5 | .coverage.* 6 | .env 7 | .aws 8 | .gitignore 9 | .github 10 | .git 11 | .directory 12 | -------------------------------------------------------------------------------- /.github/workflows/build-deploy.yml: -------------------------------------------------------------------------------- 1 | name: Build Status 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | 8 | permissions: 9 | packages: write 10 | 11 | jobs: 12 | build: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - name: Checkout 16 | uses: actions/checkout@v4 17 | - name: Use Node.js 18 | uses: actions/setup-node@v3 19 | with: 20 | node-version: '20.x' 21 | - run: npm ci 22 | - run: npm run build --if-present 23 | - run: npm test 24 | 25 | - name: Docker meta 26 | id: meta 27 | uses: docker/metadata-action@v5 28 | with: 29 | images: ghcr.io/nekoprog/sample-devops 30 | tags: | 31 | type=sha 32 | latest 33 | 34 | - name: Login to GHCR 35 | uses: docker/login-action@v3 36 | with: 37 | registry: ghcr.io 38 | username: ${{ github.repository_owner }} 39 | password: ${{ secrets.GITHUB_TOKEN }} 40 | 41 | - name: Build container 42 | uses: docker/build-push-action@v5 43 | with: 44 | context: . 45 | push: true 46 | tags: ${{ steps.meta.outputs.tags }} 47 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | **/node_modules/ 2 | **/dist 3 | npm-debug.log 4 | .coverage 5 | .coverage.* 6 | .env 7 | .aws 8 | .directory 9 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:alpine 2 | COPY . /app 3 | WORKDIR /app 4 | RUN chown node:node ./ 5 | USER node 6 | ARG NODE_ENV=production 7 | ENV NODE_ENV $NODE_ENV 8 | RUN npm ci && npm cache clean --force 9 | EXPOSE 8080 10 | CMD ["node", "./app.js"] 11 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Neko Prog 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. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # sample-devops [![Node.js CI](https://github.com/nekoprog/sample-devops/actions/workflows/build-deploy.yml/badge.svg)](https://github.com/nekoprog/sample-devops/actions/workflows/build-deploy.yml) 2 | DevOps CI/CD pipeline for Node.js and Docker 3 | 4 | ``` 5 | docker run -d \ 6 | --name sample-devops \ 7 | --restart unless-stopped \ 8 | -p 8080:8080 \ 9 | ghcr.io/nekoprog/sample-devops 10 | ``` 11 | -------------------------------------------------------------------------------- /app.js: -------------------------------------------------------------------------------- 1 | let http = require('http'); 2 | let fs = require('fs'); 3 | let server = '127.0.0.1'; 4 | let port = 8080; 5 | 6 | let handleRequest = (request, response) => { 7 | response.writeHead(200, { 8 | 'Content-Type': 'text/html' 9 | }); 10 | fs.readFile('./static/skel.html', null, function (error, data) { 11 | if (error) { 12 | response.writeHead(404); 13 | respone.write('Whoops! File not found!'); 14 | } else { 15 | response.write(data); 16 | } 17 | response.end(); 18 | }); 19 | }; 20 | http.createServer(handleRequest).listen(port); 21 | //console.log('Server running at http://'+server+':'+port+'/'); 22 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sample_devops", 3 | "version": "1.0.0", 4 | "lockfileVersion": 3, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "sample_devops", 9 | "version": "1.0.0", 10 | "license": "MIT" 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sample-devops", 3 | "version": "1.0.0", 4 | "description": "DevOps CI/CD pipeline for Node.js and Docker", 5 | "author": "Neko Prog ", 6 | "license": "MIT", 7 | "main": "app.js", 8 | "keywords": [ 9 | "devops", 10 | "ci/cd", 11 | "node.js", 12 | "docker" 13 | ], 14 | "scripts": { 15 | "test": "echo \"No test specified. Skipping...\"" 16 | }, 17 | "repository": { 18 | "type": "git", 19 | "url": "git+https://github.com/nekoprog/sample-devops.git" 20 | }, 21 | "bugs": { 22 | "url": "https://github.com/nekoprog/sample-devops/issues" 23 | }, 24 | "homepage": "https://github.com/nekoprog/sample-devops#readme" 25 | } 26 | -------------------------------------------------------------------------------- /static/skel.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Hello Bulma! 7 | 8 | 9 | 10 |
11 |
12 |

13 | Hello World! 14 |

15 |

16 | DevOps CI/CD pipeline for Node.js and Docker.
Source code on GitHub 17 |

18 |
19 |
20 | 21 | 22 | --------------------------------------------------------------------------------