diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 000000000..dc38a4762 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,44 @@ +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: + docker: + - image: buildpack-deps:trusty + steps: + - checkout + - run: + name: Deploy Main to Digital Ocean + command: | + git push https://heroku:$OCEAN_API_KEY@git.OCEAN.com/$OCEAN_APP_NAME.git main +workflows: + version: 2 + build-deploy: + jobs: + - build + - deploy: + requires: + - build + filters: + branches: + only: main \ 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/LAB_INSTRUCTIONS_DigitalOcean.md b/LAB_INSTRUCTIONS_DigitalOcean.md index 5f0e37553..a07004fa8 100644 --- a/LAB_INSTRUCTIONS_DigitalOcean.md +++ b/LAB_INSTRUCTIONS_DigitalOcean.md @@ -112,7 +112,7 @@ EXPOSE 4000 5. Build and run the Docker image using the following commands from _within_ the cis411_lab4_CD directory: ``` > docker build -t lab4 . -> docker run -p 4000:4000 lab4 & +> docker run -p 4000:4000 lab4 ``` > Tip: the period (`.`) at the end of the command is important! 6. Navigate to http://localhost:4000/graphql and verify that you can access GraphQL. diff --git a/assets/CircleCI.JPG b/assets/CircleCI.JPG new file mode 100644 index 000000000..a7e3fa256 Binary files /dev/null and b/assets/CircleCI.JPG differ diff --git a/assets/GraphQL.JPG b/assets/GraphQL.JPG new file mode 100644 index 000000000..d9c3a4b2f Binary files /dev/null and b/assets/GraphQL.JPG differ diff --git a/labreports/LAB_jp1478.md b/labreports/LAB_jp1478.md new file mode 100644 index 000000000..4a0a1a9a2 --- /dev/null +++ b/labreports/LAB_jp1478.md @@ -0,0 +1,37 @@ +# Lab Report: UX/UI +___ +**Course:** CIS 411, Spring 2023 +**Instructor(s):** [Trevor Bunch](https://github.com/trevordbunch) +**Name:** Joshua Phillips +**GitHub Handle:** jp1478 +**Repository:** https://github.com/jp1478/cis411_lab4_CD +**Collaborators:** 02NRA, aidan-hubley +___ + +# 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: +> [https://cis411lab4-jp1478-os7gv.ondigitalocean.app/graphql](https://cis411lab4-jp1478-os7gv.ondigitalocean.app/graphql) +- [x] Embed _using markdown_ a screenshot of your successful deployed application to Digital Ocean. +> Example: ![Successful Build](../assets/GraphQL.JPG) +- [x] Embed _using markdown_ a screenshot of your successful build and deployment to Heroku of your project (with the circleci interface). +> Example: ![Successful Build](../assets/CircleCI.JPG) +- [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? +> Containers allow the application to be run in any environment. +> [checkpoint.com](https://www.checkpoint.com/cyber-hub/cloud-security/what-is-container-security/what-is-containerization/#:~:text=Containerization%20is%20a%20type%20of,and%20highly%20conducive%20to%20automation.) +2. If we have the ability to publish directory to Heroku (Digital Ocean), why involve a CI solution like CircleCI? What benefit does it provide? +> It automates the process of testing and deployment by automatically running a series of tests and deploying to Digital Ocean if the tests succeed. This can catch nonfatal errors as well as errors in multiple branches. +> [circleci.com](https://circleci.com/why-circleci/) +3. Why would you use a container technology over a virtual machine(VM)? +> Containers are less resource intensive than VMs, making them easier to create and destroy, and you can use more of them at a time. +> [diva-portal.org](https://www.diva-portal.org/smash/get/diva2:1412070/FULLTEXT01.pdf) +4. What are some alternatives to Docker for containerized deployments? +> Alternatives include Cloud Foundry, Containerd, CoreOS rkt, Hyper-V Containers, and more. Docker can only run on Linux systems, so one of these alternatives may be preferable for a Windows or Mac-OS system. +> [simplilearn.com](https://www.simplilearn.com/docker-alternatives-article) \ No newline at end of file diff --git a/package.json b/package.json index 6392df13f..ea2562c5c 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "dependencies": { "express": "^4.16.3", "express-graphql": "^0.6.12", - "graphql": "^14.0.2", + "graphql": "^0.13.0 || ^14.0.2", "lokijs": "^1.5.5", "uuid": "^3.3.2" },