diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000000000000000000000000000000000000..29b5af12803d3757044d41d36f44dbbbf1746a6b --- /dev/null +++ b/.editorconfig @@ -0,0 +1,23 @@ +# http://editorconfig.org +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_style = space +indent_size = 4 +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false + +[Makefile] +charset = utf-8 +end_of_line = lf +indent_style = tab +insert_final_newline = true +trim_trailing_whitespace = true + +[*.{yml,yaml}] +indent_size = 2 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..44476bb2dd1790d9156f247f2bbf30943224cc0c --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +./local diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..a9e1b63a85e529345ab9db280883778e246fb488 --- /dev/null +++ b/Makefile @@ -0,0 +1,92 @@ +.DEFAULT_GOAL := default +SHELL = /usr/bin/env bash -eo pipefail + + + +MKFILE_DIR = $(abspath $(dir $(abspath $(lastword $(MAKEFILE_LIST))))) +LOCAL_DIR = $(MKFILE_DIR)/.local + +BIN_DIR = $(LOCAL_DIR)/bin +TEMP_DIR = $(LOCAL_DIR)/tmp +DATA_DIR = $(LOCAL_DIR)/data +LOG_DIR = $(LOCAL_DIR)/logs + + + +PLATFORM := $(shell if echo $$OSTYPE | grep -q darwin; then echo darwin; else echo linux; fi) + + + +MONGO_VERSION = +MONGO_URL = + + +REACT_APP_VERSION = '3.4.1' + + + + +install-stack: + echo '# mongo' + echo '# node' + echo '# npm' + +install-deps: + cd $(MKFILE_DIR)/app/client \ + && npm install + cd $(MKFILE_DIR)/app/server \ + && npm install + + + +run-db: + mkdir -p $(LOG_DIR) $(DATA_DIR)/db + mongod --config ./conf/mongod.conf + + +build: + cd $(MKFILE_DIR)/app/client \ + && rm -rf ./build \ + && PUBLIC_URL=http://localhost:3000 \ + npm run build + + +run-local: + cd $(MKFILE_DIR)/app/server \ + && npm run dev + + +test: + cd $(MKFILE_DIR)/app/client \ + && npm run test + cd $(MKFILE_DIR)/app/server \ + && npm run test + + + +test-local: + cd $(MKFILE_DIR)/app/client \ + && npm run test:dev + + + + + +.PHONY: update-react-app-template +update-react-app-template: + rm -rf $(TEMP_DIR)/npm-project-scope + mkdir -p $(TEMP_DIR)/npm-project-scope + cd $(TEMP_DIR)/npm-project-scope \ + && npm install --save-dev react-scripts@$(REACT_APP_VERSION) \ + && npm init react-app $(TEMP_DIR)/npm-project-scope/cra + cp \ + $(TEMP_DIR)/npm-project-scope/cra/src/* \ + $(MKFILE_DIR)/app/client/src/ + cp \ + $(TEMP_DIR)/npm-project-scope/cra/public/* \ + $(MKFILE_DIR)/app/client/public/ + cp \ + $(TEMP_DIR)/npm-project-scope/cra/package.json \ + $(MKFILE_DIR)/app/client/ + rm -rf \ + $(MKFILE_DIR)/app/client/src/logo.svg diff --git a/README.md b/README.md new file mode 100644 index 0000000000000000000000000000000000000000..443130dab9b7d8e9a507ce18a145f662e2b5c4b1 --- /dev/null +++ b/README.md @@ -0,0 +1,51 @@ +Lecture: DevOps - application +============================= + + +This repository contains the [application](./app/README.md) that should be used as *deployable workload* in the +[exercise](https://github.com/lucendio/lecture-devops-material/blob/master/exercise.md) implementation. + + +### Getting started + +For more information on the app, please have a look into its [README](./app/README.md). +The `Makefile` is the main entry point for this repository. It's meant to be used for documentation purposes and local + invokation only. The following the following commands are available: + + +#### `make install-deps` + +* install npm dependencies for server and client + + +#### `make build` + +* start a local mongo database + + +#### `make run-db` + +* start a local mongo database + + +#### `make run-local` + +* start server with development configuration +* file watcher enabled + + +#### `make test-local` + +* run client tests + + +#### `make test` + +* run client tests in [CI mode](https://jestjs.io/docs/en/cli.html#--ci) (exits regardless of the test outcome; closed tty) +* run server tests in [CI mode](https://jestjs.io/docs/en/cli.html#--ci) (exits regardless of the test outcome; closed tty) + + +### Notes + +* the `Makefile` shows how to interact with the code base, it is not recommended to invoke make targets from the CI/CD, +but rather use automation-specific interfaces (e.g. `Jenkinsfile`, `.travis.yml`, etc.). diff --git a/app/README.md b/app/README.md index 7ed129840508bd3ab95dec77983bca0295c98bc2..71b677f5b25f12e0132e6840050b4f57934bc2d6 100644 --- a/app/README.md +++ b/app/README.md @@ -1,12 +1,34 @@ -# React, Node Js, and MongoDB microservices-based application deployment on Kubernetes +Todo-App +======== -This complete article can be check at [medium.com/@aamirpinger](https://medium.com/@aamirpinger/react-express-node-js-and-mongodb-mern-stack-microservices-based-application-deployment-on-ec4607cec74d) -This is a simple ToDo application build using MERN Stack. It consist of: -1. The Front-end application is build using React. -2. The backend is build using Node Js, Express, and mongoose. -3. The Database Layer will be using the NoSQL database i.e. MongoDB. +This application functions as the deployable workload for the lecture: [*DevOps*](https://github.com/lucendio/lecture-devops-material) -As a brief overview of this todo app, when the user will access the front-end application from the browser, a login screen with a signup option appears. User must first signup to register and then after having success on signup can login into the app by using registered email and the password. +The application consists of two parts: -After a successful login, user will then add a new Todo task and list already added todos. Users can also mark any specific ToDo as important by clicking on the star, mark them as completed, and delete any specific ToDo when needed. Users may also use the ToDo search option and sort the paginated list on serial no, title, or description. \ No newline at end of file +* frontend (`./client`) +* backend (`./server`) + +and utilizes the following technologies (a.k.a MERN-stack): + +* React (rendering engine of the web-based graphical user interface) +* Express (web-server framework) +* Node (Javascript runtime in the backend) +* MongoDB (persistence layer) + +Other, most noticeable dependencies are: + +* [Jest](https://jestjs.io/) as the test framework for both parts +* [ESLint](https://eslint.org/) for code quality (linting) +* [Webpack](https://webpack.js.org/) to bundle the fronend +* [Babel](https://babeljs.io/) to transpile and therewith support latest Ecmascript versions +* [Mongoose](https://mongoosejs.com/docs/api.html) as the database driver + + +*Please see the `scripts` sections in the respective `package.json` files to find out which commands are available for +each parts.* + + +##### Full disclosure + +This application was forked from [Aamir Pinger](https://github.com/aamirpinger)'s [ToDo app][https://github.com/aamirpinger/todo-app-client-server-kubernetes] diff --git a/app/client/README.md b/app/client/README.md deleted file mode 100644 index 9d9614c4fd32e65dcbefff34b758d7824b397181..0000000000000000000000000000000000000000 --- a/app/client/README.md +++ /dev/null @@ -1,68 +0,0 @@ -This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). - -## Available Scripts - -In the project directory, you can run: - -### `npm start` - -Runs the app in the development mode.<br> -Open [http://localhost:3000](http://localhost:3000) to view it in the browser. - -The page will reload if you make edits.<br> -You will also see any lint errors in the console. - -### `npm test` - -Launches the test runner in the interactive watch mode.<br> -See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. - -### `npm run build` - -Builds the app for production to the `build` folder.<br> -It correctly bundles React in production mode and optimizes the build for the best performance. - -The build is minified and the filenames include the hashes.<br> -Your app is ready to be deployed! - -See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. - -### `npm run eject` - -**Note: this is a one-way operation. Once you `eject`, you can’t go back!** - -If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. - -Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. - -You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. - -## Learn More - -You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). - -To learn React, check out the [React documentation](https://reactjs.org/). - -### Code Splitting - -This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting - -### Analyzing the Bundle Size - -This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size - -### Making a Progressive Web App - -This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app - -### Advanced Configuration - -This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration - -### Deployment - -This section has moved here: https://facebook.github.io/create-react-app/docs/deployment - -### `npm run build` fails to minify - -This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify