├── rmbyext └── .gitkeep ├── .github └── FUNDING.yml ├── hello-dock ├── .dockerignore ├── public │ └── favicon.ico ├── src │ ├── main.js │ ├── assets │ │ └── docker-handbook-github.webp │ ├── index.css │ ├── App.vue │ └── components │ │ └── HelloDock.vue ├── package.json └── index.html ├── notes-api ├── api │ ├── .dockerignore │ ├── nodemon.json │ ├── models │ │ ├── index.js │ │ └── Note.js │ ├── jest.config.js │ ├── .env.example │ ├── services │ │ ├── index.js │ │ ├── knex.js │ │ └── notes.js │ ├── .prettierrc.js │ ├── .eslintrc.js │ ├── api │ │ ├── index.js │ │ └── routes │ │ │ └── notes.js │ ├── migrations │ │ └── 20200619195837_create_notes_table.js │ ├── tests │ │ └── e2e │ │ │ └── api │ │ │ ├── index.test.js │ │ │ └── routes │ │ │ └── notes.test.js │ ├── bin │ │ └── www │ ├── knexfile.js │ ├── package.json │ └── app.js ├── Makefile ├── shutdown.sh ├── boot.sh ├── destroy.sh └── build.sh ├── fullstack-notes-application ├── client │ ├── .browserslistrc │ ├── .dockerignore │ ├── jest.config.js │ ├── babel.config.js │ ├── src │ │ ├── libs │ │ │ └── axios.js │ │ ├── assets │ │ │ └── logo.png │ │ ├── main.js │ │ ├── components │ │ │ └── Note.vue │ │ ├── App.vue │ │ ├── router │ │ │ └── index.js │ │ ├── views │ │ │ ├── Home.vue │ │ │ └── Create.vue │ │ └── store │ │ │ └── index.js │ ├── public │ │ ├── favicon.ico │ │ └── index.html │ ├── .editorconfig │ ├── Dockerfile.dev │ ├── webpack.config.js │ ├── Dockerfile │ ├── vue.config.js │ ├── tests │ │ └── unit │ │ │ └── note.spec.js │ ├── .eslintrc.js │ └── package.json ├── api │ ├── .dockerignore │ ├── .env.example │ ├── nodemon.json │ ├── models │ │ ├── index.js │ │ └── Note.js │ ├── jest.config.js │ ├── services │ │ ├── index.js │ │ ├── knex.js │ │ └── notes.js │ ├── .prettierrc.js │ ├── .eslintrc.js │ ├── api │ │ ├── index.js │ │ └── routes │ │ │ └── notes.js │ ├── migrations │ │ └── 20200619195837_create_notes_table.js │ ├── tests │ │ └── e2e │ │ │ └── api │ │ │ ├── index.test.js │ │ │ └── routes │ │ │ └── notes.test.js │ ├── Dockerfile │ ├── Dockerfile.dev │ ├── bin │ │ └── www │ ├── knexfile.js │ ├── package.json │ └── app.js ├── nginx │ ├── Dockerfile.dev │ ├── Dockerfile │ ├── production.conf │ └── development.conf ├── Makefile ├── shutdown.sh ├── boot.sh ├── destroy.sh └── build.sh ├── docker-handbook-github.png ├── custom-nginx └── nginx-1.19.2.tar.gz ├── LICENSE ├── README.md └── .gitignore /rmbyext/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: fhsinchy 2 | custom: buymeacoffee.com/farhanhasin 3 | -------------------------------------------------------------------------------- /hello-dock/.dockerignore: -------------------------------------------------------------------------------- 1 | .git 2 | *Dockerfile* 3 | *docker-compose* 4 | node_modules -------------------------------------------------------------------------------- /notes-api/api/.dockerignore: -------------------------------------------------------------------------------- 1 | .git 2 | *Dockerfile* 3 | *docker-compose* 4 | node_modules -------------------------------------------------------------------------------- /fullstack-notes-application/client/.browserslistrc: -------------------------------------------------------------------------------- 1 | > 1% 2 | last 2 versions 3 | not dead 4 | -------------------------------------------------------------------------------- /notes-api/api/nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "verbose": true, 3 | "ignore": ["*.test.js"] 4 | } -------------------------------------------------------------------------------- /notes-api/api/models/index.js: -------------------------------------------------------------------------------- 1 | const Note = require('./Note'); 2 | 3 | module.exports = { Note }; 4 | -------------------------------------------------------------------------------- /fullstack-notes-application/api/.dockerignore: -------------------------------------------------------------------------------- 1 | .git 2 | *Dockerfile* 3 | *docker-compose* 4 | node_modules -------------------------------------------------------------------------------- /fullstack-notes-application/api/.env.example: -------------------------------------------------------------------------------- 1 | DB_HOST=notes-db 2 | DB_DATABASE=notesdb 3 | DB_PASSWORD=secret -------------------------------------------------------------------------------- /fullstack-notes-application/api/nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "verbose": true, 3 | "ignore": ["*.test.js"] 4 | } -------------------------------------------------------------------------------- /fullstack-notes-application/client/.dockerignore: -------------------------------------------------------------------------------- 1 | .git 2 | *Dockerfile* 3 | *docker-compose* 4 | node_modules -------------------------------------------------------------------------------- /notes-api/api/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | verbose: true, 3 | testEnvironment: 'node', 4 | }; 5 | -------------------------------------------------------------------------------- /docker-handbook-github.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/objects/docker-handbook-projects/master/docker-handbook-github.png -------------------------------------------------------------------------------- /fullstack-notes-application/api/models/index.js: -------------------------------------------------------------------------------- 1 | const Note = require('./Note'); 2 | 3 | module.exports = { Note }; 4 | -------------------------------------------------------------------------------- /fullstack-notes-application/client/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset: '@vue/cli-plugin-unit-jest', 3 | }; 4 | -------------------------------------------------------------------------------- /fullstack-notes-application/api/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | verbose: true, 3 | testEnvironment: 'node', 4 | }; 5 | -------------------------------------------------------------------------------- /hello-dock/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/objects/docker-handbook-projects/master/hello-dock/public/favicon.ico -------------------------------------------------------------------------------- /notes-api/api/.env.example: -------------------------------------------------------------------------------- 1 | DB_HOST=notes-db 2 | DB_PORT=5432 3 | DB_USER=postgres 4 | DB_DATABASE=notesdb 5 | DB_PASSWORD=secret -------------------------------------------------------------------------------- /custom-nginx/nginx-1.19.2.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/objects/docker-handbook-projects/master/custom-nginx/nginx-1.19.2.tar.gz -------------------------------------------------------------------------------- /fullstack-notes-application/nginx/Dockerfile.dev: -------------------------------------------------------------------------------- 1 | FROM nginx:stable-alpine 2 | 3 | COPY ./development.conf /etc/nginx/conf.d/default.conf -------------------------------------------------------------------------------- /fullstack-notes-application/client/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | '@vue/cli-plugin-babel/preset', 4 | ], 5 | }; 6 | -------------------------------------------------------------------------------- /fullstack-notes-application/client/src/libs/axios.js: -------------------------------------------------------------------------------- 1 | import axios from 'axios'; 2 | 3 | export default axios.create({ 4 | baseURL: '/api', 5 | }); 6 | -------------------------------------------------------------------------------- /fullstack-notes-application/nginx/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM nginx:stable-alpine 2 | 3 | EXPOSE 80 4 | 5 | COPY ./production.conf /etc/nginx/conf.d/default.conf -------------------------------------------------------------------------------- /hello-dock/src/main.js: -------------------------------------------------------------------------------- 1 | import { createApp } from 'vue' 2 | import App from './App.vue' 3 | import './index.css' 4 | 5 | createApp(App).mount('#app') 6 | -------------------------------------------------------------------------------- /notes-api/api/services/index.js: -------------------------------------------------------------------------------- 1 | const Knex = require('./knex'); 2 | const NotesService = require('./notes'); 3 | 4 | module.exports = { Knex, NotesService }; 5 | -------------------------------------------------------------------------------- /hello-dock/src/assets/docker-handbook-github.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/objects/docker-handbook-projects/master/hello-dock/src/assets/docker-handbook-github.webp -------------------------------------------------------------------------------- /fullstack-notes-application/client/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/objects/docker-handbook-projects/master/fullstack-notes-application/client/public/favicon.ico -------------------------------------------------------------------------------- /fullstack-notes-application/client/src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/objects/docker-handbook-projects/master/fullstack-notes-application/client/src/assets/logo.png -------------------------------------------------------------------------------- /notes-api/api/.prettierrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | semi: true, 3 | trailingComma: "all", 4 | singleQuote: true, 5 | printWidth: 100, 6 | tabWidth: 2 7 | }; -------------------------------------------------------------------------------- /notes-api/api/services/knex.js: -------------------------------------------------------------------------------- 1 | const knex = require('knex'); 2 | 3 | const config = require('../knexfile'); 4 | 5 | module.exports = knex(config[process.env.NODE_ENV]); 6 | -------------------------------------------------------------------------------- /fullstack-notes-application/api/services/index.js: -------------------------------------------------------------------------------- 1 | const Knex = require('./knex'); 2 | const NotesService = require('./notes'); 3 | 4 | module.exports = { Knex, NotesService }; 5 | -------------------------------------------------------------------------------- /fullstack-notes-application/api/services/knex.js: -------------------------------------------------------------------------------- 1 | const knex = require('knex'); 2 | 3 | const config = require('../knexfile'); 4 | 5 | module.exports = knex(config[process.env.NODE_ENV]); 6 | -------------------------------------------------------------------------------- /fullstack-notes-application/api/.prettierrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | semi: true, 3 | trailingComma: "all", 4 | singleQuote: true, 5 | printWidth: 100, 6 | tabWidth: 2 7 | }; -------------------------------------------------------------------------------- /notes-api/api/models/Note.js: -------------------------------------------------------------------------------- 1 | const { Model } = require('objection'); 2 | 3 | class Note extends Model { 4 | static get tableName() { 5 | return 'notes'; 6 | } 7 | } 8 | 9 | module.exports = Note; 10 | -------------------------------------------------------------------------------- /fullstack-notes-application/api/models/Note.js: -------------------------------------------------------------------------------- 1 | const { Model } = require('objection'); 2 | 3 | class Note extends Model { 4 | static get tableName() { 5 | return 'notes'; 6 | } 7 | } 8 | 9 | module.exports = Note; 10 | -------------------------------------------------------------------------------- /fullstack-notes-application/client/.editorconfig: -------------------------------------------------------------------------------- 1 | [*.{js,jsx,ts,tsx,vue}] 2 | indent_style = space 3 | indent_size = 2 4 | end_of_line = lf 5 | trim_trailing_whitespace = true 6 | insert_final_newline = true 7 | max_line_length = 100 8 | -------------------------------------------------------------------------------- /hello-dock/src/index.css: -------------------------------------------------------------------------------- 1 | #app { 2 | font-family: Avenir, Helvetica, Arial, sans-serif; 3 | -webkit-font-smoothing: antialiased; 4 | -moz-osx-font-smoothing: grayscale; 5 | text-align: center; 6 | color: #2c3e50; 7 | margin-top: 60px; 8 | } 9 | -------------------------------------------------------------------------------- /fullstack-notes-application/client/Dockerfile.dev: -------------------------------------------------------------------------------- 1 | FROM node:lts-alpine 2 | 3 | USER node 4 | 5 | RUN mkdir -p /home/node/app 6 | 7 | WORKDIR /home/node/app 8 | 9 | COPY ./package.json . 10 | RUN npm install 11 | 12 | CMD [ "npm", "run", "serve" ] -------------------------------------------------------------------------------- /fullstack-notes-application/client/webpack.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | module: { 3 | rules: [ 4 | { 5 | test: /\.css$/i, 6 | use: [ 7 | 'css-loader', 8 | ], 9 | }, 10 | ], 11 | }, 12 | }; 13 | -------------------------------------------------------------------------------- /notes-api/api/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: ["prettier"], 3 | extends: [ 4 | 'airbnb-base', 5 | 'plugin:prettier/recommended' 6 | ], 7 | env: { 8 | node: true, 9 | }, 10 | rules: { 11 | "global-require": 0 12 | } 13 | }; 14 | -------------------------------------------------------------------------------- /fullstack-notes-application/api/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: ["prettier"], 3 | extends: [ 4 | 'airbnb-base', 5 | 'plugin:prettier/recommended' 6 | ], 7 | env: { 8 | node: true, 9 | }, 10 | rules: { 11 | "global-require": 0 12 | } 13 | }; 14 | -------------------------------------------------------------------------------- /fullstack-notes-application/client/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:lts-alpine as builder 2 | 3 | WORKDIR /app 4 | 5 | COPY ./package.json . 6 | RUN npm install 7 | 8 | COPY . . 9 | RUN npm run build 10 | 11 | FROM nginx:stable-alpine 12 | 13 | EXPOSE 80 14 | 15 | COPY --from=builder /app/dist /usr/share/nginx/html -------------------------------------------------------------------------------- /notes-api/api/api/index.js: -------------------------------------------------------------------------------- 1 | const { Router } = require('express'); 2 | 3 | const routes = Router(); 4 | 5 | routes.get('/', (req, res) => { 6 | res.status(200).json({ 7 | error: false, 8 | message: 'Bonjour, mon ami', 9 | }); 10 | }); 11 | 12 | require('./routes/notes')(routes); 13 | 14 | module.exports = routes; 15 | -------------------------------------------------------------------------------- /hello-dock/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hello-dock", 3 | "version": "0.0.0", 4 | "scripts": { 5 | "dev": "vite", 6 | "build": "vite build" 7 | }, 8 | "dependencies": { 9 | "vue": "^3.0.0-rc.1" 10 | }, 11 | "devDependencies": { 12 | "vite": "^1.0.0-rc.1", 13 | "@vue/compiler-sfc": "^3.0.0-rc.1" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /fullstack-notes-application/api/api/index.js: -------------------------------------------------------------------------------- 1 | const { Router } = require('express'); 2 | 3 | const routes = Router(); 4 | 5 | routes.get('/', (req, res) => { 6 | res.status(200).json({ 7 | error: false, 8 | message: 'Bonjour, mon ami', 9 | }); 10 | }); 11 | 12 | require('./routes/notes')(routes); 13 | 14 | module.exports = routes; 15 | -------------------------------------------------------------------------------- /hello-dock/src/App.vue: -------------------------------------------------------------------------------- 1 | 5 | 6 | 16 | -------------------------------------------------------------------------------- /fullstack-notes-application/client/src/main.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue'; 2 | import App from './App.vue'; 3 | import router from './router'; 4 | import store from './store'; 5 | 6 | import 'mini.css/dist/mini-default.min.css'; 7 | 8 | Vue.config.productionTip = false; 9 | 10 | new Vue({ 11 | router, 12 | store, 13 | render: (h) => h(App), 14 | }).$mount('#app'); 15 | -------------------------------------------------------------------------------- /fullstack-notes-application/nginx/production.conf: -------------------------------------------------------------------------------- 1 | upstream client { 2 | server notes-client:80; 3 | } 4 | 5 | upstream api { 6 | server notes-api:3000; 7 | } 8 | 9 | server { 10 | location / { 11 | proxy_pass http://client; 12 | } 13 | 14 | location /api { 15 | rewrite /api/(.*) /$1 break; 16 | proxy_pass http://api; 17 | } 18 | } -------------------------------------------------------------------------------- /fullstack-notes-application/client/vue.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | devServer: { 3 | disableHostCheck: true, 4 | }, 5 | chainWebpack: (config) => { 6 | config 7 | .plugin('html') 8 | .tap((args) => { 9 | // eslint-disable-next-line no-param-reassign 10 | args[0].title = 'Notes'; 11 | return args; 12 | }); 13 | }, 14 | }; 15 | -------------------------------------------------------------------------------- /hello-dock/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | The Docker Handbook 8 | 9 | 10 |
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /notes-api/api/migrations/20200619195837_create_notes_table.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable func-names */ 2 | 3 | exports.up = function (knex) { 4 | return knex.schema.createTable('notes', (table) => { 5 | table.increments(); 6 | table.string('title').notNullable(); 7 | table.text('content').notNullable(); 8 | }); 9 | }; 10 | 11 | exports.down = function (knex) { 12 | return knex.schema.dropTable('notes'); 13 | }; 14 | -------------------------------------------------------------------------------- /fullstack-notes-application/api/migrations/20200619195837_create_notes_table.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable func-names */ 2 | 3 | exports.up = function (knex) { 4 | return knex.schema.createTable('notes', (table) => { 5 | table.increments(); 6 | table.string('title').notNullable(); 7 | table.text('content').notNullable(); 8 | }); 9 | }; 10 | 11 | exports.down = function (knex) { 12 | return knex.schema.dropTable('notes'); 13 | }; 14 | -------------------------------------------------------------------------------- /notes-api/api/tests/e2e/api/index.test.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-undef */ 2 | 3 | const request = require('supertest'); 4 | 5 | const app = require('../../../app'); 6 | 7 | describe('GET /', () => { 8 | test('Responds with 200 status code and a message', async () => { 9 | const response = await request(app).get('/'); 10 | 11 | expect(response.status).toBe(200); 12 | expect(response.body.message).toEqual('Bonjour, mon ami'); 13 | }); 14 | }); 15 | -------------------------------------------------------------------------------- /fullstack-notes-application/api/tests/e2e/api/index.test.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-undef */ 2 | 3 | const request = require('supertest'); 4 | 5 | const app = require('../../../app'); 6 | 7 | describe('GET /', () => { 8 | test('Responds with 200 status code and a message', async () => { 9 | const response = await request(app).get('/'); 10 | 11 | expect(response.status).toBe(200); 12 | expect(response.body.message).toEqual('Bonjour, mon ami'); 13 | }); 14 | }); 15 | -------------------------------------------------------------------------------- /fullstack-notes-application/client/src/components/Note.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 22 | -------------------------------------------------------------------------------- /fullstack-notes-application/client/src/App.vue: -------------------------------------------------------------------------------- 1 | 11 | 12 | 19 | -------------------------------------------------------------------------------- /notes-api/Makefile: -------------------------------------------------------------------------------- 1 | ################# 2 | ## Production ## 3 | ################ 4 | start: 5 | ./boot.sh 6 | build: 7 | ./build.sh 8 | stop: 9 | ./shutdown.sh 10 | destroy: stop 11 | ./destroy.sh 12 | 13 | ################## 14 | ## Development ## 15 | ################# 16 | dev-start: 17 | docker-compose up --detach 18 | dev-build: 19 | docker-compose up --detach --build; docker-compose exec api npm run db:migrate 20 | dev-shell: 21 | docker-compose exec api bash 22 | dev-stop: 23 | docker-compose stop 24 | dev-destroy: 25 | docker-compose down --volume -------------------------------------------------------------------------------- /fullstack-notes-application/api/Dockerfile: -------------------------------------------------------------------------------- 1 | # stage one 2 | FROM node:lts-alpine as builder 3 | 4 | # install dependencies for node-gyp 5 | RUN apk add --no-cache python2 make g++ 6 | 7 | WORKDIR /app 8 | 9 | COPY ./package.json . 10 | RUN npm install --only=prod 11 | 12 | # stage two 13 | FROM node:lts-alpine 14 | 15 | EXPOSE 3000 16 | ENV NODE_ENV=production 17 | 18 | USER node 19 | RUN mkdir -p /home/node/app 20 | WORKDIR /home/node/app 21 | 22 | COPY . . 23 | COPY --from=builder /app/node_modules /home/node/app/node_modules 24 | 25 | CMD [ "node", "bin/www" ] 26 | -------------------------------------------------------------------------------- /fullstack-notes-application/Makefile: -------------------------------------------------------------------------------- 1 | ################# 2 | ## Production ## 3 | ################ 4 | start: 5 | ./boot.sh 6 | build: 7 | ./build.sh 8 | stop: 9 | ./shutdown.sh 10 | destroy: stop 11 | ./destroy.sh 12 | 13 | ################## 14 | ## Development ## 15 | ################# 16 | dev-start: 17 | docker-compose up --detach 18 | dev-build: 19 | docker-compose up --detach --build; docker-compose exec api npm run db:migrate 20 | dev-shell: 21 | docker-compose exec api bash 22 | dev-stop: 23 | docker-compose stop 24 | dev-destroy: 25 | docker-compose down --volume -------------------------------------------------------------------------------- /fullstack-notes-application/nginx/development.conf: -------------------------------------------------------------------------------- 1 | upstream client { 2 | server client:8080; 3 | } 4 | 5 | upstream api { 6 | server api:3000; 7 | } 8 | 9 | server { 10 | location / { 11 | proxy_pass http://client; 12 | } 13 | 14 | location /sockjs-node { 15 | proxy_pass http://client; 16 | proxy_http_version 1.1; 17 | proxy_set_header Upgrade $http_upgrade; 18 | proxy_set_header Connection "Upgrade"; 19 | } 20 | 21 | location /api { 22 | rewrite /api/(.*) /$1 break; 23 | proxy_pass http://api; 24 | } 25 | } -------------------------------------------------------------------------------- /fullstack-notes-application/api/Dockerfile.dev: -------------------------------------------------------------------------------- 1 | # stage one 2 | FROM node:lts-alpine as builder 3 | 4 | # install dependencies for node-gyp 5 | RUN apk add --no-cache python2 make g++ 6 | 7 | WORKDIR /app 8 | 9 | COPY ./package.json . 10 | RUN npm install 11 | 12 | # stage two 13 | FROM node:lts-alpine 14 | 15 | ENV NODE_ENV=development 16 | 17 | USER node 18 | RUN mkdir -p /home/node/app 19 | WORKDIR /home/node/app 20 | 21 | COPY . . 22 | COPY --from=builder /app/node_modules /home/node/app/node_modules 23 | 24 | CMD [ "./node_modules/.bin/nodemon", "--config", "nodemon.json", "bin/www" ] 25 | -------------------------------------------------------------------------------- /fullstack-notes-application/client/src/router/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue'; 2 | import VueRouter from 'vue-router'; 3 | import Home from '../views/Home.vue'; 4 | 5 | Vue.use(VueRouter); 6 | 7 | const routes = [ 8 | { 9 | path: '/', 10 | name: 'Home', 11 | component: Home, 12 | }, 13 | { 14 | path: '/notes/create', 15 | name: 'Create', 16 | component: () => import('../views/Create.vue'), 17 | }, 18 | ]; 19 | 20 | const router = new VueRouter({ 21 | mode: 'history', 22 | base: process.env.BASE_URL, 23 | routes, 24 | }); 25 | 26 | export default router; 27 | -------------------------------------------------------------------------------- /fullstack-notes-application/client/tests/unit/note.spec.js: -------------------------------------------------------------------------------- 1 | import { shallowMount } from '@vue/test-utils'; 2 | import Note from '@/components/Note.vue'; 3 | 4 | describe('Note.vue', () => { 5 | it('renders props.note when passed', () => { 6 | const note = { 7 | title: 'Lorem ipsum', 8 | content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', 9 | }; 10 | const wrapper = shallowMount(Note, { 11 | propsData: { note }, 12 | }); 13 | expect(wrapper.props().note).toBe(note); 14 | }); 15 | }); 16 | -------------------------------------------------------------------------------- /fullstack-notes-application/client/src/views/Home.vue: -------------------------------------------------------------------------------- 1 | 12 | 13 | 28 | -------------------------------------------------------------------------------- /fullstack-notes-application/client/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | env: { 4 | node: true, 5 | }, 6 | extends: [ 7 | 'plugin:vue/essential', 8 | '@vue/airbnb', 9 | ], 10 | parserOptions: { 11 | parser: 'babel-eslint', 12 | }, 13 | rules: { 14 | 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off', 15 | 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off', 16 | }, 17 | overrides: [ 18 | { 19 | files: [ 20 | '**/__tests__/*.{j,t}s?(x)', 21 | '**/tests/unit/**/*.spec.{j,t}s?(x)', 22 | ], 23 | env: { 24 | jest: true, 25 | }, 26 | }, 27 | ], 28 | }; 29 | -------------------------------------------------------------------------------- /fullstack-notes-application/client/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | <%= htmlWebpackPlugin.options.title %> 9 | 10 | 11 | 14 |
15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /notes-api/api/bin/www: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | /** 4 | * Module dependencies. 5 | */ 6 | 7 | const http = require('http'); 8 | const dotenv = require('dotenv'); 9 | const app = require('../app'); 10 | 11 | dotenv.config(); 12 | 13 | /** 14 | * Get port from environment and store in Express. 15 | */ 16 | 17 | const host = process.env.HOST || 'http://127.0.0.1'; 18 | const port = process.env.PORT || 3000; 19 | app.set('port', port); 20 | 21 | /** 22 | * Create HTTP server. 23 | */ 24 | 25 | const server = http.createServer(app); 26 | 27 | /** 28 | * Listen on provided port, on all network interfaces. 29 | */ 30 | // eslint-disable-next-line no-console 31 | console.log(`app running -> ${host}:${port}`); 32 | server.listen(port); 33 | -------------------------------------------------------------------------------- /notes-api/shutdown.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | API_CONTAINER_NAME="notes-api" 5 | DB_CONTAINER_NAME="notes-db" 6 | 7 | if docker container ls | grep -q $API_CONTAINER_NAME; 8 | then 9 | printf "stopping api container --->\n" 10 | docker container stop $API_CONTAINER_NAME; 11 | printf "api container stopped --->\n" 12 | else 13 | printf "api container not found --->\n" 14 | fi 15 | 16 | printf "\n" 17 | 18 | if docker container ls | grep -q $DB_CONTAINER_NAME; 19 | then 20 | printf "stopping db container --->\n" 21 | docker container stop $DB_CONTAINER_NAME; 22 | printf "db container stopped --->\n" 23 | else 24 | printf "db container not found --->\n" 25 | fi 26 | 27 | printf "\n" 28 | 29 | printf "shutdown script finished\n\n" -------------------------------------------------------------------------------- /notes-api/boot.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | API_CONTAINER_NAME="notes-api" 5 | DB_CONTAINER_NAME="notes-db" 6 | 7 | if docker container ls --all | grep -q $DB_CONTAINER_NAME; 8 | then 9 | printf "starting db container --->\n" 10 | docker container start $DB_CONTAINER_NAME; 11 | printf "db container started --->\n" 12 | else 13 | printf "db container not found --->\n" 14 | fi 15 | 16 | printf "\n" 17 | 18 | if docker container ls --all | grep -q $API_CONTAINER_NAME; 19 | then 20 | printf "starting api container --->\n" 21 | docker container start $API_CONTAINER_NAME; 22 | printf "api container started --->\n" 23 | else 24 | printf "api container not found --->\n" 25 | fi 26 | 27 | printf "\n" 28 | 29 | printf "boot script finished\n\n" -------------------------------------------------------------------------------- /fullstack-notes-application/api/bin/www: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | /** 4 | * Module dependencies. 5 | */ 6 | 7 | const http = require('http'); 8 | const dotenv = require('dotenv'); 9 | const app = require('../app'); 10 | 11 | dotenv.config(); 12 | 13 | /** 14 | * Get port from environment and store in Express. 15 | */ 16 | 17 | const host = process.env.HOST || 'http://127.0.0.1'; 18 | const port = process.env.PORT || 3000; 19 | app.set('port', port); 20 | 21 | /** 22 | * Create HTTP server. 23 | */ 24 | 25 | const server = http.createServer(app); 26 | 27 | /** 28 | * Listen on provided port, on all network interfaces. 29 | */ 30 | // eslint-disable-next-line no-console 31 | console.log(`app running -> ${host}:${port}`); 32 | server.listen(port); 33 | -------------------------------------------------------------------------------- /hello-dock/src/components/HelloDock.vue: -------------------------------------------------------------------------------- 1 | 15 | 16 | 24 | -------------------------------------------------------------------------------- /notes-api/api/knexfile.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | development: { 3 | client: 'pg', 4 | connection: { 5 | host: process.env.DB_HOST, 6 | port: 5432, 7 | user: 'postgres', 8 | password: process.env.DB_PASSWORD, 9 | database: process.env.DB_DATABASE, 10 | }, 11 | }, 12 | 13 | test: { 14 | client: 'sqlite3', 15 | connection: ':memory:', 16 | useNullAsDefault: true, 17 | }, 18 | 19 | staging: { 20 | client: 'pg', 21 | connection: { 22 | host: process.env.DB_HOST, 23 | port: 5432, 24 | user: 'postgres', 25 | password: process.env.DB_PASSWORD, 26 | database: process.env.DB_DATABASE, 27 | }, 28 | }, 29 | 30 | production: { 31 | client: 'pg', 32 | connection: { 33 | host: process.env.DB_HOST, 34 | port: 5432, 35 | user: 'postgres', 36 | password: process.env.DB_PASSWORD, 37 | database: process.env.DB_DATABASE, 38 | }, 39 | }, 40 | }; 41 | -------------------------------------------------------------------------------- /fullstack-notes-application/api/knexfile.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | development: { 3 | client: 'pg', 4 | connection: { 5 | host: process.env.DB_HOST, 6 | port: 5432, 7 | user: 'postgres', 8 | password: process.env.DB_PASSWORD, 9 | database: process.env.DB_DATABASE, 10 | }, 11 | }, 12 | 13 | test: { 14 | client: 'sqlite3', 15 | connection: ':memory:', 16 | useNullAsDefault: true, 17 | }, 18 | 19 | staging: { 20 | client: 'pg', 21 | connection: { 22 | host: process.env.DB_HOST, 23 | port: 5432, 24 | user: 'postgres', 25 | password: process.env.DB_PASSWORD, 26 | database: process.env.DB_DATABASE, 27 | }, 28 | }, 29 | 30 | production: { 31 | client: 'pg', 32 | connection: { 33 | host: process.env.DB_HOST, 34 | port: 5432, 35 | user: 'postgres', 36 | password: process.env.DB_PASSWORD, 37 | database: process.env.DB_DATABASE, 38 | }, 39 | }, 40 | }; 41 | -------------------------------------------------------------------------------- /fullstack-notes-application/client/src/views/Create.vue: -------------------------------------------------------------------------------- 1 |