Skip to content

Commit

Permalink
Release Candidate 1.1.1 (#65)
Browse files Browse the repository at this point in the history
## Release Candidate 1.1.1
[View release on Github.com](https://github.com/DCSO/MISP-dockerized/releases/tag/v1.1.1)
  • Loading branch information
8ear authored Apr 23, 2019
1 parent efed6eb commit 9f6ea3a
Show file tree
Hide file tree
Showing 21 changed files with 1,822 additions and 85 deletions.
7 changes: 4 additions & 3 deletions .ci/01_before_install.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
#!/bin/sh
set -e
STARTMSG="[before_install]"

# Install Requirements
echo
echo "$STARTMSG Install requirements..."
[ ! -z "$(which apk)" ] && apk add --no-cache make bash sudo git curl coreutils grep python3
[ ! -z "$(which apk)" ] && apk add --no-cache bash sudo git curl coreutils grep py-pip python-dev libffi-dev openssl-dev gcc libc-dev make
[ ! -z "$(which apt-get)" ] && apt-get update;
[ ! -z "$(which apt-get)" ] && apt-get install make bash sudo git curl coreutils grep python3
[ ! -z "$(which apt-get)" ] && apt-get install make bash sudo git curl coreutils grep python3 gcc
# Upgrade Docke
[ ! -z "$(which apt-get)" ] && apt-get install --only-upgrade docker-ce -y
# Install docker-compose
# https://stackoverflow.com/questions/42295457/using-docker-compose-in-a-gitlab-ci-pipeline
[ -z "$(which docker-compose)" ] && pip3 install --no-cache-dir docker-compose
[ -z "$(which docker-compose)" ] && pip install docker-compose
# Show version of docker-compose:
docker-compose -v

Expand Down
9 changes: 6 additions & 3 deletions .ci/02_script.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/sh
set -e

STARTMSG="[02_script]"

# change directory for make usage
Expand Down Expand Up @@ -31,9 +33,9 @@ echo "$DOCKER_LOGIN_OUTPUT"


# Build config and deploy environent
echo "$STARTMSG build configuration..." && $makefile_main build-config REPOURL=$REGISTRY_URL
echo "$STARTMSG pull images..." && docker-compose -f current/docker-compose.yml -f current/docker-compose.override.yml pull
echo "$STARTMSG start environment..." && docker-compose -f current/docker-compose.yml -f current/docker-compose.override.yml up -d
echo "$STARTMSG Build Configuration..." && $makefile_main build-config REPOURL="$REGISTRY_URL"
echo "$STARTMSG Pull Images..." && docker-compose -f current/docker-compose.yml -f current/docker-compose.override.yml pull
echo "$STARTMSG Start Environment..." && docker-compose -f current/docker-compose.yml -f current/docker-compose.override.yml up -d
###########################################################
# ATTENTION ATTENTION ATTENTION
# If you want to use docker-in-docker (dind) you cant start docker container on another filesystem!!!! You need to do it from the docker-compose directly!!!
Expand All @@ -55,6 +57,7 @@ then
echo "$STARTMSG show running docker container..." && docker ps
fi

$makefile_main configure
# show config folders
ls -laR config/

1 change: 1 addition & 0 deletions .ci/10_scanning.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/sh
set -e



Expand Down
81 changes: 81 additions & 0 deletions .ci/20_tag_2_registry.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/bin/sh
set -e

STARTMSG="[tag]"

# first_version=5.100.2
# second_version=5.1.2
# if version_gt $first_version $second_version; then
# echo "$first_version is greater than $second_version !"
# fi'
version_gt() { test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1"; }

func_tag() {
DOCKER_REPO="$1"
TAG="$2"

# add -dev
[ -z "$(echo "$TAG"| grep dev)" ] && TAG="$TAG-dev"
IMAGE_ID="$(docker images --format "{{.Repository}}:{{.Tag}}:{{.ID}}"|grep "$DOCKER_REPO:$TAG"|cut -d : -f 3|head -n 1;)"
IMAGE_TAGS="$(docker images --format "{{.Repository}}:{{.Tag}}:{{.ID}}"|grep "$IMAGE_ID"|cut -d : -f 2;)"
for i in $IMAGE_TAGS
do
k="$(echo "$i"|sed 's,-dev$,,')"
echo "$STARTMSG Retag: $DOCKER_REPO:$i with $DOCKER_REPO:$k"
docker tag "$DOCKER_REPO:$i" "$DOCKER_REPO:$k"
echo "$STARTMSG Remove: $DOCKER_REPO:$i"
docker image rm "$DOCKER_REPO:$i"
done
}


# change directory for make usage
[ -z "$1" ] && echo "$STARTMSG No parameter with the Docker registry URL. Exit now." && exit 1
[ "$1" = "NOT2PUSH" ] && echo "$STARTMSG The NOT2PUSH slug is only for local build and retag not for pushin to docker registries. Exit now." && exit 1
[ -z "$2" ] && echo "$STARTMSG No parameter with the Docker registry username. Exit now." && exit 1
[ -z "$3" ] && echo "$STARTMSG No parameter with the Docker registry password. Exit now." && exit 1

REGISTRY_URL="$1"
REGISTRY_USER="$2"
REGISTRY_PW="$3"


# Pull all latest tagged container
echo
echo "$STARTMSG Pull all latest-dev container..."
make pull-latest REPOURL="$REGISTRY_URL"


# prepare retagging
SERVER_TAG="$(docker ps -f name=server --format '{{.Image}}'|cut -d : -f 2)"
PROXY_TAG="$(docker ps -f name=proxy --format '{{.Image}}'|cut -d : -f 2)"
ROBOT_TAG="$(docker ps -f name=robot --format '{{.Image}}'|cut -d : -f 2)"
MODULES_TAG="$(docker ps -f name=modules --format '{{.Image}}'|cut -d : -f 2)"
DB_TAG=$(docker ps -f name=db --format '{{.Image}}'|cut -d : -f 2)
REDIS_TAG=$(docker ps -f name=redis --format '{{.Image}}'|cut -d : -f 2)


# Login to Docker registry
[ "$REGISTRY_URL" != "dcso" ] && DOCKER_LOGIN_OUTPUT="$(echo "$REGISTRY_PW" | docker login -u "$REGISTRY_USER" "$REGISTRY_URL" --password-stdin)"
[ "$REGISTRY_URL" = "dcso" ] && DOCKER_LOGIN_OUTPUT="$(echo "$REGISTRY_PW" | docker login -u "$REGISTRY_USER" --password-stdin)"
echo "$DOCKER_LOGIN_OUTPUT"
DOCKER_LOGIN_STATE="$(echo "$DOCKER_LOGIN_OUTPUT" | grep 'Login Succeeded')"

if [ ! -z "$DOCKER_LOGIN_STATE" ]; then
# retag all existing tags dev 2 public repo
#$makefile_travis tag REPOURL=$REGISTRY_URL server_tag=${server_tag} proxy_tag=${proxy_tag} robot_tag=${robot_tag} modules_tag=${modules_tag} db_tag=${modules_tag} redis_tag=${modules_tag} postfix_tag=${postfix_tag}
func_tag "$REGISTRY_URL/misp-dockerized-server" "$SERVER_TAG"
func_tag "$REGISTRY_URL/misp-dockerized-proxy" "$PROXY_TAG"
func_tag "$REGISTRY_URL/misp-dockerized-robot" "$ROBOT_TAG"
func_tag "$REGISTRY_URL/misp-dockerized-misp-modules" "$MODULES_TAG"
if $version_gt "$VERSION" 1.1.0 ; then
func_tag "$REGISTRY_URL/misp-dockerized-redis" "$REDIS_TAG"
fi
#func_tag "$REGISTRY_URL/misp-dockerized-db" "$DB_TAG"
echo "###########################################" && docker images && echo "###########################################"
else
echo "$DOCKER_LOGIN_OUTPUT"
exit
fi

echo "$STARTMSG $0 is finished."
89 changes: 36 additions & 53 deletions .ci/30_push_2_registry.sh
Original file line number Diff line number Diff line change
@@ -1,38 +1,26 @@
#!/bin/sh
set -e

STARTMSG="[push]"

func_push() {
DOCKER_REPO="$1"
TAG="$2"
TAG="$(echo "$TAG"|sed 's,-dev$,,')"
# first_version=5.100.2
# second_version=5.1.2
# if version_gt $first_version $second_version; then
# echo "$first_version is greater than $second_version !"
# fi'
version_gt() { test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1"; }

IMAGE_ID="$(docker images --format "{{.Repository}}:{{.Tag}}:{{.ID}}"|grep "$DOCKER_REPO:$TAG"|cut -d : -f 3|head -n 1;)"
IMAGE_TAGS="$(docker images --format "{{.Repository}}:{{.Tag}}:{{.ID}}"|grep "$IMAGE_ID"|cut -d : -f 2;)"
for i in $IMAGE_TAGS
do
docker push "$DOCKER_REPO:$i"
done
}

func_tag() {
func_push() {
DOCKER_REPO="$1"
TAG="$2"

# add -dev
[ -z "$(echo "$TAG"| grep dev)" ] && TAG="$TAG-dev"
IMAGE_ID="$(docker images --format "{{.Repository}}:{{.Tag}}:{{.ID}}"|grep "$DOCKER_REPO:$TAG"|cut -d : -f 3|head -n 1;)"
IMAGE_TAGS="$(docker images --format "{{.Repository}}:{{.Tag}}:{{.ID}}"|grep "$IMAGE_ID"|cut -d : -f 2;)"
for i in $IMAGE_TAGS
TAGS="$2"
for i in $TAGS
do
k="$(echo "$i"|sed 's,-dev$,,')"
echo "$STARTMSG Retag: $DOCKER_REPO:$i with $DOCKER_REPO:$k"
docker tag "$DOCKER_REPO:$i" "$DOCKER_REPO:$k"
echo "$STARTMSG Remove: $DOCKER_REPO:$i"
docker image rm "$DOCKER_REPO:$i"
[ ! -z "$(echo $i | grep 'dev')" ] && continue
docker push "$DOCKER_REPO:$i"
done
}


# change directory for make usage
[ -z "$1" ] && echo "$STARTMSG No parameter with the Docker registry URL. Exit now." && exit 1
[ "$1" = "NOT2PUSH" ] && echo "$STARTMSG The NOT2PUSH slug is only for local build and retag not for pushin to docker registries. Exit now." && exit 1
Expand All @@ -43,20 +31,13 @@ REGISTRY_URL="$1"
REGISTRY_USER="$2"
REGISTRY_PW="$3"

SERVER_TAGS="$(docker images --no-trunc --format '{{.Tag}}={{.ID}}' | grep $(docker inspect misp-server -f '{{.Image}}')|cut -d = -f 1)"
PROXY_TAGS="$(docker images --no-trunc --format '{{.Tag}}={{.ID}}' | grep $(docker inspect misp-proxy -f '{{.Image}}')|cut -d = -f 1)"
ROBOT_TAGS="$(docker images --no-trunc --format '{{.Tag}}={{.ID}}' | grep $(docker inspect misp-robot -f '{{.Image}}')|cut -d = -f 1)"
MODULES_TAGS="$(docker images --no-trunc --format '{{.Tag}}={{.ID}}' | grep $(docker inspect misp-modules -f '{{.Image}}')|cut -d = -f 1)"
#DB_TAGS=$(docker ps -f name=db --format '{{.Image}}'|cut -d : -f 2)
REDIS_TAGS="$(docker images --no-trunc --format '{{.Tag}}={{.ID}}' | grep $(docker inspect misp-redis -f '{{.Image}}')|cut -d = -f 1)"

# Pull all latest tagged container
echo
echo "$STARTMSG Pull all latest-dev container..."
make pull-latest REPOURL="$REGISTRY_URL"


# prepare retagging
SERVER_TAG="$(docker ps -f name=server --format '{{.Image}}'|cut -d : -f 2)"
PROXY_TAG="$(docker ps -f name=proxy --format '{{.Image}}'|cut -d : -f 2)"
ROBOT_TAG="$(docker ps -f name=robot --format '{{.Image}}'|cut -d : -f 2)"
MODULES_TAG="$(docker ps -f name=modules --format '{{.Image}}'|cut -d : -f 2)"
DB_TAG=$(docker ps -f name=db --format '{{.Image}}'|cut -d : -f 2)
REDIS_TAG=$(docker ps -f name=redis --format '{{.Image}}'|cut -d : -f 2)


# Login to Docker registry
Expand All @@ -66,23 +47,25 @@ echo "$DOCKER_LOGIN_OUTPUT"
DOCKER_LOGIN_STATE="$(echo "$DOCKER_LOGIN_OUTPUT" | grep 'Login Succeeded')"

if [ ! -z "$DOCKER_LOGIN_STATE" ]; then
# retag all existing tags dev 2 public repo
#$makefile_travis tag REPOURL=$REGISTRY_URL server_tag=${server_tag} proxy_tag=${proxy_tag} robot_tag=${robot_tag} modules_tag=${modules_tag} db_tag=${modules_tag} redis_tag=${modules_tag} postfix_tag=${postfix_tag}
func_tag "$REGISTRY_URL/misp-dockerized-server" "$SERVER_TAG"
func_tag "$REGISTRY_URL/misp-dockerized-server" "$SERVER_TAG"
func_tag "$REGISTRY_URL/misp-dockerized-robot" "$ROBOT_TAG"
func_tag "$REGISTRY_URL/misp-dockerized-misp-modules" "$MODULES_TAG"
#func_tag "$REGISTRY_URL/misp-dockerized-db" "$DB_TAG"
func_tag "$REGISTRY_URL/misp-dockerized-redis" "$REDIS_TAG"
echo "###########################################" && docker images && echo "###########################################"
# # retag all existing tags dev 2 public repo
# #$makefile_travis tag REPOURL=$REGISTRY_URL server_tag=${server_tag} proxy_tag=${proxy_tag} robot_tag=${robot_tag} modules_tag=${modules_tag} db_tag=${modules_tag} redis_tag=${modules_tag} postfix_tag=${postfix_tag}
# func_tag "$REGISTRY_URL/misp-dockerized-server" "$SERVER_TAG"
# func_tag "$REGISTRY_URL/misp-dockerized-server" "$SERVER_TAG"
# func_tag "$REGISTRY_URL/misp-dockerized-robot" "$ROBOT_TAG"
# func_tag "$REGISTRY_URL/misp-dockerized-misp-modules" "$MODULES_TAG"
# #func_tag "$REGISTRY_URL/misp-dockerized-db" "$DB_TAG"
# func_tag "$REGISTRY_URL/misp-dockerized-redis" "$REDIS_TAG"
# echo "###########################################" && docker images && echo "###########################################"
# Push all Docker images
#$makefile_travis push REPOURL=$REGISTRY_URL server_tag=${server_tag} proxy_tag=${proxy_tag} robot_tag=${robot_tag} modules_tag=${modules_tag} postfix_tag=${postfix_tag}
func_push "$REGISTRY_URL/misp-dockerized-server" "$SERVER_TAG"
func_push "$REGISTRY_URL/misp-dockerized-proxy" "$PROXY_TAG"
func_push "$REGISTRY_URL/misp-dockerized-robot" "$ROBOT_TAG"
func_push "$REGISTRY_URL/misp-dockerized-misp-modules" "$MODULES_TAG"
#func_push "$REGISTRY_URL/misp-dockerized-db" "$DB_TAG"
func_push "$REGISTRY_URL/misp-dockerized-redis" "$REDIS_TAG"
func_push "$REGISTRY_URL/misp-dockerized-server" "$SERVER_TAGS"
func_push "$REGISTRY_URL/misp-dockerized-proxy" "$PROXY_TAGS"
func_push "$REGISTRY_URL/misp-dockerized-robot" "$ROBOT_TAGS"
func_push "$REGISTRY_URL/misp-dockerized-misp-modules" "$MODULES_TAGS"
if $version_gt "$VERSION" 1.1.0 ; then
func_push "$REGISTRY_URL/misp-dockerized-redis" "$REDIS_TAGS"
fi
#func_push "$REGISTRY_URL/misp-dockerized-db" "$DB_TAGS"
else
echo "$DOCKER_LOGIN_OUTPUT"
exit
Expand Down
3 changes: 3 additions & 0 deletions .ci/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ test:
@if [ ! -d reports ]; then mkdir reports; fi
@docker cp misp-robot:/srv/MISP-dockerized-testbench/reports/. reports/

tag:
@bash 20_tag_2_registry.sh $(REPOURL) $(USER) $(PW)

push:
@bash 30_push_2_registry.sh $(REPOURL) $(USER) $(PW)

Expand Down
Loading

0 comments on commit 9f6ea3a

Please sign in to comment.