Skip to content

Commit 8f6fa9a

Browse files
committed
Initial Commit
0 parents  commit 8f6fa9a

11 files changed

+656
-0
lines changed

.dockerignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

.editorconfig

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# EditorConfig is awesome: https://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
# Unix-style newlines with a newline ending every file
7+
[*]
8+
end_of_line = lf
9+
insert_final_newline = true
10+
11+
# Set charset and 1 tab indent
12+
[*.{js,jsx,sol,md,wasm,py,yaml,yml,json,css}]
13+
charset = utf-8
14+
indent_style = tab
15+
16+
# Set charset and 1 tab indent
17+
[Dockerfile]
18+
charset = utf-8
19+
indent_style = tab
20+
21+
# Tab indentation (no size specified)
22+
[Makefile]
23+
indent_style = tab

.gitignore

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# See https://help.github.com/ignore-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
6+
# testing
7+
/coverage
8+
9+
# production
10+
/build
11+
12+
# misc
13+
.DS_Store
14+
.env.local
15+
.env.development.local
16+
.env.test.local
17+
.env.production.local
18+
19+
npm-debug.log*
20+
yarn-debug.log*
21+
yarn-error.log*
22+
23+
# Webstorms IDE files
24+
.idea/**/workspace.xml
25+
.idea/**/tasks.xml
26+
.idea/**/usage.statistics.xml
27+
.idea/**/dictionaries
28+
.idea/**/shelf
29+
.idea/**/dataSources/
30+
.idea/**/dataSources.ids
31+
.idea/**/dataSources.local.xml
32+
.idea/**/sqlDataSources.xml
33+
.idea/**/dynamic.xml
34+
.idea/**/uiDesigner.xml
35+
.idea/**/dbnavigator.xml
36+
.idea/httpRequests

.gitlab-ci.yml

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# This file is a template, and might need editing before it works on your project.
2+
# Official docker image.
3+
image: docker:dind
4+
5+
variables:
6+
# When using dind service we need to instruct docker, to talk with the
7+
# daemon started inside of the service. The daemon is available with
8+
# a network connection instead of the default /var/run/docker.sock socket.
9+
#
10+
# The 'docker' hostname is the alias of the service container as described at
11+
# https://docs.gitlab.com/ee/ci/docker/using_docker_images.html#accessing-the-services
12+
#
13+
# Note that if you're using Kubernetes executor, the variable should be set to
14+
# tcp://localhost:2375 because of how Kubernetes executor connects services
15+
# to the job container
16+
DOCKER_HOST: tcp://localhost:2375/
17+
# When using dind, it's wise to use the overlayfs driver for
18+
# improved performance.
19+
DOCKER_DRIVER: overlay2
20+
21+
# This folder is cached between builds
22+
# http://docs.gitlab.com/ce/ci/yaml/README.html#cache
23+
cache:
24+
paths:
25+
- node_modules/
26+
27+
services:
28+
- docker:dind
29+
30+
before_script:
31+
- docker info
32+
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
33+
34+
build-master:
35+
stage: build
36+
script:
37+
- docker pull "$CI_REGISTRY_IMAGE" || true
38+
- docker build --pull --cache-from "$CI_REGISTRY_IMAGE" -t "$CI_REGISTRY_IMAGE" .
39+
- docker push "$CI_REGISTRY_IMAGE"
40+
only:
41+
- master
42+
43+
build:
44+
stage: build
45+
script:
46+
- docker pull "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" || docker pull "$CI_REGISTRY_IMAGE" || true
47+
- docker build --pull --cache-from "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" --cache-from "$CI_REGISTRY_IMAGE" -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" .
48+
- docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
49+
except:
50+
- master

Dockerfile

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM node:10
2+
3+
RUN mkdir /code
4+
WORKDIR /code
5+
6+
ADD package.json /code
7+
ADD package-lock.json /code
8+
9+
RUN npm install
10+
11+
ADD . /code
12+
13+
EXPOSE 3000
14+
15+
CMD npm run start

api/index.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
var express = require('express');
2+
var router = express.Router();
3+
4+
/* GET home page. */
5+
router.get('/', function(req, res, next) {
6+
res.render('index', { title: 'Express' });
7+
});
8+
9+
module.exports = router;

api/users.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
var express = require('express');
2+
var router = express.Router();
3+
4+
/* GET users listing. */
5+
router.get('/', function(req, res, next) {
6+
res.send('respond with a resource');
7+
});
8+
9+
module.exports = router;

app.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const express = require('express');
2+
const path = require('path');
3+
const cookieParser = require('cookie-parser');
4+
const logger = require('morgan');
5+
6+
const apiRouter = require('./api/index');
7+
8+
const app = express();
9+
10+
app.use(logger('dev'));
11+
app.use(express.json());
12+
app.use(express.urlencoded({ extended: false }));
13+
app.use(cookieParser());
14+
15+
app.use('/api', apiRouter);
16+
17+
module.exports = app;

bin/www

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#!/usr/bin/env node
2+
3+
/**
4+
* Module dependencies.
5+
*/
6+
7+
let app = require('../app');
8+
let debug = require('debug')('client:server');
9+
let http = require('http');
10+
11+
/**
12+
* Get port from environment and store in Express.
13+
*/
14+
15+
let port = normalizePort(process.env.PORT || '3000');
16+
app.set('port', port);
17+
18+
/**
19+
* Create HTTP server.
20+
*/
21+
22+
let server = http.createServer(app);
23+
24+
/**
25+
* Listen on provided port, on all network interfaces.
26+
*/
27+
28+
server.listen(port);
29+
server.on('error', onError);
30+
server.on('listening', onListening);
31+
32+
/**
33+
* Normalize a port into a number, string, or false.
34+
*/
35+
36+
function normalizePort(val) {
37+
let port = parseInt(val, 10);
38+
39+
if (isNaN(port)) {
40+
// named pipe
41+
return val;
42+
}
43+
44+
if (port >= 0) {
45+
// port number
46+
return port;
47+
}
48+
49+
return false;
50+
}
51+
52+
/**
53+
* Event listener for HTTP server "error" event.
54+
*/
55+
56+
function onError(error) {
57+
if (error.syscall !== 'listen') {
58+
throw error;
59+
}
60+
61+
let bind = typeof port === 'string'
62+
? 'Pipe ' + port
63+
: 'Port ' + port;
64+
65+
// handle specific listen errors with friendly messages
66+
switch (error.code) {
67+
case 'EACCES':
68+
console.error(bind + ' requires elevated privileges');
69+
process.exit(1);
70+
break;
71+
case 'EADDRINUSE':
72+
console.error(bind + ' is already in use');
73+
process.exit(1);
74+
break;
75+
default:
76+
throw error;
77+
}
78+
}
79+
80+
/**
81+
* Event listener for HTTP server "listening" event.
82+
*/
83+
84+
function onListening() {
85+
let addr = server.address();
86+
let bind = typeof addr === 'string'
87+
? 'pipe ' + addr
88+
: 'port ' + addr.port;
89+
debug('Listening on ' + bind);
90+
}

0 commit comments

Comments
 (0)