Skip to content

Commit

Permalink
Bump v0.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Walther committed Dec 7, 2017
1 parent 71ea6a0 commit 962cd7d
Show file tree
Hide file tree
Showing 17 changed files with 257 additions and 78 deletions.
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,7 @@ insert_final_newline = false
[**/templates/**]
trim_trailing_whitespace = false
insert_final_newline = false

[{Makefile,**.mk}]
# Use tabs for indentation (Makefiles require tabs)
indent_style = tab
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@

# node.js
node_modules
.data
50 changes: 26 additions & 24 deletions .verb.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,7 @@

Just another "Hello World" docker image to be used in various experiments ...

### Table of Contents

<details>

<!-- toc -->

</details>
Note: This Docker image is definitely not designed to be used in a production environment as it could result into serious security issues. But it's nice to be added to your toolbox when playing with Docker/Docker Swarm/Kubernetes, etc.

## Usage

Expand All @@ -27,7 +21,7 @@ $ docker pull stefanwalther/{%=name%}
```

```sh
$ docker run -it stefanwalther/{%=name%}
$ docker run -it -p 3000:3000 stefanwalther/{%=name%}
```

### With docker-compose
Expand All @@ -38,9 +32,9 @@ services:
hello-world:
image: stefanwalther/{%=name%}
ports:
- 3004:3004
- 3000:3000
environment:
- PORT=3004
- PORT=3000
```
Expand All @@ -51,11 +45,29 @@ services:
## Endpoints
### `/`
Just returns a "Hello World"
Just returns a "Hello World":
```json
{
"text": "Hello World"
}
```
### `/health-check`
Returns a typical health-check, useful to test health-checks in a microservice environment.
```json
{
"ts": "2017-12-07T22:25:34.489Z",
"version": "0.3.1",
"name": "docker-test",
"repository": {
"type": "git",
"url": "git+https://github.com/stefanwalther/docker-test.git"
}
}
```
### `/cmd`
Execute any command on the machine and get the result.
Expand All @@ -65,12 +77,12 @@ Parameters:
Usage:
```sh
# Process ls -la
$ curl http://localhost:3004/cmd/?def=ls%20-la
$ curl http://localhost:3000/cmd/?def=ls%20-la
```
Examples:
- `ls -la` - list the directory
- `curl -o -I -L -s -w "%{http_code}\n" http://localhost:3004/health-check` - Get the Http status code of the health-check
- `curl -o -I -L -s -w "%{http_code}\n" http://localhost:3000/health-check` - Get the Http status code of the health-check
### `/cmd-cron`
Create a cron job, executing a command.
Expand All @@ -84,7 +96,7 @@ Usage:
```sh
# Process "echo foo" with the following cron def: "* * * * *" (every minute)
$ curl http://localhost:3004/cmd-cron?def=echo%20foo&cron=*%20*%20*%20*%20*
$ curl http://localhost:3000/cmd-cron?def=echo%20foo&cron=*%20*%20*%20*%20*
```
Expand All @@ -98,16 +110,6 @@ $ curl http://localhost:3004/cmd-cron?def=echo%20foo&cron=*%20*%20*%20*%20*
- Using multi-stage builds to reduce Go images: https://blog.alexellis.io/mutli-stage-docker-builds/
- https://github.com/yamalight/node-docker-pkg-demo
## Todo
- [ ] Use read-pkg-up - makes more sense
- [ ] Enable codecov
- [ ] Enable codeclimate
- [ ] Enable necessary badges
- [ ] Use multistage builds to truly separate images
- [ ] Use nodemon to watch changes locally
- [ ] Optimize precommit (husky) to not run it if there were no changes in either .verb.md or in ./docs
- [ ] Provide missing tests
## About
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
v0.3.2:
date: "2017-12-07"
changes:
- "Make port 3000 the default everywhere"
- "Add a Makefile"
v0.3.1:
date: "2017-09-18"
changes:
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ FROM BASE as RELEASE
COPY --from=dependencies /app/prod_node_modules ./node_modules
COPY /src ./src/

COPY ./nodemon.json ./

EXPOSE $PORT

CMD ["npm", "run", "start"]
Expand Down
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
help: ## Show this help.
@echo ''
@echo 'Available commands:'
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
@echo ''
.PHONY: help

gen-readme: ## Generate README.md (using docker-verb)
docker run --rm -v ${PWD}:/opt/verb stefanwalther/verb
.PHONY: gen-readme
69 changes: 27 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,7 @@

Just another "Hello World" docker image to be used in various experiments ...

### Table of Contents

<details>

- [Usage](#usage)
* [With docker-compose](#with-docker-compose)
- [Configuration](#configuration)
- [Endpoints](#endpoints)
* [`/`](#)
* [`/health-check`](#health-check)
* [`/cmd`](#cmd)
* [`/cmd-cron`](#cmd-cron)
- [Experiments](#experiments)
* [Multistage Builds](#multistage-builds)
- [Todo](#todo)
- [About](#about)
* [Author](#author)
* [Contributing](#contributing)
* [License](#license)

_(TOC generated by [verb](https://github.com/verbose/verb) using [markdown-toc](https://github.com/jonschlinkert/markdown-toc))_

</details>
Note: This Docker image is definitely not designed to be used in a production environment as it could result into serious security issues. But it's nice to be added to your toolbox when playing with Docker/Docker Swarm/Kubernetes, etc.

## Usage

Expand All @@ -43,7 +21,7 @@ $ docker pull stefanwalther/docker-test
```

```sh
$ docker run -it stefanwalther/docker-test
$ docker run -it -p 3000:3000 stefanwalther/docker-test
```

### With docker-compose
Expand All @@ -54,9 +32,9 @@ services:
hello-world:
image: stefanwalther/docker-test
ports:
- 3004:3004
- 3000:3000
environment:
- PORT=3004
- PORT=3000
```
Expand All @@ -67,11 +45,29 @@ services:
## Endpoints
### `/`
Just returns a "Hello World"
Just returns a "Hello World":
```json
{
"text": "Hello World"
}
```
### `/health-check`
Returns a typical health-check, useful to test health-checks in a microservice environment.
```json
{
"ts": "2017-12-07T22:25:34.489Z",
"version": "0.3.1",
"name": "docker-test",
"repository": {
"type": "git",
"url": "git+https://github.com/stefanwalther/docker-test.git"
}
}
```
### `/cmd`
Execute any command on the machine and get the result.
Expand All @@ -81,12 +77,12 @@ Parameters:
Usage:
```sh
# Process ls -la
$ curl http://localhost:3004/cmd/?def=ls%20-la
$ curl http://localhost:3000/cmd/?def=ls%20-la
```
Examples:
- `ls -la` - list the directory
- `curl -o -I -L -s -w "%{http_code}\n" http://localhost:3004/health-check` - Get the Http status code of the health-check
- `curl -o -I -L -s -w "%{http_code}\n" http://localhost:3000/health-check` - Get the Http status code of the health-check
### `/cmd-cron`
Create a cron job, executing a command.
Expand All @@ -100,7 +96,7 @@ Usage:
```sh
# Process "echo foo" with the following cron def: "* * * * *" (every minute)
$ curl http://localhost:3004/cmd-cron?def=echo%20foo&cron=*%20*%20*%20*%20*
$ curl http://localhost:3000/cmd-cron?def=echo%20foo&cron=*%20*%20*%20*%20*
```
## Experiments
Expand All @@ -110,20 +106,9 @@ $ curl http://localhost:3004/cmd-cron?def=echo%20foo&cron=*%20*%20*%20*%20*
**References:**
- https://capgemini.github.io/development/multi-stage-builds-in-docker/
- https://codefresh.io/blog/node_docker_multistage/
- https://blog.alexellis.io/mutli-stage-docker-builds/
- Using multi-stage builds to reduce Go images: https://blog.alexellis.io/mutli-stage-docker-builds/
- https://github.com/yamalight/node-docker-pkg-demo
## Todo
- [ ] Use read-pkg-up - makes more sense
- [ ] Enable codecov
- [ ] Enable codeclimate
- [ ] Enable necessary badges
- [ ] Use multistage builds to truly separate images
- [ ] Use nodemon to watch changes locally
- [ ] Optimize precommit (husky) to not run it if there were no changes in either .verb.md or in ./docs
- [ ] Provide missing tests
## About
### Author
Expand Down
15 changes: 15 additions & 0 deletions configs/logstash/config/logstash.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
## Default Logstash configuration from logstash-docker.
## from https://github.com/elastic/logstash-docker/blob/master/build/logstash/config/logstash.yml
#
http.host: "0.0.0.0"

## Disable X-Pack
## see https://www.elastic.co/guide/en/x-pack/current/xpack-settings.html
## https://www.elastic.co/guide/en/x-pack/current/installing-xpack.html#xpack-enabling
#
xpack.monitoring.enabled: false

# config.debug: true
log.level: "info"
# path.config: "/usr/share/logstash/pipeline"
42 changes: 42 additions & 0 deletions configs/logstash/pipeline/logstash.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
input {
# gelf {
# port => 12201
# }
tcp {
port => 10514
codec => json
}
# tcp {
# port => 5000
# codec => json
# }
# udp {
# port => 5000
# codec => json
# }
}

filter {

json {
source => "message"
}

mutate {
add_field => {
"token" => "${LOGZ_ACCOUNT_TOKEN}"
}
}

}

output {
stdout {
codec => rubydebug
}
tcp {
host => "listener.logz.io"
port => 5050
codec => json_lines
}
}
5 changes: 4 additions & 1 deletion docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
version: '3.3'

services:
hello-world:
docker-test:
container_name: docker-test
build: .
command: ["npm", "run", "start:watch"]
volumes:
- ./src:/app/src


35 changes: 35 additions & 0 deletions docker-compose.logging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
version: '3.3'

services:
docker-test:
build: .
command: ["npm", "run", "start:watch"]
volumes:
- ./src:/app/src
environment:
- DOCKER_LABELS=true
labels:
- io.sammler.env=DEV
- io.sammler.service=docker-test

logstash:
image: docker.elastic.co/logstash/logstash:5.2.2
ports:
- "10514:10514"
- "5000:5000"
- "5000:5000/udp"
- "12201" # gelf
- "12201:12201/udp" # gelf udp port
# expose:
# - "12201"
environment:
- LOGSPOUT=ignore
- DROP_NON_JSON=false
- STDOUT=true
- LS_JAVA_OPTS=-Xmx256m -Xms256m
- LOGZ_ACCOUNT_TOKEN=${S5R_LOGZ_ACCOUNT_TOKEN}
volumes:
- ./.data/logstash/logs:/usr/share/logstash/logs
- ./configs/logstash/pipeline/logstash.conf:/usr/share/logstash/pipeline/logstash.conf
- ./configs/logstash/config/logstash.yml:/usr/share/logstash/config/logstash.yml

10 changes: 10 additions & 0 deletions docs/todos.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Todos

- [ ] Use read-pkg-up - makes more sense
- [ ] Enable codecov
- [ ] Enable codeclimate
- [ ] Enable necessary badges
- [ ] Use multistage builds to truly separate images
- [ ] Use nodemon to watch changes locally
- [ ] Optimize precommit (husky) to not run it if there were no changes in either .verb.md or in ./docs
- [ ] Provide missing tests
Loading

0 comments on commit 962cd7d

Please sign in to comment.