Functional Testing

Shell scripts to test k8s and os conversion
which can be ran by following command in root dir
`./script/test/cmd/tests.sh`
This commit is contained in:
Suraj Deshmukh
2016-08-08 04:39:10 +00:00
parent 786f0fee9b
commit 9a4e953555
35 changed files with 2918 additions and 0 deletions
+14
View File
@@ -0,0 +1,14 @@
## Docker Compose Etherpad
Etherpad and Mariadb
### Usage
The simplest thing to do:
```bash
export $(cat envs)
docker-compose up
```
To customize the values edit `envs` file.
@@ -0,0 +1,11 @@
version: "2"
services:
mariadb:
ports:
- 3306
etherpad:
ports:
- "80:9001"
@@ -0,0 +1,5 @@
version: "2"
services:
mariadb:
image: centos/mariadb
+25
View File
@@ -0,0 +1,25 @@
version: "2"
services:
mariadb:
image: centos/mariadb
ports:
- "$DB_PORT"
environment:
MYSQL_ROOT_PASSWORD: $ROOT_PASS
MYSQL_DATABASE: $DB_NAME
MYSQL_PASSWORD: $DB_PASS
MYSQL_USER: $DB_USER
etherpad:
image: centos/etherpad
ports:
- "80:9001"
depends_on:
- mariadb
environment:
DB_HOST: $DB_HOST
DB_DBID: $DB_NAME
DB_PASS: $DB_PASS
DB_PORT: $DB_PORT
DB_USER: $DB_USER
+6
View File
@@ -0,0 +1,6 @@
DB_HOST=mariadb
ROOT_PASS=etherpad
DB_NAME=etherpad
DB_PASS=etherpad
DB_USER=etherpad
DB_PORT=3306
+184
View File
@@ -0,0 +1,184 @@
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "mariadb",
"creationTimestamp": null,
"labels": {
"service": "mariadb"
}
},
"spec": {
"ports": [
{
"name": "3306",
"protocol": "TCP",
"port": 3306,
"targetPort": 3306
}
],
"selector": {
"service": "mariadb"
}
},
"status": {
"loadBalancer": {}
}
}
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "etherpad",
"creationTimestamp": null,
"labels": {
"service": "etherpad"
}
},
"spec": {
"ports": [
{
"name": "80",
"protocol": "TCP",
"port": 80,
"targetPort": 9001
}
],
"selector": {
"service": "etherpad"
}
},
"status": {
"loadBalancer": {}
}
}
{
"kind": "Deployment",
"apiVersion": "extensions/v1beta1",
"metadata": {
"name": "etherpad",
"creationTimestamp": null,
"labels": {
"service": "etherpad"
}
},
"spec": {
"replicas": 1,
"selector": {
"matchLabels": {
"service": "etherpad"
}
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "etherpad"
}
},
"spec": {
"containers": [
{
"name": "etherpad",
"image": "centos/etherpad",
"ports": [
{
"containerPort": 9001,
"protocol": "TCP"
}
],
"env": [
{
"name": "DB_HOST",
"value": "mariadb"
},
{
"name": "DB_PASS",
"value": "etherpad"
},
{
"name": "DB_PORT",
"value": "3306"
},
{
"name": "DB_USER",
"value": "etherpad"
},
{
"name": "DB_DBID",
"value": "etherpad"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
},
"strategy": {}
},
"status": {}
}
{
"kind": "Deployment",
"apiVersion": "extensions/v1beta1",
"metadata": {
"name": "mariadb",
"creationTimestamp": null,
"labels": {
"service": "mariadb"
}
},
"spec": {
"replicas": 1,
"selector": {
"matchLabels": {
"service": "mariadb"
}
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "mariadb"
}
},
"spec": {
"containers": [
{
"name": "mariadb",
"image": "centos/mariadb",
"ports": [
{
"containerPort": 3306,
"protocol": "TCP"
}
],
"env": [
{
"name": "MYSQL_USER",
"value": "etherpad"
},
{
"name": "MYSQL_DATABASE",
"value": "etherpad"
},
{
"name": "MYSQL_PASSWORD",
"value": "etherpad"
},
{
"name": "MYSQL_ROOT_PASSWORD",
"value": "etherpad"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
},
"strategy": {}
},
"status": {}
}
+188
View File
@@ -0,0 +1,188 @@
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "etherpad",
"creationTimestamp": null,
"labels": {
"service": "etherpad"
}
},
"spec": {
"ports": [
{
"name": "80",
"protocol": "TCP",
"port": 80,
"targetPort": 9001
}
],
"selector": {
"service": "etherpad"
}
},
"status": {
"loadBalancer": {}
}
}
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "mariadb",
"creationTimestamp": null,
"labels": {
"service": "mariadb"
}
},
"spec": {
"ports": [
{
"name": "3306",
"protocol": "TCP",
"port": 3306,
"targetPort": 3306
}
],
"selector": {
"service": "mariadb"
}
},
"status": {
"loadBalancer": {}
}
}
{
"kind": "DeploymentConfig",
"apiVersion": "v1",
"metadata": {
"name": "etherpad",
"creationTimestamp": null,
"labels": {
"service": "etherpad"
}
},
"spec": {
"strategy": {
"resources": {}
},
"triggers": null,
"replicas": 1,
"test": false,
"selector": {
"service": "etherpad"
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "etherpad"
}
},
"spec": {
"containers": [
{
"name": "etherpad",
"image": "centos/etherpad",
"ports": [
{
"containerPort": 9001,
"protocol": "TCP"
}
],
"env": [
{
"name": "DB_PORT",
"value": "3306"
},
{
"name": "DB_USER",
"value": "etherpad"
},
{
"name": "DB_DBID",
"value": "etherpad"
},
{
"name": "DB_HOST",
"value": "mariadb"
},
{
"name": "DB_PASS",
"value": "etherpad"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
}
},
"status": {}
}
{
"kind": "DeploymentConfig",
"apiVersion": "v1",
"metadata": {
"name": "mariadb",
"creationTimestamp": null,
"labels": {
"service": "mariadb"
}
},
"spec": {
"strategy": {
"resources": {}
},
"triggers": null,
"replicas": 1,
"test": false,
"selector": {
"service": "mariadb"
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "mariadb"
}
},
"spec": {
"containers": [
{
"name": "mariadb",
"image": "centos/mariadb",
"ports": [
{
"containerPort": 3306,
"protocol": "TCP"
}
],
"env": [
{
"name": "MYSQL_ROOT_PASSWORD",
"value": "etherpad"
},
{
"name": "MYSQL_USER",
"value": "etherpad"
},
{
"name": "MYSQL_DATABASE",
"value": "etherpad"
},
{
"name": "MYSQL_PASSWORD",
"value": "etherpad"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
}
},
"status": {}
}
+10
View File
@@ -0,0 +1,10 @@
## Flask and Redis
For running this app
```bash
mkdir /opt/redis
sudo chcon -Rt svirt_sandbox_file_t /opt/redis
docker-compose up
```
+20
View File
@@ -0,0 +1,20 @@
version: "2"
services:
redis:
image: dharmit/redis
command: redis-server
ports:
- "6379"
volumes:
- /opt/redis:/redis
flask:
image: dharmit/flask
ports:
- "31000:5000"
depends_on:
- redis
environment:
REDIS_PORT: 6379
REDIS_HOST: redis
+168
View File
@@ -0,0 +1,168 @@
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "redis",
"creationTimestamp": null,
"labels": {
"service": "redis"
}
},
"spec": {
"ports": [
{
"name": "6379",
"protocol": "TCP",
"port": 6379,
"targetPort": 6379
}
],
"selector": {
"service": "redis"
}
},
"status": {
"loadBalancer": {}
}
}
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "flask",
"creationTimestamp": null,
"labels": {
"service": "flask"
}
},
"spec": {
"ports": [
{
"name": "31000",
"protocol": "TCP",
"port": 31000,
"targetPort": 5000
}
],
"selector": {
"service": "flask"
}
},
"status": {
"loadBalancer": {}
}
}
{
"kind": "Deployment",
"apiVersion": "extensions/v1beta1",
"metadata": {
"name": "redis",
"creationTimestamp": null,
"labels": {
"service": "redis"
}
},
"spec": {
"replicas": 1,
"selector": {
"matchLabels": {
"service": "redis"
}
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "redis"
}
},
"spec": {
"volumes": [
{
"name": "fpllngzieyoh43e0133o",
"hostPath": {
"path": "/opt/redis"
}
}
],
"containers": [
{
"name": "redis",
"image": "dharmit/redis",
"ports": [
{
"containerPort": 6379,
"protocol": "TCP"
}
],
"resources": {},
"volumeMounts": [
{
"name": "fpllngzieyoh43e0133o",
"mountPath": "/redis"
}
]
}
],
"restartPolicy": "Always"
}
},
"strategy": {}
},
"status": {}
}
{
"kind": "Deployment",
"apiVersion": "extensions/v1beta1",
"metadata": {
"name": "flask",
"creationTimestamp": null,
"labels": {
"service": "flask"
}
},
"spec": {
"replicas": 1,
"selector": {
"matchLabels": {
"service": "flask"
}
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "flask"
}
},
"spec": {
"containers": [
{
"name": "flask",
"image": "dharmit/flask",
"ports": [
{
"containerPort": 5000,
"protocol": "TCP"
}
],
"env": [
{
"name": "REDIS_HOST",
"value": "redis"
},
{
"name": "REDIS_PORT",
"value": "6379"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
},
"strategy": {}
},
"status": {}
}
+172
View File
@@ -0,0 +1,172 @@
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "redis",
"creationTimestamp": null,
"labels": {
"service": "redis"
}
},
"spec": {
"ports": [
{
"name": "6379",
"protocol": "TCP",
"port": 6379,
"targetPort": 6379
}
],
"selector": {
"service": "redis"
}
},
"status": {
"loadBalancer": {}
}
}
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "flask",
"creationTimestamp": null,
"labels": {
"service": "flask"
}
},
"spec": {
"ports": [
{
"name": "31000",
"protocol": "TCP",
"port": 31000,
"targetPort": 5000
}
],
"selector": {
"service": "flask"
}
},
"status": {
"loadBalancer": {}
}
}
{
"kind": "DeploymentConfig",
"apiVersion": "v1",
"metadata": {
"name": "redis",
"creationTimestamp": null,
"labels": {
"service": "redis"
}
},
"spec": {
"strategy": {
"resources": {}
},
"triggers": null,
"replicas": 1,
"test": false,
"selector": {
"service": "redis"
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "redis"
}
},
"spec": {
"volumes": [
{
"name": "fpllngzieyoh43e0133o",
"hostPath": {
"path": "/opt/redis"
}
}
],
"containers": [
{
"name": "redis",
"image": "dharmit/redis",
"ports": [
{
"containerPort": 6379,
"protocol": "TCP"
}
],
"resources": {},
"volumeMounts": [
{
"name": "fpllngzieyoh43e0133o",
"mountPath": "/redis"
}
]
}
],
"restartPolicy": "Always"
}
}
},
"status": {}
}
{
"kind": "DeploymentConfig",
"apiVersion": "v1",
"metadata": {
"name": "flask",
"creationTimestamp": null,
"labels": {
"service": "flask"
}
},
"spec": {
"strategy": {
"resources": {}
},
"triggers": null,
"replicas": 1,
"test": false,
"selector": {
"service": "flask"
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "flask"
}
},
"spec": {
"containers": [
{
"name": "flask",
"image": "dharmit/flask",
"ports": [
{
"containerPort": 5000,
"protocol": "TCP"
}
],
"env": [
{
"name": "REDIS_HOST",
"value": "redis"
},
{
"name": "REDIS_PORT",
"value": "6379"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
}
},
"status": {}
}
+14
View File
@@ -0,0 +1,14 @@
## Gitlab
Gitlab, Postgresql, Redis
### Usage
The simplest thing to do:
```bash
export $(cat envs)
docker-compose up
```
To customize the values edit `envs` file.
+33
View File
@@ -0,0 +1,33 @@
version: "2"
services:
postgresql:
image: swordphilic/postgresql
ports:
- "$DB_PORT"
environment:
DB_NAME: $DB_NAME
DB_PASS: $DB_PASS
DB_USER: $DB_USER
gitlab:
image: swordphilic/gitlab
ports:
- "30000:80"
- "30001:443"
- "30002:22"
restart: always
environment:
DB_TYPE: postgres
DB_HOST: postgresql
DB_PORT: $DB_PORT
DB_NAME: $DB_NAME
DB_PASS: $DB_PASS
DB_USER: $DB_USER
REDIS_HOST: redis
REDIS_PORT: $REDIS_PORT
redis:
image: swordphilic/redis
ports:
- "$REDIS_PORT"
+5
View File
@@ -0,0 +1,5 @@
DB_PORT=5432
DB_NAME=gitlab
DB_PASS=gitlab
DB_USER=gitlab
REDIS_PORT=6379
+284
View File
@@ -0,0 +1,284 @@
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "redis",
"creationTimestamp": null,
"labels": {
"service": "redis"
}
},
"spec": {
"ports": [
{
"name": "6379",
"protocol": "TCP",
"port": 6379,
"targetPort": 6379
}
],
"selector": {
"service": "redis"
}
},
"status": {
"loadBalancer": {}
}
}
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "gitlab",
"creationTimestamp": null,
"labels": {
"service": "gitlab"
}
},
"spec": {
"ports": [
{
"name": "30000",
"protocol": "TCP",
"port": 30000,
"targetPort": 80
},
{
"name": "30001",
"protocol": "TCP",
"port": 30001,
"targetPort": 443
},
{
"name": "30002",
"protocol": "TCP",
"port": 30002,
"targetPort": 22
}
],
"selector": {
"service": "gitlab"
}
},
"status": {
"loadBalancer": {}
}
}
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "postgresql",
"creationTimestamp": null,
"labels": {
"service": "postgresql"
}
},
"spec": {
"ports": [
{
"name": "5432",
"protocol": "TCP",
"port": 5432,
"targetPort": 5432
}
],
"selector": {
"service": "postgresql"
}
},
"status": {
"loadBalancer": {}
}
}
{
"kind": "Deployment",
"apiVersion": "extensions/v1beta1",
"metadata": {
"name": "redis",
"creationTimestamp": null,
"labels": {
"service": "redis"
}
},
"spec": {
"replicas": 1,
"selector": {
"matchLabels": {
"service": "redis"
}
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "redis"
}
},
"spec": {
"containers": [
{
"name": "redis",
"image": "swordphilic/redis",
"ports": [
{
"containerPort": 6379,
"protocol": "TCP"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
},
"strategy": {}
},
"status": {}
}
{
"kind": "Deployment",
"apiVersion": "extensions/v1beta1",
"metadata": {
"name": "gitlab",
"creationTimestamp": null,
"labels": {
"service": "gitlab"
}
},
"spec": {
"replicas": 1,
"selector": {
"matchLabels": {
"service": "gitlab"
}
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "gitlab"
}
},
"spec": {
"containers": [
{
"name": "gitlab",
"image": "swordphilic/gitlab",
"ports": [
{
"containerPort": 80,
"protocol": "TCP"
},
{
"containerPort": 443,
"protocol": "TCP"
},
{
"containerPort": 22,
"protocol": "TCP"
}
],
"env": [
{
"name": "DB_HOST",
"value": "postgresql"
},
{
"name": "DB_NAME",
"value": "gitlab"
},
{
"name": "DB_PASS",
"value": "gitlab"
},
{
"name": "DB_PORT",
"value": "5432"
},
{
"name": "DB_TYPE",
"value": "postgres"
},
{
"name": "DB_USER",
"value": "gitlab"
},
{
"name": "REDIS_HOST",
"value": "redis"
},
{
"name": "REDIS_PORT",
"value": "6379"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
},
"strategy": {}
},
"status": {}
}
{
"kind": "Deployment",
"apiVersion": "extensions/v1beta1",
"metadata": {
"name": "postgresql",
"creationTimestamp": null,
"labels": {
"service": "postgresql"
}
},
"spec": {
"replicas": 1,
"selector": {
"matchLabels": {
"service": "postgresql"
}
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "postgresql"
}
},
"spec": {
"containers": [
{
"name": "postgresql",
"image": "swordphilic/postgresql",
"ports": [
{
"containerPort": 5432,
"protocol": "TCP"
}
],
"env": [
{
"name": "DB_NAME",
"value": "gitlab"
},
{
"name": "DB_PASS",
"value": "gitlab"
},
{
"name": "DB_USER",
"value": "gitlab"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
},
"strategy": {}
},
"status": {}
}
+290
View File
@@ -0,0 +1,290 @@
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "postgresql",
"creationTimestamp": null,
"labels": {
"service": "postgresql"
}
},
"spec": {
"ports": [
{
"name": "5432",
"protocol": "TCP",
"port": 5432,
"targetPort": 5432
}
],
"selector": {
"service": "postgresql"
}
},
"status": {
"loadBalancer": {}
}
}
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "redis",
"creationTimestamp": null,
"labels": {
"service": "redis"
}
},
"spec": {
"ports": [
{
"name": "6379",
"protocol": "TCP",
"port": 6379,
"targetPort": 6379
}
],
"selector": {
"service": "redis"
}
},
"status": {
"loadBalancer": {}
}
}
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "gitlab",
"creationTimestamp": null,
"labels": {
"service": "gitlab"
}
},
"spec": {
"ports": [
{
"name": "30000",
"protocol": "TCP",
"port": 30000,
"targetPort": 80
},
{
"name": "30001",
"protocol": "TCP",
"port": 30001,
"targetPort": 443
},
{
"name": "30002",
"protocol": "TCP",
"port": 30002,
"targetPort": 22
}
],
"selector": {
"service": "gitlab"
}
},
"status": {
"loadBalancer": {}
}
}
{
"kind": "DeploymentConfig",
"apiVersion": "v1",
"metadata": {
"name": "postgresql",
"creationTimestamp": null,
"labels": {
"service": "postgresql"
}
},
"spec": {
"strategy": {
"resources": {}
},
"triggers": null,
"replicas": 1,
"test": false,
"selector": {
"service": "postgresql"
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "postgresql"
}
},
"spec": {
"containers": [
{
"name": "postgresql",
"image": "swordphilic/postgresql",
"ports": [
{
"containerPort": 5432,
"protocol": "TCP"
}
],
"env": [
{
"name": "DB_NAME",
"value": "gitlab"
},
{
"name": "DB_PASS",
"value": "gitlab"
},
{
"name": "DB_USER",
"value": "gitlab"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
}
},
"status": {}
}
{
"kind": "DeploymentConfig",
"apiVersion": "v1",
"metadata": {
"name": "redis",
"creationTimestamp": null,
"labels": {
"service": "redis"
}
},
"spec": {
"strategy": {
"resources": {}
},
"triggers": null,
"replicas": 1,
"test": false,
"selector": {
"service": "redis"
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "redis"
}
},
"spec": {
"containers": [
{
"name": "redis",
"image": "swordphilic/redis",
"ports": [
{
"containerPort": 6379,
"protocol": "TCP"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
}
},
"status": {}
}
{
"kind": "DeploymentConfig",
"apiVersion": "v1",
"metadata": {
"name": "gitlab",
"creationTimestamp": null,
"labels": {
"service": "gitlab"
}
},
"spec": {
"strategy": {
"resources": {}
},
"triggers": null,
"replicas": 1,
"test": false,
"selector": {
"service": "gitlab"
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "gitlab"
}
},
"spec": {
"containers": [
{
"name": "gitlab",
"image": "swordphilic/gitlab",
"ports": [
{
"containerPort": 80,
"protocol": "TCP"
},
{
"containerPort": 443,
"protocol": "TCP"
},
{
"containerPort": 22,
"protocol": "TCP"
}
],
"env": [
{
"name": "DB_HOST",
"value": "postgresql"
},
{
"name": "DB_NAME",
"value": "gitlab"
},
{
"name": "DB_PASS",
"value": "gitlab"
},
{
"name": "DB_PORT",
"value": "5432"
},
{
"name": "DB_TYPE",
"value": "postgres"
},
{
"name": "DB_USER",
"value": "gitlab"
},
{
"name": "REDIS_HOST",
"value": "redis"
},
{
"name": "REDIS_PORT",
"value": "6379"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
}
},
"status": {}
}
+7
View File
@@ -0,0 +1,7 @@
### Usage
Ref: http://anandmanisankar.com/posts/docker-container-nginx-node-redis-example/
```bash
docker-compose up
```
@@ -0,0 +1,25 @@
version: "2"
services:
nginx:
build: ./nginx
ports:
- "80:80"
restart: always
node1:
build: ./node
ports:
- "8080"
node2:
build: ./node
ports:
- "8080"
node3:
build: ./node
ports:
- "8080"
redis:
image: redis
ports:
- "6379"
@@ -0,0 +1,8 @@
# Set nginx base image
FROM nginx
# File Author / Maintainer
MAINTAINER Anand Mani Sankar
# Copy custom configuration file from the current directory
COPY nginx.conf /etc/nginx/nginx.conf
+26
View File
@@ -0,0 +1,26 @@
worker_processes 4;
events { worker_connections 1024; }
http {
upstream node-app {
least_conn;
server node1:8080 weight=60 max_fails=10 fail_timeout=60s;
server node2:8080 weight=60 max_fails=10 fail_timeout=60s;
server node3:8080 weight=60 max_fails=10 fail_timeout=60s;
}
server {
listen 80;
location / {
proxy_pass http://node-app;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
}
+16
View File
@@ -0,0 +1,16 @@
FROM centos:7
RUN yum -y install epel-release && yum install -y nodejs npm gcc* make
RUN /bin/bash -c 'npm install -g nodemon' && mkdir /src
# Define working directory
WORKDIR /src
ADD . /src
RUN cd /src && npm install
# Expose port
EXPOSE 8080
# Run app using nodemon
CMD /bin/bash -c 'nodemon /src/index.js'
+28
View File
@@ -0,0 +1,28 @@
var express = require('express'),
http = require('http'),
redis = require('redis');
var app = express();
console.log(process.env.REDIS_PORT_6379_TCP_ADDR + ':' + process.env.REDIS_PORT_6379_TCP_PORT);
// APPROACH 1: Using environment variables created by Docker
// var client = redis.createClient(
// process.env.REDIS_PORT_6379_TCP_PORT,
// process.env.REDIS_PORT_6379_TCP_ADDR
// );
// APPROACH 2: Using host entries created by Docker in /etc/hosts (RECOMMENDED)
var client = redis.createClient('6379', 'redis');
app.get('/', function(req, res, next) {
client.incr('counter', function(err, counter) {
if(err) return next(err);
res.send('This page has been viewed ' + counter + ' times!');
});
});
http.createServer(app).listen(process.env.PORT || 8080, function() {
console.log('Listening on port ' + (process.env.PORT || 8080));
});
+14
View File
@@ -0,0 +1,14 @@
{
"name": "node",
"version": "1.0.0",
"description": "",
"main": "index.js",
"author": "Anand Mani Sankar",
"license": "ISC",
"dependencies": {
"express": "^4.12.3",
"hiredis": "^0.2.0",
"mocha": "^2.2.1",
"redis": "^0.12.1"
}
}
@@ -0,0 +1,7 @@
var assert = require("assert");
describe('Dummy Test', function(){
it('should pass', function(){
assert.ok(true, "It is true!");
});
});
+356
View File
@@ -0,0 +1,356 @@
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "redis",
"creationTimestamp": null,
"labels": {
"service": "redis"
}
},
"spec": {
"ports": [
{
"name": "6379",
"protocol": "TCP",
"port": 6379,
"targetPort": 6379
}
],
"selector": {
"service": "redis"
}
},
"status": {
"loadBalancer": {}
}
}
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "nginx",
"creationTimestamp": null,
"labels": {
"service": "nginx"
}
},
"spec": {
"ports": [
{
"name": "80",
"protocol": "TCP",
"port": 80,
"targetPort": 80
}
],
"selector": {
"service": "nginx"
}
},
"status": {
"loadBalancer": {}
}
}
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "node1",
"creationTimestamp": null,
"labels": {
"service": "node1"
}
},
"spec": {
"ports": [
{
"name": "8080",
"protocol": "TCP",
"port": 8080,
"targetPort": 8080
}
],
"selector": {
"service": "node1"
}
},
"status": {
"loadBalancer": {}
}
}
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "node2",
"creationTimestamp": null,
"labels": {
"service": "node2"
}
},
"spec": {
"ports": [
{
"name": "8080",
"protocol": "TCP",
"port": 8080,
"targetPort": 8080
}
],
"selector": {
"service": "node2"
}
},
"status": {
"loadBalancer": {}
}
}
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "node3",
"creationTimestamp": null,
"labels": {
"service": "node3"
}
},
"spec": {
"ports": [
{
"name": "8080",
"protocol": "TCP",
"port": 8080,
"targetPort": 8080
}
],
"selector": {
"service": "node3"
}
},
"status": {
"loadBalancer": {}
}
}
{
"kind": "Deployment",
"apiVersion": "extensions/v1beta1",
"metadata": {
"name": "nginx",
"creationTimestamp": null,
"labels": {
"service": "nginx"
}
},
"spec": {
"replicas": 1,
"selector": {
"matchLabels": {
"service": "nginx"
}
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "nginx"
}
},
"spec": {
"containers": [
{
"name": "nginx",
"ports": [
{
"containerPort": 80,
"protocol": "TCP"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
},
"strategy": {}
},
"status": {}
}
{
"kind": "Deployment",
"apiVersion": "extensions/v1beta1",
"metadata": {
"name": "node1",
"creationTimestamp": null,
"labels": {
"service": "node1"
}
},
"spec": {
"replicas": 1,
"selector": {
"matchLabels": {
"service": "node1"
}
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "node1"
}
},
"spec": {
"containers": [
{
"name": "node1",
"ports": [
{
"containerPort": 8080,
"protocol": "TCP"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
},
"strategy": {}
},
"status": {}
}
{
"kind": "Deployment",
"apiVersion": "extensions/v1beta1",
"metadata": {
"name": "node2",
"creationTimestamp": null,
"labels": {
"service": "node2"
}
},
"spec": {
"replicas": 1,
"selector": {
"matchLabels": {
"service": "node2"
}
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "node2"
}
},
"spec": {
"containers": [
{
"name": "node2",
"ports": [
{
"containerPort": 8080,
"protocol": "TCP"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
},
"strategy": {}
},
"status": {}
}
{
"kind": "Deployment",
"apiVersion": "extensions/v1beta1",
"metadata": {
"name": "node3",
"creationTimestamp": null,
"labels": {
"service": "node3"
}
},
"spec": {
"replicas": 1,
"selector": {
"matchLabels": {
"service": "node3"
}
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "node3"
}
},
"spec": {
"containers": [
{
"name": "node3",
"ports": [
{
"containerPort": 8080,
"protocol": "TCP"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
},
"strategy": {}
},
"status": {}
}
{
"kind": "Deployment",
"apiVersion": "extensions/v1beta1",
"metadata": {
"name": "redis",
"creationTimestamp": null,
"labels": {
"service": "redis"
}
},
"spec": {
"replicas": 1,
"selector": {
"matchLabels": {
"service": "redis"
}
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "redis"
}
},
"spec": {
"containers": [
{
"name": "redis",
"image": "redis",
"ports": [
{
"containerPort": 6379,
"protocol": "TCP"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
},
"strategy": {}
},
"status": {}
}
+366
View File
@@ -0,0 +1,366 @@
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "node3",
"creationTimestamp": null,
"labels": {
"service": "node3"
}
},
"spec": {
"ports": [
{
"name": "8080",
"protocol": "TCP",
"port": 8080,
"targetPort": 8080
}
],
"selector": {
"service": "node3"
}
},
"status": {
"loadBalancer": {}
}
}
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "redis",
"creationTimestamp": null,
"labels": {
"service": "redis"
}
},
"spec": {
"ports": [
{
"name": "6379",
"protocol": "TCP",
"port": 6379,
"targetPort": 6379
}
],
"selector": {
"service": "redis"
}
},
"status": {
"loadBalancer": {}
}
}
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "nginx",
"creationTimestamp": null,
"labels": {
"service": "nginx"
}
},
"spec": {
"ports": [
{
"name": "80",
"protocol": "TCP",
"port": 80,
"targetPort": 80
}
],
"selector": {
"service": "nginx"
}
},
"status": {
"loadBalancer": {}
}
}
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "node1",
"creationTimestamp": null,
"labels": {
"service": "node1"
}
},
"spec": {
"ports": [
{
"name": "8080",
"protocol": "TCP",
"port": 8080,
"targetPort": 8080
}
],
"selector": {
"service": "node1"
}
},
"status": {
"loadBalancer": {}
}
}
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "node2",
"creationTimestamp": null,
"labels": {
"service": "node2"
}
},
"spec": {
"ports": [
{
"name": "8080",
"protocol": "TCP",
"port": 8080,
"targetPort": 8080
}
],
"selector": {
"service": "node2"
}
},
"status": {
"loadBalancer": {}
}
}
{
"kind": "DeploymentConfig",
"apiVersion": "v1",
"metadata": {
"name": "nginx",
"creationTimestamp": null,
"labels": {
"service": "nginx"
}
},
"spec": {
"strategy": {
"resources": {}
},
"triggers": null,
"replicas": 1,
"test": false,
"selector": {
"service": "nginx"
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "nginx"
}
},
"spec": {
"containers": [
{
"name": "nginx",
"ports": [
{
"containerPort": 80,
"protocol": "TCP"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
}
},
"status": {}
}
{
"kind": "DeploymentConfig",
"apiVersion": "v1",
"metadata": {
"name": "node1",
"creationTimestamp": null,
"labels": {
"service": "node1"
}
},
"spec": {
"strategy": {
"resources": {}
},
"triggers": null,
"replicas": 1,
"test": false,
"selector": {
"service": "node1"
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "node1"
}
},
"spec": {
"containers": [
{
"name": "node1",
"ports": [
{
"containerPort": 8080,
"protocol": "TCP"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
}
},
"status": {}
}
{
"kind": "DeploymentConfig",
"apiVersion": "v1",
"metadata": {
"name": "node2",
"creationTimestamp": null,
"labels": {
"service": "node2"
}
},
"spec": {
"strategy": {
"resources": {}
},
"triggers": null,
"replicas": 1,
"test": false,
"selector": {
"service": "node2"
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "node2"
}
},
"spec": {
"containers": [
{
"name": "node2",
"ports": [
{
"containerPort": 8080,
"protocol": "TCP"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
}
},
"status": {}
}
{
"kind": "DeploymentConfig",
"apiVersion": "v1",
"metadata": {
"name": "node3",
"creationTimestamp": null,
"labels": {
"service": "node3"
}
},
"spec": {
"strategy": {
"resources": {}
},
"triggers": null,
"replicas": 1,
"test": false,
"selector": {
"service": "node3"
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "node3"
}
},
"spec": {
"containers": [
{
"name": "node3",
"ports": [
{
"containerPort": 8080,
"protocol": "TCP"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
}
},
"status": {}
}
{
"kind": "DeploymentConfig",
"apiVersion": "v1",
"metadata": {
"name": "redis",
"creationTimestamp": null,
"labels": {
"service": "redis"
}
},
"spec": {
"strategy": {
"resources": {}
},
"triggers": null,
"replicas": 1,
"test": false,
"selector": {
"service": "redis"
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "redis"
}
},
"spec": {
"containers": [
{
"name": "redis",
"image": "redis",
"ports": [
{
"containerPort": 6379,
"protocol": "TCP"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
}
},
"status": {}
}
+14
View File
@@ -0,0 +1,14 @@
## Docker Compose Wordpress
Wordpress and Mariadb
### Usage
The simplest thing to do:
```bash
export $(cat envs)
docker-compose up
```
To customize the values edit `envs` file.
+25
View File
@@ -0,0 +1,25 @@
version: "2"
services:
mariadb:
image: centos/mariadb
ports:
- "$DB_PORT"
environment:
MYSQL_ROOT_PASSWORD: $ROOT_PASS
MYSQL_DATABASE: $DB_NAME
MYSQL_PASSWORD: $DB_PASS
MYSQL_USER: $DB_USER
wordpress:
image: wordpress
ports:
- "8080:80"
depends_on:
- mariadb
restart: always
environment:
WORDPRESS_DB_HOST: $DB_HOST:$DB_PORT
WORDPRESS_DB_NAME: $DB_NAME
WORDPRESS_DB_PASSWORD: $DB_PASS
WORDPRESS_DB_USER: $DB_USER
+6
View File
@@ -0,0 +1,6 @@
DB_HOST=mariadb
ROOT_PASS=wordpress
DB_NAME=wordpress
DB_PASS=wordpress
DB_USER=wordpress
DB_PORT=3306
+180
View File
@@ -0,0 +1,180 @@
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "mariadb",
"creationTimestamp": null,
"labels": {
"service": "mariadb"
}
},
"spec": {
"ports": [
{
"name": "3306",
"protocol": "TCP",
"port": 3306,
"targetPort": 3306
}
],
"selector": {
"service": "mariadb"
}
},
"status": {
"loadBalancer": {}
}
}
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "wordpress",
"creationTimestamp": null,
"labels": {
"service": "wordpress"
}
},
"spec": {
"ports": [
{
"name": "8080",
"protocol": "TCP",
"port": 8080,
"targetPort": 80
}
],
"selector": {
"service": "wordpress"
}
},
"status": {
"loadBalancer": {}
}
}
{
"kind": "Deployment",
"apiVersion": "extensions/v1beta1",
"metadata": {
"name": "mariadb",
"creationTimestamp": null,
"labels": {
"service": "mariadb"
}
},
"spec": {
"replicas": 1,
"selector": {
"matchLabels": {
"service": "mariadb"
}
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "mariadb"
}
},
"spec": {
"containers": [
{
"name": "mariadb",
"image": "centos/mariadb",
"ports": [
{
"containerPort": 3306,
"protocol": "TCP"
}
],
"env": [
{
"name": "MYSQL_PASSWORD",
"value": "wordpress"
},
{
"name": "MYSQL_ROOT_PASSWORD",
"value": "wordpress"
},
{
"name": "MYSQL_USER",
"value": "wordpress"
},
{
"name": "MYSQL_DATABASE",
"value": "wordpress"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
},
"strategy": {}
},
"status": {}
}
{
"kind": "Deployment",
"apiVersion": "extensions/v1beta1",
"metadata": {
"name": "wordpress",
"creationTimestamp": null,
"labels": {
"service": "wordpress"
}
},
"spec": {
"replicas": 1,
"selector": {
"matchLabels": {
"service": "wordpress"
}
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "wordpress"
}
},
"spec": {
"containers": [
{
"name": "wordpress",
"image": "wordpress",
"ports": [
{
"containerPort": 80,
"protocol": "TCP"
}
],
"env": [
{
"name": "WORDPRESS_DB_HOST",
"value": "mariadb:3306"
},
{
"name": "WORDPRESS_DB_NAME",
"value": "wordpress"
},
{
"name": "WORDPRESS_DB_PASSWORD",
"value": "wordpress"
},
{
"name": "WORDPRESS_DB_USER",
"value": "wordpress"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
},
"strategy": {}
},
"status": {}
}
+184
View File
@@ -0,0 +1,184 @@
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "wordpress",
"creationTimestamp": null,
"labels": {
"service": "wordpress"
}
},
"spec": {
"ports": [
{
"name": "8080",
"protocol": "TCP",
"port": 8080,
"targetPort": 80
}
],
"selector": {
"service": "wordpress"
}
},
"status": {
"loadBalancer": {}
}
}
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "mariadb",
"creationTimestamp": null,
"labels": {
"service": "mariadb"
}
},
"spec": {
"ports": [
{
"name": "3306",
"protocol": "TCP",
"port": 3306,
"targetPort": 3306
}
],
"selector": {
"service": "mariadb"
}
},
"status": {
"loadBalancer": {}
}
}
{
"kind": "DeploymentConfig",
"apiVersion": "v1",
"metadata": {
"name": "wordpress",
"creationTimestamp": null,
"labels": {
"service": "wordpress"
}
},
"spec": {
"strategy": {
"resources": {}
},
"triggers": null,
"replicas": 1,
"test": false,
"selector": {
"service": "wordpress"
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "wordpress"
}
},
"spec": {
"containers": [
{
"name": "wordpress",
"image": "wordpress",
"ports": [
{
"containerPort": 80,
"protocol": "TCP"
}
],
"env": [
{
"name": "WORDPRESS_DB_NAME",
"value": "wordpress"
},
{
"name": "WORDPRESS_DB_PASSWORD",
"value": "wordpress"
},
{
"name": "WORDPRESS_DB_USER",
"value": "wordpress"
},
{
"name": "WORDPRESS_DB_HOST",
"value": "mariadb:3306"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
}
},
"status": {}
}
{
"kind": "DeploymentConfig",
"apiVersion": "v1",
"metadata": {
"name": "mariadb",
"creationTimestamp": null,
"labels": {
"service": "mariadb"
}
},
"spec": {
"strategy": {
"resources": {}
},
"triggers": null,
"replicas": 1,
"test": false,
"selector": {
"service": "mariadb"
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "mariadb"
}
},
"spec": {
"containers": [
{
"name": "mariadb",
"image": "centos/mariadb",
"ports": [
{
"containerPort": 3306,
"protocol": "TCP"
}
],
"env": [
{
"name": "MYSQL_ROOT_PASSWORD",
"value": "wordpress"
},
{
"name": "MYSQL_USER",
"value": "wordpress"
},
{
"name": "MYSQL_DATABASE",
"value": "wordpress"
},
{
"name": "MYSQL_PASSWORD",
"value": "wordpress"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
}
},
"status": {}
}