diff --git a/eg3/README.md b/eg3/README.md new file mode 100644 index 0000000..f0d1be5 --- /dev/null +++ b/eg3/README.md @@ -0,0 +1,4 @@ +# e.g. 3: Create an Ningx Reverse Proxy With Docker + +How To Run Multiple Docker Containers Under One URL + diff --git a/eg3/backend/Dockerfile b/eg3/backend/Dockerfile new file mode 100644 index 0000000..58d7637 --- /dev/null +++ b/eg3/backend/Dockerfile @@ -0,0 +1,5 @@ +FROM node:10.15.3-alpine +WORKDIR /home/node/ +RUN npm install express --save +COPY index.js . +CMD [ "node", "index.js"] \ No newline at end of file diff --git a/eg3/backend/docker-compose.yaml b/eg3/backend/docker-compose.yaml new file mode 100644 index 0000000..43eae2c --- /dev/null +++ b/eg3/backend/docker-compose.yaml @@ -0,0 +1,8 @@ +version: '3.8' + +services: + backend: + container_name: backend + build: . + ports: + - "5000:5000" \ No newline at end of file diff --git a/eg3/backend/index.js b/eg3/backend/index.js new file mode 100644 index 0000000..fc8e049 --- /dev/null +++ b/eg3/backend/index.js @@ -0,0 +1,7 @@ +const express = require('express'); +const app = express(); +const port = 5000; +const version = '1.0.0'; + +app.get('/', (req, res) => res.send({ version })); +app.listen(port, () => console.log(`Listening on port ${port}`)); \ No newline at end of file diff --git a/eg3/frontend/Dockerfile b/eg3/frontend/Dockerfile new file mode 100644 index 0000000..3bb9c3c --- /dev/null +++ b/eg3/frontend/Dockerfile @@ -0,0 +1,4 @@ +FROM nginx:stable-alpine +WORKDIR /usr/share/nginx/html +RUN apk add curl +COPY index.html . \ No newline at end of file diff --git a/eg3/frontend/docker-compose.yaml b/eg3/frontend/docker-compose.yaml new file mode 100644 index 0000000..ace46c8 --- /dev/null +++ b/eg3/frontend/docker-compose.yaml @@ -0,0 +1,8 @@ +version: '3.8' + +services: + frontend: + container_name: frontend + build: . + # ports: + # - "80:80" \ No newline at end of file diff --git a/eg3/frontend/index.html b/eg3/frontend/index.html new file mode 100644 index 0000000..8cc004d --- /dev/null +++ b/eg3/frontend/index.html @@ -0,0 +1,27 @@ + + +
+