mirror of
https://github.com/autistic-symposium/backend-and-orchestration-toolkit.git
synced 2025-06-08 15:02:55 -04:00
first commit
This commit is contained in:
commit
f4a26dbadc
8 changed files with 457 additions and 0 deletions
8
node_server_example/Dockerfile
Executable file
8
node_server_example/Dockerfile
Executable file
|
@ -0,0 +1,8 @@
|
|||
FROM node:4.4
|
||||
MAINTAINER "bt3"
|
||||
|
||||
EXPOSE 1337
|
||||
|
||||
COPY server.js .
|
||||
|
||||
CMD node server.js
|
15
node_server_example/Makefile
Executable file
15
node_server_example/Makefile
Executable file
|
@ -0,0 +1,15 @@
|
|||
.DELETE_ON_ERROR:
|
||||
|
||||
build:
|
||||
docker build -t node_app_test .
|
||||
|
||||
run:
|
||||
docker run -d -p 1337:1337 node_app_test
|
||||
|
||||
curl:
|
||||
curl localhost:1337
|
||||
|
||||
status:
|
||||
docker ps
|
||||
|
||||
.PHONY: build run curl status
|
44
node_server_example/README.md
Executable file
44
node_server_example/README.md
Executable file
|
@ -0,0 +1,44 @@
|
|||
# Spinning up a Hello World node server in docker
|
||||
|
||||
Build the image:
|
||||
|
||||
```
|
||||
$ make build:
|
||||
```
|
||||
|
||||
Run the container:
|
||||
|
||||
```
|
||||
$ make run
|
||||
```
|
||||
docker build -t node_app_test .
|
||||
|
||||
Check whether the server worked:
|
||||
```
|
||||
$ make curl
|
||||
```
|
||||
|
||||
Check container's status:
|
||||
```
|
||||
$ make status
|
||||
```
|
||||
|
||||
|
||||
#### Other useful commands
|
||||
|
||||
Exec inside the container:
|
||||
|
||||
```
|
||||
$ docker exec -i -t <container name from status> /bin/bash
|
||||
```
|
||||
|
||||
Check images in disk:
|
||||
|
||||
```
|
||||
$ docker images
|
||||
```
|
||||
|
||||
|
||||
## Some References:
|
||||
|
||||
* [Dockerfiles good practices](https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/#general-guidelines-and-recommendations).
|
18
node_server_example/node_example_kube_config.yaml
Executable file
18
node_server_example/node_example_kube_config.yaml
Executable file
|
@ -0,0 +1,18 @@
|
|||
apiVersion: extensions/v1beta1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: node_app_test
|
||||
spec:
|
||||
replicas: 1
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
run: node_app_test
|
||||
spec:
|
||||
containers:
|
||||
- name: node_app_test
|
||||
image: node_app_test:1.0
|
||||
ports:
|
||||
- containerPort: 1337
|
||||
imagePullSecrets:
|
||||
- name: <encrypted password your container registry>
|
11
node_server_example/server.js
Executable file
11
node_server_example/server.js
Executable file
|
@ -0,0 +1,11 @@
|
|||
var os = require("os");
|
||||
var hostname = os.hostname();
|
||||
var http = require('http');
|
||||
var handleRequest = function(request, response) {
|
||||
console.log('Received request for URL: ' + request.url);
|
||||
response.writeHead(200);
|
||||
response.end("Hello from container " + hostname + "!\n\n");
|
||||
};
|
||||
var www = http.createServer(handleRequest);
|
||||
www.listen(1337);
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue