Skip to content

Commit

Permalink
Initial
Browse files Browse the repository at this point in the history
  • Loading branch information
Chuxel committed Apr 17, 2019
1 parent b0f7a6d commit 684f7e0
Show file tree
Hide file tree
Showing 11 changed files with 792 additions and 1 deletion.
24 changes: 24 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#-----------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See LICENSE in the project root for license information.
#-----------------------------------------------------------------------------------------

FROM node:8

# Install git, process tools
RUN apt-get update && apt-get -y install git procps

# Install yarn
RUN apt-get install -y curl apt-transport-https lsb-release \
&& curl -sS https://dl.yarnpkg.com/$(lsb_release -is | tr '[:upper:]' '[:lower:]')/pubkey.gpg | apt-key add - \
&& echo "deb https://dl.yarnpkg.com/$(lsb_release -is | tr '[:upper:]' '[:lower:]')/ stable main" | tee /etc/apt/sources.list.d/yarn.list \
&& apt-get update \
&& apt-get install -y yarn

# Install tslint and typescript
RUN npm install -g tslint typescript

# Clean up
RUN apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
8 changes: 8 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "Node.js Sample",
"dockerFile": "Dockerfile",
"appPort": 3000,
"extensions": [
"ms-vscode.vscode-typescript-tslint-plugin"
]
}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -328,3 +328,7 @@ ASALocalRun/

# MFractors (Xamarin productivity tool) working folder
.mfractor/

*.DS_Store

out
16 changes: 16 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}/out/server.js",
"cwd": "${workspaceFolder}",
"preLaunchTask": "compile"
}
]
}
14 changes: 14 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "compile",
"type": "shell",
"command": "npm run compile",
"problemMatcher": "$tsc"

}
]
}
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Node.js Sample Project for Visual Studio Remote - Containers

# Contributing
This is a sample project to go along with the "try" quick start for the VS Code Remote - Containers extension.

Using the sample:

1. **[Windows]** Disable automatic line ending conversion for Git on the *Windows side* (given Linux and Windows use different line endings). Run: `git config --global core.autocrlf false`
2. Follow the steps at [https://aka.ms/vsocde-remote/containers/getting-started](https://aka.ms/vsocde-remote/containers/getting-started).
3. Run `yarn install`
4. Launch the application, edit, and try things out!

Other samples and dev container definitions:
- [Node.js](https://github.com/Microsoft/vscode-dev-containers/tree/master/containers/javascript-node-lts)
- [Node.js & Mongo DB](https://github.com/Microsoft/vscode-dev-containers/tree/master/containers/javascript-node-lts-mongo)
- [Node.js & TypeScript](https://github.com/Microsoft/vscode-dev-containers/tree/master/containers/typescript-node-lts)
- [Azure Functions & Node.js](https://github.com/Microsoft/vscode-dev-containers/tree/master/containers/azure-functions-node-lts)

## Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
Expand All @@ -12,3 +28,8 @@ provided by the bot. You will only need to do this once across all repos using o
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
contact [[email protected]](mailto:[email protected]) with any additional questions or comments.

## License

Copyright © Microsoft Corporation All rights reserved.<br />
Licensed under the MIT License. See LICENSE in the project root for license information.
19 changes: 19 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "docker_web_app",
"private": true,
"version": "1.0.0",
"description": "Node.js on Docker",
"author": "First Last <[email protected]>",
"main": "out/server.js",
"scripts": {
"compile": "node_modules/.bin/tsc -p tsconfig.json",
"start": "node out/server.js"
},
"dependencies": {
"express": "^4.16.1"
},
"devDependencies": {
"@types/express": "^4.16.0",
"tslint": "^5.11.0"
}
}
19 changes: 19 additions & 0 deletions src/server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*-----------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See LICENSE in the project root for license information.
*---------------------------------------------------------------------------------------*/

import * as express from 'express';

// Constants
const PORT = 3000;
const HOST = '0.0.0.0';

// App
const app = express();
app.get('/', (req, res) => {
res.send('Hello world\n');
});

app.listen(PORT, HOST);
console.log(`Running on http://${HOST}:${PORT}`);
13 changes: 13 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"strict": true,
"outDir": "out",
"sourceMap": true
},
"exclude": [
"out",
"node_modules"
]
}
16 changes: 16 additions & 0 deletions tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"defaultSeverity": "error",
"extends": [
"tslint:recommended"
],
"jsRules": {},
"rules": {
"quotemark": false,
"no-console": false,
"indent": [
true,
"tabs"
]
},
"rulesDirectory": []
}
Loading

0 comments on commit 684f7e0

Please sign in to comment.