Skip to content

Commit db9195d

Browse files
committed
Add docker example
1 parent a891be1 commit db9195d

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
This repo contains materials for learning how to use infrastructure-as-code practices, including:
44

55
1. An [example Ruby on Rails app](/example-rails-app) used for demonstration purposes.
6-
2. A [Packer example](/packer-example) that shows how to create an AMI that has Ruby on Rails installed and contains
6+
1. A [Packer example](/packer-example) that shows how to create an AMI that has Ruby on Rails installed and contains
77
the code from the example Rails app.
8-
3. A [basic Terraform example](/terraform-example-basic) that shows an intro to Terraform.
9-
4. A [full Terraform example](/terraform-example-full) that shows more advanced Terraform usage, including how to take
8+
1. A [Docker example](/docker-example) that shows how to create a Docker container that has Node.js installed and
9+
runs a simple Node "Hello, World" web server.
10+
1. A [basic Terraform example](/terraform-example-basic) that shows an intro to Terraform.
11+
1. A [full Terraform example](/terraform-example-full) that shows more advanced Terraform usage, including how to take
1012
the AMI created by the Packer example, deploy it on AWS, and run the example Rails app.
1113

1214
Note: all the code in this repo is used only for demonstration and teaching purposes and should not be used in

docker-example/Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM ubuntu:latest
2+
MAINTAINER Yevgeniy Brikman <[email protected]>
3+
4+
RUN apt-get update && apt-get install -y nodejs
5+
6+
RUN mkdir -p /usr/src/app
7+
COPY ./src /usr/src/app
8+
WORKDIR /usr/src/app
9+
10+
CMD ["nodejs", "server.js"]

docker-example/src/server.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
var http = require('http');
2+
3+
var server = http.createServer(function (request, response) {
4+
response.writeHead(200, {"Content-Type": "text/plain"});
5+
response.end("Hello World!\n");
6+
});
7+
8+
server.listen(8080);
9+
10+
console.log("Server running at http://127.0.0.1:8080/");
11+
12+
process.on('SIGINT', function() {
13+
process.exit();
14+
});

0 commit comments

Comments
 (0)