diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 000000000..af63bc662 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,53 @@ +version: 2 +jobs: + + build: + docker: + - image: circleci/node:11 + steps: + - checkout + + # Download and cache dependencies + - restore_cache: + keys: + - v1-dependencies-{{ checksum "package.json" }} + # fallback to using the latest cache if no exact match is found + - v1-dependencies- + + - run: yarn install + + - save_cache: + paths: + - node_modules + key: v1-dependencies-{{ checksum "package.json" }} + + # run tests! + - run: yarn test + deploy: + working_directory: ~/repo + docker: + - image: circleci/node:11 + steps: + - checkout + - run: + name: Configure Github credentials + command: | + git config user.email $GITHUB_EMAIL + git config user.name $GITHUB_USERNAME + - add_ssh_keys: + fingerprints: + - $GITHUB_FINGERPRINT + - run: + name: Deploy to Azure Web App Using Azure Container Registry Task + command: npm run deploy +workflows: + version: 2 + build: + jobs: + - build + - deploy: + requires: + - build # only deploy once build job has completed + filters: + branches: + only: purelab # only deploy on the main branch \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..9a6c211be --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM node:11 +WORKDIR /dist +COPY package.json /dist +RUN npm install +COPY . /dist +CMD node server.js +EXPOSE 4000 \ No newline at end of file diff --git a/labreports/1st_succesful_build.png b/labreports/1st_succesful_build.png new file mode 100644 index 000000000..82598781d Binary files /dev/null and b/labreports/1st_succesful_build.png differ diff --git a/labreports/1st_successful_build.png b/labreports/1st_successful_build.png new file mode 100644 index 000000000..a45d47195 Binary files /dev/null and b/labreports/1st_successful_build.png differ diff --git a/labreports/LAB_BenOfTheOneRing.md b/labreports/LAB_BenOfTheOneRing.md new file mode 100644 index 000000000..fcce59a0c --- /dev/null +++ b/labreports/LAB_BenOfTheOneRing.md @@ -0,0 +1,34 @@ +# Lab Report: UX/UI +___ +**Course:** CIS 411, Spring 2021 +**Instructor(s):** [Trevor Bunch](https://github.com/trevordbunch) +**Name:** Ben Clarke +**GitHub Handle:** BenOfTheOneRing +**Repository:** [My Forked Repository](https://github.com/BenOfTheOneRing/cis411_lab4_CD.git) +**Collaborators:** Mike Shoul, Grace Taylor via Pull request +___ + +# Required Content + +- [x] Generate a markdown file in the labreports directory named LAB_[GITHUB HANDLE].md. Write your lab report there. +- [x] Create the directory ```./circleci``` and the file ```.circleci/config.yml``` in your project and push that change to your GitHub repository. +- [x] Create the file ```Dockerfile``` in the root of your project and include the contents of the file as described in the instructions. Push that change to your GitHub repository. +- [x] Write the URL of your app hosted on Heroku or other Cloud Provider here: +[Azure URL](https://labcd4app.azurewebsites.net/graphql) +- [x] Embed _using markdown_ a screenshot of your successful deployed application to Azure. +![Successful Build](1st_successful_build.png) +- [x] Embed _using markdown_ a screenshot of your successful build and deployment to Azure of your project (with the circleci interface). +![Successful Deployment](build_2.png) +- [x] Answer the **4** questions below. +- [x] Submit a Pull Request to cis411_lab4_CD and provide the URL of that Pull Request in Canvas as your URL submission. + +## Questions +1. Why would a containerized version of an application be beneficial if you can run the application locally already? + +> Because containerized applications contain all of their own data and app/file versions. This way if two devs have different versions of npm, git, or some other necessary file or service, those differences do not leak into errors with the app if the app is deployed to a different environment. +2. If we have the ability to publish directory to Heroku, why involve a CI solution like CircleCI? What benefit does it provide? +> It checks for errors and makes sure the app can actually run. This saves valuable time in troubleshooting, and also acts as a fail-safe in-case a dev accidentally sends a broken build to the deployed server. CircleCI would block that type of dangerous deployment. +3. Why would you use a container technology over a virtual machine(VM)? +> Because a virtual machine, while it would stop your personal device from being harmed from errors, would still have environments that would most likely not match with every user's systems and environments. If an app fully contains its own dependencies then it does not matter what device it is used on. +4. What are some alternatives to Docker for containerized deployments? +> Cloud Foundry, Containerd, CoreOS rkt, Kubernetes \ No newline at end of file diff --git a/labreports/LAB_Template.md b/labreports/LAB_Template.md deleted file mode 100644 index b489c9ccf..000000000 --- a/labreports/LAB_Template.md +++ /dev/null @@ -1,33 +0,0 @@ -# Lab Report: UX/UI -___ -**Course:** CIS 411, Spring 2021 -**Instructor(s):** [Trevor Bunch](https://github.com/trevordbunch) -**Name:** Your Name -**GitHub Handle:** Your GitHub Handle -**Repository:** Your Forked Repository -**Collaborators:** -___ - -# Required Content - -- [ ] Generate a markdown file in the labreports directory named LAB_[GITHUB HANDLE].md. Write your lab report there. -- [ ] Create the directory ```./circleci``` and the file ```.circleci/config.yml``` in your project and push that change to your GitHub repository. -- [ ] Create the file ```Dockerfile``` in the root of your project and include the contents of the file as described in the instructions. Push that change to your GitHub repository. -- [ ] Write the URL of your app hosted on Heroku or other Cloud Provider here: -> Example: [http://cis411lab2-trevordbunch.herokuapp.com/graphql](http://cis411lab2-trevordbunch.herokuapp.com/graphql) -- [ ] Embed _using markdown_ a screenshot of your successful deployed application to Heroku. -> Example: ![Successful Build](../ex/trevordbunch_lab2_01.png) -- [ ] Embed _using markdown_ a screenshot of your successful build and deployment to Heroku of your project (with the circleci interface). -> Example: ![Successful Build](../ex/trevordbunch_lab2_02.png) -- [ ] Answer the **4** questions below. -- [ ] Submit a Pull Request to cis411_lab4_CD and provide the URL of that Pull Request in Canvas as your URL submission. - -## Questions -1. Why would a containerized version of an application be beneficial if you can run the application locally already? -> Respond here... -2. If we have the ability to publish directory to Heroku, why involve a CI solution like CircleCI? What benefit does it provide? -> Respond here... -3. Why would you use a container technology over a virtual machine(VM)? -> Respond here... -4. What are some alternatives to Docker for containerized deployments? -> Respond here... \ No newline at end of file diff --git a/labreports/build_2.png b/labreports/build_2.png new file mode 100644 index 000000000..123e04ec0 Binary files /dev/null and b/labreports/build_2.png differ diff --git a/package.json b/package.json index 6392df13f..825a8ba4f 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,8 @@ "main": "server.js", "scripts": { "run": "node server.js", - "test": "exit 0" + "test": "exit 0", + "deploy" : "npx gh-pages -b deploy --message '[skip ci] Updates' -d ./" }, "repository": { "type": "git", @@ -35,6 +36,7 @@ "uuid": "^3.3.2" }, "devDependencies": { + "gh-pages": "^5.0.0", "nyc": "^15.1.0" } }