Studying docker

Start mirroring #1

merged opened by dotslash-baunthy.tngl.sh targeting master from dev
Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:u2ss2p4pta45j6qb75zv7lh5/sh.tangled.repo.pull/3mg5pcw4bjf22
+105 -13
Diff #0
+1
README.md
··· 1 + # Repository listing all stuff created for Docker training
+18
assignment-problem/instructions.txt
··· 1 + Dockerize BOTH apps - the Python and the Node app. 2 + 3 + 1) Create appropriate images for both apps (two separate images!). 4 + HINT: Have a brief look at the app code to configure your images correctly! 5 + 6 + 2) Launch a container for each created image, making sure, 7 + that the app inside the container works correctly and is usable. 8 + 9 + 3) Re-create both containers and assign names to both containers. 10 + Use these names to stop and restart both containers. 11 + 12 + 4) Clean up (remove) all stopped (and running) containers, 13 + clean up all created images. 14 + 15 + 5) Re-build the images - this time with names and tags assigned to them. 16 + 17 + 6) Run new containers based on the re-built images, ensuring that the containers 18 + are removed automatically when stopped.
+7
assignment-problem/node-app/Dockerfile
··· 1 + FROM node:20-alpine 2 + WORKDIR /app 3 + COPY package.json ./ 4 + RUN npm install 5 + COPY . /app 6 + EXPOSE 3000 7 + CMD ["node", "server.js"]
+14
assignment-problem/node-app/package.json
··· 1 + { 2 + "name": "app", 3 + "version": "1.0.0", 4 + "description": "", 5 + "main": "index.js", 6 + "scripts": { 7 + "test": "echo \"Error: no test specified\" && exit 1" 8 + }, 9 + "author": "", 10 + "license": "ISC", 11 + "dependencies": { 12 + "express": "^4.17.1" 13 + } 14 + }
+11
assignment-problem/node-app/server.js
··· 1 + const express = require('express'); 2 + 3 + const app = express(); 4 + 5 + app.get('/', (req, res) => { 6 + res.send(` 7 + <h1>Hello from inside the very basic Node app!</h1> 8 + `); 9 + }) 10 + 11 + app.listen(3000);
+5
assignment-problem/python-app/Dockerfile
··· 1 + FROM python:3.9-slim 2 + WORKDIR /app 3 + COPY . /app 4 + EXPOSE 80 5 + CMD ["python", "bmi.py"]
+31
assignment-problem/python-app/bmi.py
··· 1 + print('(1) Metric (m, kg) or (2) Non-Metric (ft, pounds)?') 2 + 3 + chosen_system = input('Please choose: ') 4 + 5 + if (chosen_system != '1' and chosen_system != '2'): 6 + print('You have to choose either metric or non-metric. Shutting down...') 7 + exit() 8 + 9 + height_unit = 'meters' 10 + weight_unit = 'kilograms' 11 + 12 + if (chosen_system == '2'): 13 + height_unit = 'feet' 14 + weight_unit = 'pounds' 15 + 16 + print('Please enter your height in ' + height_unit) 17 + user_height = float(input('Your height: ')) 18 + 19 + print('Please enter your weight in ' + weight_unit) 20 + user_weight = float(input('Your weight: ')) 21 + 22 + adj_height = user_height 23 + adj_weight = user_weight 24 + 25 + if (chosen_system == '2'): 26 + adj_height = user_height / 3.28084 27 + adj_weight = user_weight / 2.20462 28 + 29 + bmi = adj_weight / (adj_height * adj_height) 30 + 31 + print('Your body-mass-index: ' + str(bmi))
-6
first-demo-starting-setup/Dockerfile
··· 1 1 FROM node:14 2 - 3 2 WORKDIR /app 4 - 5 3 COPY package.json . 6 - 7 4 RUN npm install 8 - 9 5 COPY . . 10 - 11 6 EXPOSE 3000 12 - 13 7 CMD [ "node", "app.mjs" ]
+1 -6
nodejs-first-starting/Dockerfile
··· 1 - FROM node 2 - 1 + FROM node:20-alpine 3 2 WORKDIR /app 4 - 5 3 COPY . /app 6 - 7 4 RUN npm install 8 - 9 5 EXPOSE 80 10 - 11 6 CMD ["node","server.js"]
+1 -1
nodejs-first-starting/server.js
··· 21 21 </head> 22 22 <body> 23 23 <section> 24 - <h2>My Course Goal</h2> 24 + <h2>ChAnGeD sTuFf</h2> 25 25 <h3>${userGoal}</h3> 26 26 </section> 27 27 <form action="/store-goal" method="POST">
+5
python-app-starting-setup/Dockerfile
··· 1 + FROM python:3.9-slim 2 + WORKDIR /app 3 + COPY . /app 4 + EXPOSE 80 5 + CMD ["python", "rng.py"]
+11
python-app-starting-setup/rng.py
··· 1 + from random import randint 2 + 3 + min_number = int(input('Please enter the min number: ')) 4 + max_number = int(input('Please enter the max number: ')) 5 + 6 + if (max_number < min_number): 7 + print('Invalid input - shutting down...') 8 + else: 9 + rnd_number = randint(min_number, max_number) 10 + print(rnd_number) 11 +

History

1 round 0 comments
sign up or login to add to the discussion
7 commits
expand
Add readme
Dummy commit
Switch to smaller image
Random edits
Add Python example
Formatting
Add assignment
expand 0 comments
pull request successfully merged