Skip to content

Commit

Permalink
Cleanup REAME.md
Browse files Browse the repository at this point in the history
  • Loading branch information
madharjan committed May 21, 2019
1 parent ad0fb6d commit b6cedf7
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 50 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ jobs:
include:
- stage: release
script:
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
- echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USERNAME}" --password-stdin
- make build DEBUG=false
- make release DEBUG=false
- make tag_latest DEBUG=false
- make release DEBUG=false
- curl -s -X POST "https://hooks.microbadger.com/images/${TRAVIS_REPO_SLUG}/x2dDUennV51OiIhNh02THCSOLW4="
8 changes: 4 additions & 4 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# 16.04
## 16.04

## Changes
### Changes

* Updated to Ubuntu 16.04

# 14.04
## 14.04

## Changes
### Changes

* Using Ubuntu 14.04
* Version follows Ubuntu Version
Expand Down
38 changes: 27 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,21 @@ VERSION = 16.04

DEBUG ?= true

.PHONY: all build run tests clean tag_latest release clean_images
DOCKER_USERNAME ?= $(shell read -p "DockerHub Username: " pwd; echo $$pwd)
DOCKER_PASSWORD ?= $(shell stty -echo; read -p "DockerHub Password: " pwd; stty echo; echo $$pwd)
DOCKER_LOGIN ?= $(shell cat ~/.docker/config.json | grep "docker.io" | wc -l)

.PHONY: all build run test stop clean tag_latest release clean_images

all: build

docker_login:
ifeq ($(DOCKER_LOGIN), 1)
@echo "Already login to DockerHub"
else
@docker login -u $(DOCKER_USERNAME) -p $(DOCKER_PASSWORD)
endif

build:
docker build \
--build-arg UBUNTU_VERSION=${VERSION} \
Expand All @@ -16,6 +27,8 @@ build:
-t $(NAME):$(VERSION) --rm .

run:
@if ! docker images $(NAME) | awk '{ print $$2 }' | grep -q -F $(VERSION); then echo "$(NAME) version $(VERSION) is not yet built. Please run 'make build'"; false; fi

docker run -d \
-e DEBUG=$(DEBUG) \
--name base $(NAME):$(VERSION) \
Expand All @@ -37,25 +50,28 @@ run:

sleep 1

tests:
test:
sleep 2
./bats/bin/bats test/tests.bats

stop:
docker stop base base_no_syslog base_no_cron || true
docker stop base base_no_syslog base_no_cron 2> /dev/null || true

clean: stop
docker rm base base_no_syslog base_no_cron || true
docker images | grep "^<none>" | awk '{print$3 }' | xargs docker rmi || true
docker rm base base_no_syslog base_no_cron 2> /dev/null || true
docker images | grep "<none>" | awk '{print$3 }' | xargs docker rmi 2> /dev/null || true

publish: docker_login run test clean
docker push $(NAME)

tag_latest:
docker tag $(NAME):$(VERSION) $(NAME):latest

release: run tests clean tag_latest
@if ! docker images $(NAME) | awk '{ print $$2 }' | grep -q -F $(VERSION); then echo "$(NAME) version $(VERSION) is not yet built. Please run 'make build'"; false; fi
release: docker_login run test clean tag_latest
docker push $(NAME)
@echo "*** Don't forget to create a tag. git tag $(VERSION) && git push origin $(VERSION) ***"
curl -s -X POST https://hooks.microbadger.com/images/madharjan/docker-base/x2dDUennV51OiIhNh02THCSOLW4=

clean_images:
docker rmi $(NAME):latest $(NAME):$(VERSION) || true
clean_images: clean
docker rmi $(NAME):latest $(NAME):$(VERSION) 2> /dev/null || true
docker logout


54 changes: 21 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,61 +13,49 @@ Docker baseimage based on [phusion/baseimage-docker](https://github.com/phusion/
## Features

* Environment variables to disable services
* Using scripts in `my_init.d` to initialize services (e.g base-startup.sh, nginx-startup.sh .. etc)
* Using scripts in `my_shutdown.d` to cleanup services before container stop (e.g postfix-stop.sh ..etc)
* Using scripts in `my_init.d` to initialize services (e.g 10-startup.sh, 20-nginx.sh .. etc)
* Using scripts in `my_shutdown.d` to cleanup services before container stop (e.g 80-postfix.sh ..etc)
* Bats ([bats-core/bats-core](https://github.com/bats-core/bats-core)) based test cases

Example:

```bash
docker run -d \
-e DISABLE_SYSLOG=1 \
-e DISABLE_CRON=0 \
--name <container-name> <image-name>:<image-version>
```

## Ubuntu 16.04 (docker-base)

### Environment

| Variable | Default | Set to disable |
| Variable | Default | Example |
|----------------|---------|----------------|
| DISABLE_SYSLOG | 0 | 1 |
| DISABLE_CRON | 0 | 1 |
| DISABLE_SYSLOG | 0 | 1 (to disable) |
| DISABLE_CRON | 0 | 1 (to disable) |

## Build

### Clone this project

```bash
# clone project
git clone https://github.com/madharjan/docker-base
cd docker-base
```

### Build Container `baseimage`

```bash
# login to DockerHub
docker login

# build
make

# tests
make run
make tests
make clean

# tag
make tag_latest
make test

# release
make release
# clean
make clean
```

### Tag and Commit to Git
## Run

```bash
git tag 16.04
git push origin 16.04
# stop & remove previous instances
docker stop base
docker rm base

# run container
docker run -d \
-e DEBUG=false \
-e DISABLE_SYSLOG=0 \
-e DISABLE_CRON=0 \
--name base madharjan/docker-base:16.04 \
/sbin/my_init --log-level 3
```

0 comments on commit b6cedf7

Please sign in to comment.