├── .DS_Store ├── Dockerfile ├── package.json ├── README.md ├── public └── styles.css └── server.js /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AbeTavarez/containers_devops/main/.DS_Store -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node 2 | 3 | WORKDIR /app 4 | 5 | COPY package.json /app 6 | 7 | RUN npm install 8 | 9 | COPY . /app 10 | 11 | EXPOSE 80 12 | 13 | CMD ["node", "server.js"] -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "docker-complete", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "server.js", 6 | "author": "Maximilian Schwarzmüller / Academind GmbH", 7 | "license": "MIT", 8 | "dependencies": { 9 | "express": "^4.17.1", 10 | "body-parser": "1.19.0" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Containers 2 | 3 | ## Build & Run 4 | 5 | Build the image: 6 | `docker build .` at the main dir. 7 | 8 | Then run the container: 9 | `docker run -p 3000:80 ` 10 | 11 | To list running container: 12 | `docker ps` 13 | 14 | To list all containers: 15 | `docker ps -a` 16 | 17 | To stop a running container: 18 | `docker stop ` -------------------------------------------------------------------------------- /public/styles.css: -------------------------------------------------------------------------------- 1 | html { 2 | font-family: sans-serif; 3 | } 4 | 5 | body { 6 | margin: 0; 7 | } 8 | 9 | section, 10 | form { 11 | padding: 1rem; 12 | border-radius: 12px; 13 | box-shadow: 0 2px 8px rgba(0, 0, 0, 0.26); 14 | margin: 2rem auto; 15 | max-width: 40rem; 16 | } 17 | 18 | .form-control { 19 | margin: 0.5rem 0; 20 | } 21 | 22 | input { 23 | font: inherit; 24 | } 25 | 26 | input, 27 | label { 28 | display: block; 29 | } 30 | 31 | label { 32 | font-weight: bold; 33 | margin-bottom: 0.5rem; 34 | } 35 | 36 | button { 37 | background-color: #2f005a; 38 | border: 1px solid #2f005a; 39 | color: white; 40 | cursor: pointer; 41 | padding: 0.5rem 1.5rem; 42 | } 43 | 44 | button:hover, 45 | button:active { 46 | background-color: #50005a; 47 | border-color: #50005a; 48 | } 49 | -------------------------------------------------------------------------------- /server.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const bodyParser = require('body-parser'); 3 | 4 | const app = express(); 5 | 6 | let userGoal = 'Learn Docker!'; 7 | 8 | app.use( 9 | bodyParser.urlencoded({ 10 | extended: false, 11 | }) 12 | ); 13 | 14 | app.use(express.static('public')); 15 | 16 | app.get('/', (req, res) => { 17 | res.send(` 18 | 19 | 20 | 21 | 22 | 23 |
24 |

My Course Goals

25 |

${userGoal}

26 |
27 |
28 |
29 | 30 | 31 |
32 | 33 |
34 | 35 | 36 | `); 37 | }); 38 | 39 | app.post('/store-goal', (req, res) => { 40 | const enteredGoal = req.body.goal; 41 | console.log(enteredGoal); 42 | userGoal = enteredGoal; 43 | res.redirect('/'); 44 | }); 45 | 46 | app.listen(80); 47 | --------------------------------------------------------------------------------