Add node-api template
This commit is contained in:
27
templates/node-api/skeleton/.drone.yml
Normal file
27
templates/node-api/skeleton/.drone.yml
Normal file
@@ -0,0 +1,27 @@
|
||||
kind: pipeline
|
||||
type: kubernetes
|
||||
name: build-${{ values.name }}
|
||||
|
||||
steps:
|
||||
- name: test
|
||||
image: node:${{ values.nodeVersion }}
|
||||
commands:
|
||||
- npm install
|
||||
- npm test
|
||||
|
||||
- name: build-push
|
||||
image: gcr.io/kaniko-project/executor:debug
|
||||
environment:
|
||||
HARBOR_USERNAME:
|
||||
from_secret: harbor_username
|
||||
HARBOR_PASSWORD:
|
||||
from_secret: harbor_password
|
||||
commands:
|
||||
- echo "{\"auths\":{\"registre.rber.bj\":{\"username\":\"$HARBOR_USERNAME\",\"password\":\"$HARBOR_PASSWORD\"}}}" > /kaniko/.docker/config.json
|
||||
- /kaniko/executor --context=/drone/src --dockerfile=/drone/src/Dockerfile --destination=registre.rber.bj/${{ values.university }}/${{ values.name }}:${DRONE_COMMIT_SHA:0:8} --destination=registre.rber.bj/${{ values.university }}/${{ values.name }}:latest
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
- main
|
||||
event:
|
||||
- push
|
||||
3
templates/node-api/skeleton/.gitignore
vendored
Normal file
3
templates/node-api/skeleton/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
node_modules/
|
||||
.env
|
||||
*.log
|
||||
12
templates/node-api/skeleton/Dockerfile
Normal file
12
templates/node-api/skeleton/Dockerfile
Normal file
@@ -0,0 +1,12 @@
|
||||
FROM node:${{ values.nodeVersion }}-alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY package*.json ./
|
||||
RUN npm install --production
|
||||
|
||||
COPY . .
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
CMD ["npm", "start"]
|
||||
12
templates/node-api/skeleton/catalog-info.yaml
Normal file
12
templates/node-api/skeleton/catalog-info.yaml
Normal file
@@ -0,0 +1,12 @@
|
||||
apiVersion: backstage.io/v1alpha1
|
||||
kind: Component
|
||||
metadata:
|
||||
name: ${{ values.name }}
|
||||
description: ${{ values.description }}
|
||||
annotations:
|
||||
github.com/project-slug: ${{ values.university }}/${{ values.name }}
|
||||
backstage.io/techdocs-ref: dir:.
|
||||
spec:
|
||||
type: service
|
||||
lifecycle: experimental
|
||||
owner: ${{ values.university }}
|
||||
14
templates/node-api/skeleton/package.json
Normal file
14
templates/node-api/skeleton/package.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "${{ values.name }}",
|
||||
"version": "1.0.0",
|
||||
"description": "${{ values.description }}",
|
||||
"main": "src/index.js",
|
||||
"scripts": {
|
||||
"start": "node src/index.js",
|
||||
"dev": "node --watch src/index.js",
|
||||
"test": "echo \"No tests yet\" && exit 0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=${{ values.nodeVersion }}"
|
||||
}
|
||||
}
|
||||
16
templates/node-api/skeleton/src/index.js
Normal file
16
templates/node-api/skeleton/src/index.js
Normal file
@@ -0,0 +1,16 @@
|
||||
const http = require('http');
|
||||
|
||||
const PORT = process.env.PORT || 3000;
|
||||
|
||||
const server = http.createServer((req, res) => {
|
||||
res.writeHead(200, { 'Content-Type': 'application/json' });
|
||||
res.end(JSON.stringify({
|
||||
service: '${{ values.name }}',
|
||||
university: '${{ values.university }}',
|
||||
status: 'running'
|
||||
}));
|
||||
});
|
||||
|
||||
server.listen(PORT, () => {
|
||||
console.log(`${{ values.name }} running on port ${PORT}`);
|
||||
});
|
||||
Reference in New Issue
Block a user