Add a couple of questions on containers

Also, fixed some minor styling issues in random_question.py script.
This commit is contained in:
abregman
2021-10-24 22:00:44 +03:00
parent aa420a7eed
commit 51ecb4ff77
5 changed files with 113 additions and 31 deletions

View File

@ -9,4 +9,18 @@
### Bonus
Containerize the app of the project you forked using any containerization technology you would like.
Containerize the app of the project you forked using any container engine you would like (e.g. Docker, Podman).<br>
Once you successfully ran the application in a container, submit the Dockerfile to the original project (but be prepared that the maintainer might not need/want that).
### Suggestions for Projects
The following is a list of projects without CI (at least at the moment):
Note: I wrote a script to find these (except the first project on the list, of course) based on some parameters in case you wonder why these projects specifically are listed.
* [This one](https://github.com/bregman-arie/devops-exercises) - We don't have CI! help! :)
* [image retrieval platform](https://github.com/skx6/image_retrieval_platform)
* [FollowSpot](https://github.com/jenbrissman/FollowSpot)
* [Pyrin](https://github.com/mononobi/pyrin)
* [food-detection-yolov5](https://github.com/lannguyen0910/food-detection-yolov5)
* [Lifely](https://github.com/sagnik1511/Lifely)

View File

@ -6,18 +6,9 @@
https://github.com/bregman-arie/node-hello-world
https://github.com/bregman-arie/flask-hello-world
```
`git clone https://github.com/bregman-arie/node-hello-world`
2. Write a Dockerfile you'll use for building an image of the application (you can use any base image you would like)
```
FROM alpine
LABEL maintainer="your name/email"
RUN apk add --update nodejs nodejs-npm
COPY . /src
WORKDIR /src
RUN npm install
EXPOSE 8080
ENTRYPOINT ["node", "./app.js"]
```
3. Build an image using the Dockerfile you've just wrote
4. Verify the image exists
5. [Optional] Push the image you've just built to a registry
6. Run the application
7. Verify the app is running

View File

@ -0,0 +1,54 @@
## Containerize an Application
1. Clone an open source project you would like to containerize. A couple of suggestions:
```
https://github.com/bregman-arie/node-hello-world
https://github.com/bregman-arie/flask-hello-world
```
`git clone https://github.com/bregman-arie/node-hello-world`
2. Write a Dockerfile you'll use for building an image of the application (you can use any base image you would like)
```
FROM alpine
LABEL maintainer="your name/email"
RUN apk add --update nodejs npm
COPY . /src
WORKDIR /src
RUN npm install
EXPOSE 3000
ENTRYPOINT ["node", "./app.js"]
```
3. Build an image using the Dockerfile you've just wrote
`docker image build -t web_app:latest .`
4. Verify the image exists
`docker image ls`
5. [Optional] Push the image you've just built to a registry
```
docker login
docker image tag web_app:latest <your username>/web_app:latest
# Verify with "docker image ls"
docker image push <your username>/web_app:latest
```
6. Run the application
```
docker container run -d -p 80:3000 web_app:latest
```
7. Verify the app is running
```
docker container ls
docker logs <container ID/name>
# In the browser, go to 127.0.0.1:80
```