Skip to content

Commit 9587d73

Browse files
committed
removed vagrant instructions for docker
1 parent 9949b94 commit 9587d73

File tree

1 file changed

+28
-53
lines changed

1 file changed

+28
-53
lines changed

README.md

Lines changed: 28 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,68 @@
11
# lab-flask-restplus-swagger
22

3-
[![Build Status](https://travis-ci.org/nyu-devops/lab-flask-restplus-swagger.svg?branch=master)](https://travis-ci.org/nyu-devops/lab-flask-restplus-swagger)
4-
[![Codecov](https://img.shields.io/codecov/c/github/nyu-devops/lab-flask-restplus-swagger.svg)]()
3+
[![Build Status](https://github.com/nyu-devops/lab-flask-restplus-swagger/actions/workflows/build.yml/badge.svg)](https://github.com/nyu-devops/lab-flask-restplus-swagger/actions)
4+
[![codecov](https://codecov.io/gh/nyu-devops/lab-flask-restplus-swagger/branch/master/graph/badge.svg?token=y6OUlCB4bC)](https://codecov.io/gh/nyu-devops/lab-flask-restplus-swagger)
5+
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
6+
[![made-with-python](https://img.shields.io/badge/Made%20with-Python-red.svg)](https://www.python.org/)
7+
[![Open in Remote - Containers](https://img.shields.io/static/v1?label=Remote%20-%20Containers&message=Open&color=blue&logo=visualstudiocode)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/nyu-devops/lab-flask-restplus-swagger)
58

69
**NYU DevOps** lab that demonstrates how to use [Flask-RESTX](https://flask-restx.readthedocs.io/en/latest/) to generate [Swagger](http://swagger.io)/[OpenAPI](https://www.openapis.org) documentation for your [Python](https://www.python.org) [Flask](http://flask.pocoo.org) application. This repository is part of lab for the NYU DevOps class [CSCI-GA.2820-001](https://cs.nyu.edu/courses/spring21/CSCI-GA.2820-001/), Graduate Division, Computer Science
710

811
## Introduction
912

1013
When developing microservices with API's that others are going to call, it is critically important to provide the proper API documentation. OpenAPI has become a standard for documenting APIs and Swagger is an implementation of this. This lab shows you how to use a Flask plug-in called **Flask-RESTX** which is a fork of the original **Flask-RESTPlus** that is no longer maintained, to imbed Swagger documentation into your Python Flask microservice so that the Swagger docs are generated for you.
1114

12-
I feel that it is much better to include the documentation with the code because programmers are more likely to update the docs if it's right there above the code they are working on. (...at least that's the therory and I'm sticking to it) ;-)
15+
I feel that it is much better to include the documentation with the code because programmers are more likely to update the docs if it's right there above the code they are working on. (...at least that's the theory and I'm sticking to it) ;-)
1316

14-
## Prerequisite Installation using Vagrant
17+
### Prerequisite Installation
1518

16-
The easiest way to use this lab is with Vagrant and VirtualBox. If you don't have this software the first step is down download and install it. If you have an 2020 Apple Mac with the M1 chip, you should download Docker Desktop instead of VirtualBox. Here is what you need:
19+
All of our development is done in Docker containers using **Visual Studio Code**. This project contains a `.devcontainer` folder that will set up a Docker environment in VSCode for you. You will need the following:
1720

18-
Download: [Vagrant](https://www.vagrantup.com/)
21+
- Docker Desktop for [Mac](https://docs.docker.com/docker-for-mac/install/) or [Windows](https://docs.docker.com/docker-for-windows/install/)
22+
- Microsoft Visual Studio Code ([VSCode](https://code.visualstudio.com/download))
23+
- [Remote Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) VSCode Extension
1924

20-
Intel Download: [VirtualBox](https://www.virtualbox.org/)
25+
It is a good idea to add VSCode to your path so that you can invoke it from the command line. To do this, open VSCode and type `Shift+Command+P` on Mac or `Shift+Ctrl+P` on Windows to open the command pallet and then search for "shell" and select the option **Shell Command: Install 'code' command in Path**. This will install VSCode in your path.
2126

22-
Apple M1 Download: [Apple M1 Tech Preview](https://docs.docker.com/docker-for-mac/apple-m1/)
23-
24-
Install each of those. Then all you have to do is clone this repo and invoke vagrant:
25-
26-
### Using Vagrant and VirtualBox (Intel only)
27-
28-
If you have an Intel Mac or Windows PC you can use these steps:
27+
Then you can start your development environment up with:
2928

3029
```bash
31-
$ git clone https://github.com/nyu-devops/lab-flask-restplus-swagger.git
32-
$ cd lab-flask-restplus-swagger
33-
$ vagrant up
34-
$ vagrant ssh
35-
$ cd /vagrant
30+
git clone https://github.com/nyu-devops/lab-flask-restplus-swagger.git
31+
cd lab-flask-restplus-swagger
32+
code .
3633
```
3734

38-
### Using Vagrant and Docker Desktop
39-
40-
If you have an Apple M1 Silicon Mac or other ARM
41-
based computer, or if you just want to use Docker as a provider instead of VirtualBox, you can use these steps:
42-
43-
This is useful for owners of Apple M1 Silicon Macs which cannot run VirtualBox because they have a CPU based on ARM architecture instead of Intel.
35+
The first time it will build the Docker image but after that it will just create a container and place you inside of it in your `/app` folder which actually contains the repo shared from your computer. It will also install all of the VSCode extensions needed for Python development.
4436

45-
Just add `--provider docker` to the `vagrant up` command like this:
46-
47-
```bash
48-
$ git clone https://github.com/nyu-devops/lab-flask-restplus-swagger.git
49-
$ cd lab-flask-restplus-swagger
50-
$ vagrant up --provider docker
51-
$ vagrant ssh
52-
$ cd /vagrant
53-
```
54-
55-
This will use a Docker container instead of a Virtual Machine (VM). Everything else should be the same.
37+
If it does not automatically prompt you to open the project in a container, you can select the green icon at the bottom left of your VSCode UI and select: **Remote Containers: Reopen in Container**.
5638

5739
## Running the code
5840

59-
You can now run `green` to run the tests and make sure that everything works as expected.
41+
You can now run `pytest` to run the tests and make sure that everything works as expected.
6042

6143
```bash
62-
$ green
44+
make test
6345
```
6446

6547
You can then run the server with:
6648

6749
```bash
68-
$ honcho start
50+
honcho start
6951
```
7052

7153
Finally you can see the microservice Swagger docs at: [http://localhost:8080/](http://localhost:8080/)
7254

73-
When you are done, you can exit and shut down the VM with:
74-
75-
```bash
76-
$ exit
77-
$ vagrant halt
78-
```
79-
80-
If the VM is no longer needed you can remove it with:
81-
82-
```bash
83-
$ vagrant destroy
84-
```
85-
8655
## What's featured in the project?
8756

8857
* service/routes.py -- the main Service using Python Flask-RESTX for Swagger
8958
* service/models.py -- a Pet model that uses Cloudant for persistence
9059
* tests/test_routes.py -- test cases using unittest for the microservice
9160
* tests/test_models.py -- test cases using unittest for the Pet model
9261

93-
This repository is part of the NYU graduate class **CSCI-GA.2810-001: DevOps and Agile Methodologies** taught by [John Rofrano](http://www.johnrofrano.com/), Adjunct Instructor, NYU Curant Institute, Graduate Division, Computer Science and at Stern Business School.
62+
## License
63+
64+
Copyright (c) 2021, 2025 John Rofrano. All rights reserved.
65+
66+
Licensed under the Apache License. See [LICENSE](LICENSE)
67+
68+
This repository is part of the NYU graduate class **CSCI-GA.2810-001: DevOps and Agile Methodologies** taught by [John Rofrano](http://www.johnrofrano.com/), Adjunct Instructor, NYU Courant Institute, Graduate Division, Computer Science and at Stern Business School.

0 commit comments

Comments
 (0)