$ git clone https://bitbucket.org/maximilianou/messageapp educacion@educacion:~/src/docker12factor/messageapp$ git status educacion@educacion:~/src/docker12factor/messageapp$ git add . educacion@educacion:~/src/docker12factor/messageapp$ git commit -m 'first commit' educacion@educacion:~/src/docker12factor/messageapp$ git push origin master
Think the best of others
Monday, December 17, 2018
Docker 12 Factor Methodology Step 01 Codebase Repository git
Docker 12 Factors Methodology Step 00 Application NodeJS Debian REST api
root@educacion:/home/educacion/src/docker12factor# apt install dirmngr root@educacion:/home/educacion/src/docker12factor# apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4 root@educacion:/home/educacion/src/docker12factor# echo "deb http://repo.mongodb.org/apt/debian stretch/mongodb-org/4.0 main" | tee /etc/apt/sources.list.d/mongodb-org-4.0.list root@educacion:/home/educacion/src/docker12factor# apt update -y root@educacion:/home/educacion/src/docker12factor# apt install -y mongodb-org root@educacion:/home/educacion/src/docker12factor# service mongod status root@educacion:/home/educacion/src/docker12factor# service mongod start root@educacion:/home/educacion/src/docker12factor# mongo > help; > exit; educacion@educacion:~/src/docker12factor$ npm init educacion@educacion:~/src/docker12factor$ npm get prefix /usr educacion@educacion:~/src/docker12factor$ npm set prefix /usr/local educacion@educacion:~/src/docker12factor$ npm get prefix /usr/local educacion@educacion:~/src/docker12factor$ npm install sails -g educacion@educacion:~/src/docker12factor$ sails new messageApp Choose a template for your new Sails app: 1. Web App · Extensible project with auth, login, & password recovery 2. Empty · An empty Sails app, yours to configure (type "?" for help, orto cancel) ? 2 educacion@educacion:~/src/docker12factor$ cd messageApp educacion@educacion:~/src/docker12factor$ sails generate api message educacion@educacion:~/src/docker12factor$ sails lift educacion@educacion:~/src/docker12factor/messageApp$ curl --header "Content-Type: application/json" --request POST --data '"text":"Hello Javascript FullStack DevOps"}' http://localhost:1337/message educacion@educacion:~/src/docker12factor/messageApp$ curl --header "Content-Type: application/json" --request POST --data '"text":"Hola Javascript FullStack DevOps"}' http://localhost:1337/message educacion@educacion:~/src/docker12factor/messageApp$ curl http://localhost:1337/message/ [ { "text": "Hello Javascript FullStack DevOps", "createdAt": 1545061317524, "updatedAt": 1545061317524, "id": 1 }, { "text": "Hola Javascript FullStack DevOps", "createdAt": 1545061415586, "updatedAt": 1545061415586, "id": 2 } ] educacion@educacion:~/src/docker12factor/messageApp$ curl --header "Content-Type: application/json" --request PUT --data '{"ext":"Hello Javascript FullStack !! DevOps !!"}' http://localhost:1337/message/2 educacion@educacion:~/src/docker12factor/messageApp$ curl http://localhost:1337/message/ [ { "text": "Hello Javascript FullStack DevOps", "createdAt": 1545061317524, "updatedAt": 1545061317524, "id": 1 }, { "text": "Hello Javascript FullStack !! DevOps !!", "createdAt": 1545061415586, "updatedAt": 1545065865167, "id": 2 } ] educacion@educacion:~/src/docker12factor/messageApp$ curl --request DELETE http://localhost:1337/message/1 educacion@educacion:~/src/docker12factor/messageApp$ curl http://localhost:1337/message/ [ { "text": "Hello Javascript FullStack !! DevOps !!", "createdAt": 1545061415586, "updatedAt": 1545065865167, "id": 2 } ] Reference: https://github.com/docker/labs/blob/master/12factor/00_application.md https://docs.mongodb.com/manual/tutorial/install-mongodb-on-debian/
Tuesday, December 4, 2018
docker nodejs IDE visual studio 2018
educacion@educacion:~/src/docker02$ cat Dockerfile FROM node WORKDIR /code RUN npm install -g nodemon COPY package.json /code/package.json RUN npm install && npm ls RUN mv /code/node_modules /node_modules COPY . /code CMD ["npm", "start"] educacion@educacion:~/src/docker02$ cat docker-compose.yml version: "2" services: web: build: . command: nodemon -L --inspect=0.0.0.0:5858 volumes: - .:/code ports: - "8000:8000" - "5858:5858" educacion@educacion:~/src/docker02$ cat package.json { "main": "app.js", "dependencies": { "express": "~4.14.0", "express-handlebars": "~3.0.0" } } educacion@educacion:~/src/docker02$ cat app.js const express = require('express'); const expressHandlebars = require('express-handlebars'); const http = require('http'); const PORT = 8000; const LINES = [ "One thing at the time.", "Start from the beginning!", "Up to date!", "As Simple As Possible", ]; let lineIndex = 0; const app = express(); app.engine('html', expressHandlebars()); app.set('view engine', 'html'); app.set('views', __dirname); app.get('/', (req, res) => { let message = LINES[lineIndex]; lineIndex += 1; if (lineIndex >= LINES.length) { lineIndex = 0; } res.render('index', {message: message}); }); http.Server(app).listen(PORT, () => { console.log("HTTP server listening on port %s", PORT); }); educacion@educacion:~/src/docker02$ cat index.html < !doctype html> < html> < head> < meta http-equiv="refresh" content="2"> < style type="text/css"> .sample_docker_nodejs { font-family: Helvetica, Arial, sans-serif; font-weight: 600; font-size: 56pt; text-transform: uppercase; text-align: center; background: #3c3; color: white; } < /style> < /head> < body class='sample_docker_nodejs'>“{{message}}”