Skip to content

Commit d2511aa

Browse files
committed
Initial version
1 parent d8c678e commit d2511aa

17 files changed

Lines changed: 245 additions & 36 deletions

.dockerignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules
2+
.git
3+
.gitignore
4+
TEST-RESULTS.xml

.gitignore

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,60 +2,30 @@
22
logs
33
*.log
44
npm-debug.log*
5-
yarn-debug.log*
6-
yarn-error.log*
75

86
# Runtime data
97
pids
108
*.pid
119
*.seed
12-
*.pid.lock
1310

1411
# Directory for instrumented libs generated by jscoverage/JSCover
1512
lib-cov
1613

1714
# Coverage directory used by tools like istanbul
1815
coverage
1916

20-
# nyc test coverage
21-
.nyc_output
22-
2317
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
2418
.grunt
2519

26-
# Bower dependency directory (https://bower.io/)
27-
bower_components
28-
2920
# node-waf configuration
3021
.lock-wscript
3122

32-
# Compiled binary addons (https://nodejs.org/api/addons.html)
23+
# Compiled binary addons (http://nodejs.org/api/addons.html)
3324
build/Release
3425

35-
# Dependency directories
36-
node_modules/
37-
jspm_packages/
38-
39-
# TypeScript v1 declaration files
40-
typings/
41-
42-
# Optional npm cache directory
43-
.npm
44-
45-
# Optional eslint cache
46-
.eslintcache
47-
48-
# Optional REPL history
49-
.node_repl_history
50-
51-
# Output of 'npm pack'
52-
*.tgz
53-
54-
# Yarn Integrity file
55-
.yarn-integrity
56-
57-
# dotenv environment variables file
58-
.env
26+
# Dependency directory
27+
# https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git
28+
node_modules
29+
/package-lock.json
5930

60-
# next.js build output
61-
.next
31+
TEST-RESULTS.xml

.vsts-ci.acr.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Build Docker image for this app
2+
# https://docs.microsoft.com/vsts/pipelines/languages/docker?view=vsts
3+
4+
queue: 'Hosted Linux Preview'
5+
6+
variables:
7+
imageName: '$(Build.DefinitionName):$(Build.BuildId)'
8+
# define two more variables dockerId and dockerPassword in the build pipeline in UI
9+
10+
steps:
11+
- script: |
12+
npm install
13+
npm test
14+
docker build -t $(dockerId).azurecr.io/$(imageName) .
15+
docker login -u $(dockerId).azurecr.io -p $pswd $(dockerId).azurecr.io
16+
docker push $(dockerId).azurecr.io/$(imageName)
17+
env:
18+
pswd: $(dockerPassword)
19+
20+
- task: PublishTestResults@2
21+
inputs:
22+
testRunner: JUnit
23+
testResultsFiles: '**/TEST-RESULTS.xml'

.vsts-ci.docker.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Build Docker image for this app
2+
# https://docs.microsoft.com/vsts/pipelines/languages/docker?view=vsts
3+
4+
queue: 'Hosted Linux Preview'
5+
6+
variables:
7+
imageName: '$(Build.DefinitionName):$(Build.BuildId)'
8+
# define two more variables dockerId and dockerPassword in the build pipeline in UI
9+
10+
steps:
11+
- script: |
12+
npm install
13+
npm test
14+
docker build -t $(dockerId)/$(imageName) .
15+
docker login -u $(dockerId) -p $pswd
16+
docker push $(dockerId)/$(imageName)
17+
env:
18+
pswd: $(dockerPassword)
19+
20+
- task: PublishTestResults@2
21+
inputs:
22+
testRunner: JUnit
23+
testResultsFiles: '**/TEST-RESULTS.xml'

.vsts-ci.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Build NodeJS Express app using VSTS
2+
# https://docs.microsoft.com/vsts/pipelines/languages/javascript?view=vsts
3+
4+
queue: 'Hosted Linux Preview'
5+
6+
steps:
7+
- script: |
8+
npm install
9+
npm test
10+
11+
- task: PublishTestResults@2
12+
inputs:
13+
testRunner: JUnit
14+
testResultsFiles: '**/TEST-RESULTS.xml'
15+
16+
- task: ArchiveFiles@2
17+
inputs:
18+
rootFolderOrFile: '$(System.DefaultWorkingDirectory)'
19+
includeRootFolder: false
20+
21+
- task: PublishBuildArtifacts@1

Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Create a container image for the NodeJS sample app
2+
# See http://docs.microsoft.com/vsts/pipelines/languages/docker for more information
3+
FROM node:boron
4+
5+
# Create app directory
6+
WORKDIR /app
7+
8+
# Copy files
9+
COPY . .
10+
11+
# Install app dependencies
12+
RUN npm install
13+
14+
EXPOSE 3000 80
15+
CMD ["npm", "start"]

docs/.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
* text=auto
2+
*.sh text eol=lf

docs/Dockerfile.multistage

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# First stage of multi-stage build
2+
FROM node:boron
3+
WORKDIR /app
4+
5+
# copy the contents of agent working directory on host to workdir in container
6+
COPY . .
7+
8+
# dotnet commands to build, test, and publish
9+
RUN npm install
10+
RUN npm test
11+
12+
# Second stage - Build runtime image
13+
FROM node:boron
14+
WORKDIR /app
15+
COPY . .
16+
RUN npm install
17+
EXPOSE 3000 80
18+
CMD ["npm", "start"]

docs/Dockerfile.test

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# This Dockerfile is for a test container to demonstrate use of docker-compose with VSTS or TFS
2+
# See http://docs.microsoft.com/vsts/pipelines/languages/docker for more information
3+
4+
FROM ubuntu:trusty
5+
RUN apt-get update && apt-get install -yq curl && apt-get clean
6+
WORKDIR /app
7+
ADD docs/test.sh /app/test.sh
8+
CMD ["bash", "test.sh"]

docs/deploy.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Script to deploy the app
2+
# This file is needed only when you want to deploy the app to a Linux VM
3+
4+
# install node
5+
pushd .
6+
cd ~
7+
curl -sL https://deb.nodesource.com/setup_6.x -o nodesource_setup.sh
8+
sudo bash nodesource_setup.sh
9+
sudo apt-get install nodejs -y
10+
sudo apt-get install build-essential -y
11+
12+
# install express
13+
sudo npm install express -y -g
14+
popd
15+
16+
# configure nginx
17+
sudo rm -f /etc/nginx/sites-enabled/default
18+
sudo cp -f ./nginx-config /etc/nginx/sites-available/example
19+
sudo ln -fs /etc/nginx/sites-available/example /etc/nginx/sites-enabled
20+
sudo service nginx reload
21+
22+
# install pm2 and start the node server as a daemon
23+
cd ..
24+
sudo npm install pm2 -g -y
25+
pm2 delete example -s
26+
pm2 start server.js -n example

0 commit comments

Comments
 (0)