diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 000000000..cb02aaabd --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,46 @@ +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: purelab diff --git a/Dockerfile b/Dockerfile index 1265da147..64731a664 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ FROM node:11 WORKDIR /dist COPY package.json /dist -RUN npm install +RUN npm install --force COPY . /dist CMD node server.js EXPOSE 4000 diff --git a/LAB_INSTRUCTIONS_DigitalOcean.md b/LAB_INSTRUCTIONS_DigitalOcean.md index 362045f6d..3fd27d8ef 100644 --- a/LAB_INSTRUCTIONS_DigitalOcean.md +++ b/LAB_INSTRUCTIONS_DigitalOcean.md @@ -17,9 +17,7 @@ Lab reports will be submitted by 4. Install Docker on your development environment, either for [Mac](https://docs.docker.com/docker-for-mac/install/), [Windows](https://docs.docker.com/docker-for-windows/install/), or various Linux distributions. > If you have Windows Home Edition, then you should following these [instructions](ex/Docker_Installation_Win10_Home.md) to navigate the system requirements. 5. [Sign up for an account on Docker Hub](https://hub.docker.com/) and keep track of your username and password (You'll need that later). -6. [Sign up for a Heroku](https://signup.heroku.com) account. Make sure that you get the Heroku for GitHub Students (https://www.heroku.com/github-students) or be prepared to pay. (You'll need that later too). -7. [Download and install the Heroku CLI](https://devcenter.heroku.com/articles/heroku-cli#download-and-install). - +6. [Sign up for Digital Ocean](https://www.digitalocean.com). # Step 1: Fork and clone this repository 1. After logging in, navigate to the [root](https://github.com/trevordbunch/cis411_lab4_CD) of this repository. @@ -128,7 +126,7 @@ EXPOSE 4000 > git push ``` -# Step 4: Push docker desktop file to docker hub + -# Step 5: Setup a Digital Ocean application +# Step 4: Setup a Digital Ocean application There are _lots_ of solutions for providing a CD endpoint including AWS, Google Cloud, Azure, Digital Ocean, etc. For the purposes of this assignment, we're going to use **Digital Ocean** for one reason: it's _relatively_ easy. They provide $200 free credits which must be used in 60 days. -1. Login to Digital Ocean through the web interface and go to manage, apps, create app, docker hub, type in the repo (example: rt1252/lab4), enter 'tag' for tag, click next. -2. Edit any setting such as name if you like. -3. Wait for service to deploy. -4. Click the live app button and append /graphql to the end. You will see graphql running! +1. Login to Digital Ocean through the web interface. +2. Go to manage, apps, create app. +3. Choose github and select your repository and branch; click next. +4. On the Resources page, delete the Lab4-cd2 web service. This is a node compiling service that is generated with your docker web service (Lab4-cd). For this lab we only need the docker service. +![Part to Delete](./assets/digitalOcean_webService_Setup.png) +5. Edit any setting such as **name** if you like. +6. Wait for service to deploy. +7. Click the live app button. You will see an error like _Cannot GET /_. +8. **Append /graphql to the end. You will see graphql running!** + ![Live Application](assets/digitalOcean_success.png) -5. **Include this URL in your lab report.** +1. **Include this URL in your lab report.** -# Step 6: Configure CircleCI for CD to Digital Ocean +# Step 5: Configure CircleCI for CD to Digital Ocean 1. From the menu on the digital ocean homepage scroll to the bottom and click API. 2. Name the token and click generate, copy the token. diff --git a/assets/digital ocean app.png b/assets/digital ocean app.png new file mode 100644 index 000000000..66a3d80c2 Binary files /dev/null and b/assets/digital ocean app.png differ diff --git a/assets/digital ocean circleci test.png b/assets/digital ocean circleci test.png new file mode 100644 index 000000000..358197f04 Binary files /dev/null and b/assets/digital ocean circleci test.png differ diff --git a/assets/digitalOcean_webService_Setup.png b/assets/digitalOcean_webService_Setup.png new file mode 100644 index 000000000..c6dee1860 Binary files /dev/null and b/assets/digitalOcean_webService_Setup.png differ diff --git a/LAB_INSTRUCTIONS_Google.md b/ex/LAB_INSTRUCTIONS_Google.md similarity index 100% rename from LAB_INSTRUCTIONS_Google.md rename to ex/LAB_INSTRUCTIONS_Google.md diff --git a/LAB_INSTRUCTIONS_Heroku.md b/ex/LAB_INSTRUCTIONS_Heroku.md similarity index 100% rename from LAB_INSTRUCTIONS_Heroku.md rename to ex/LAB_INSTRUCTIONS_Heroku.md diff --git a/Procfile b/ex/Procfile similarity index 100% rename from Procfile rename to ex/Procfile diff --git a/heroku b/ex/heroku similarity index 100% rename from heroku rename to ex/heroku diff --git a/labreports/LAB_Template.md b/labreports/LAB_Template.md index b489c9ccf..c8f815ac3 100644 --- a/labreports/LAB_Template.md +++ b/labreports/LAB_Template.md @@ -1,6 +1,6 @@ -# Lab Report: UX/UI +# Lab Report: Continuous Deployment ___ -**Course:** CIS 411, Spring 2021 +**Course:** CIS 411, Spring 2023 **Instructor(s):** [Trevor Bunch](https://github.com/trevordbunch) **Name:** Your Name **GitHub Handle:** Your GitHub Handle @@ -19,6 +19,7 @@ ___ > 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) +- [ ] Copy your mutation from your graphql instance here: - [ ] 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. diff --git a/labreports/LAB_jrmakr2123.md b/labreports/LAB_jrmakr2123.md new file mode 100644 index 000000000..46d9f70cb --- /dev/null +++ b/labreports/LAB_jrmakr2123.md @@ -0,0 +1,53 @@ +# Lab Report: Continuous Deployment +___ +**Course:** CIS 411, Spring 2023 +**Instructor(s):** [Trevor Bunch](https://github.com/trevordbunch) +**Name:** Jonah Robinson +**GitHub Handle:** [jrmakr2123](https://github.com/jrmakr2123) +**Repository:** [Continuous Development](https://github.com/jrmakr2123/cis411_lab4_CD) + +___ + +# 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-jrmakr2123-u4el5.ondigitalocean.app/graphql](https://cis411lab4-jrmakr2123-u4el5.ondigitalocean.app/graphql) +- [x] Embed _using markdown_ a screenshot of your successful deployed application to Digital Ocean. +> ![Successful Build](./../assets/digital%20ocean%20app.png) +- [x] Embed _using markdown_ a screenshot of your successful build and deployment to Digital Ocean of your project (with the circleci interface). +> Example: ![Successful Build](./../assets/digital%20ocean%20circleci%20test.png) + + + +- [x] Copy your mutation from your graphql instance here: +~~~ +{ + "data": { + "mutateAccount": { + "id": "dd6073cc-2118-4927-8e34-9b369a8d781f", + "name": "Jonah Robinson", + "email": "jr1521@messiah.edu" + } + } +} +~~~ +- [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? +> By having a containerized version of an application, the development team can run the same tests on the same containerized hardware. The application may be able to run with no errors on one computer, but on another it may not run. Containers make it possible for developers to have the same set of hardware to make changes. +2. If we have the ability to publish directory to Digital Ocean, why involve a CI solution like CircleCI? What benefit does it provide? +> Where a continuous Integration program like CircleCI would help developers compile, test, and maintain usable code, Continuous Delivery would help developers deliver new codes and programs for more testing in more realistic situations. Were CI would be more focused on creating usable code, CD is more interested in delivering and monitoring that code for future fixes. +3. Why would you use a container technology over a virtual machine(VM)? +> Container technology interfaces with the kernel thus not requiring an additional license to run. In virtual machine instances, licensing is required for each additional virtual machine. Another reason is that container technology does not require as much resources as virtualization. Containerization focusses on using what the computer is already giving in kernel manipulation thus allowing for a faster and lightweight running process. Virtualization focusses on partitioning a certain amount of computer resources. In doing so everything is recopied and ran through a compatibility layer. To get the performance of a container in a virtual machine the virtual machine would need more resources than the container would need in the first place. +4. What are some alternatives to Docker for containerized deployments? +> Some alternatives to docker are . . . +> - Hyper-V Containers, +> - Containerd, +> - Kubernetes, +> - RunC, +> - Buildah, +> - and many more options for developers. \ No newline at end of file diff --git a/package.json b/package.json index 6392df13f..2200b1a73 100644 --- a/package.json +++ b/package.json @@ -37,4 +37,4 @@ "devDependencies": { "nyc": "^15.1.0" } -} +} \ No newline at end of file