Skip to content
Snippets Groups Projects
Commit 9d9db93b authored by Dariusz Janny's avatar Dariusz Janny
Browse files

Merge branch 'master' into 'master'

Master

See merge request !3
parents 8330a069 79596304
No related branches found
No related tags found
1 merge request!3Master
/.project
FROM mariadb:10.5.8 FROM mariadb:10.5.8
ARG FAAS_DB_IMAGE
ARG FAAS_DB_NAME
ARG FAAS_DB_VERSION
RUN echo $FAAS_DB_IMAGE > /faas-docker-image
RUN echo $FAAS_DB_NAME > /faas-docker-name
RUN echo $FAAS_DB_VERSION > /faas-docker-version
EXPOSE 3306
Makefile 0 → 100644
# import config file
config ?= conf/faas-db.cnf
include $(config)
export $(shell sed 's/=.*//' $(config))
.DEFAULT_GOAL := help
clean: # clean DB docker volume
sudo rm -fr ${FAAS_DB_VOLUME_VAR_LIB_MYSQL}
build: # build container
docker build -t ${FAAS_DB_IMAGE} --build-arg FAAS_DB_NAME=${FAAS_DB_NAME} --build-arg FAAS_DB_IMAGE=${FAAS_DB_IMAGE} --build-arg FAAS_DB_VERSION=${FAAS_DB_VERSION} .
build-nc: # build container without caching
docker build --no-cache -t ${FAAS_DB_IMAGE} --build-arg FAAS_DB_NAME=${FAAS_DB_NAME} --build-arg FAAS_DB_IMAGE=${FAAS_DB_IMAGE} --build-arg FAAS_DB_VERSION=${FAAS_DB_VERSION} .
run: # run container
docker run -i -t --detach --rm --env-file=$(config) -p=${FAAS_DB_PORT}:3306 --name="${FAAS_DB_NAME}" -v ${FAAS_DB_VOLUME_VAR_LIB_MYSQL}:/var/lib/mysql ${FAAS_DB_IMAGE}
run-nd: # run container in no-deamon mode
docker run -i -t --rm --env-file=$(config) -p=${FAAS_DB_PORT}:3306 --name="${FAAS_DB_NAME}" -v ${FAAS_DB_VOLUME_VAR_LIB_MYSQL}:/var/lib/mysql ${FAAS_DB_IMAGE}
up: build run # build and run container
logs: # print docker logs
docker logs ${FAAS_DB_NAME}
stop: # stop container
docker stop ${FAAS_DB_NAME}
version: # print current component version
@echo ${FAAS_DB_VERSION}
test: testFaasDB # run all tests
testFaasDB: # run checking docker image tests
@echo "# run test version"
bats test/faas-db-tests.bats
help: # this help
@awk 'BEGIN {FS = ":.*?# "} /^[a-zA-Z_-]+:.*?# / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
...@@ -2,20 +2,32 @@ ...@@ -2,20 +2,32 @@
## structure ## structure
`_conf/`_ - directory with configuration files `_conf/`_ - directory with configuration files
`scripts/` - directory with utils and scripts
`test/` - directory with tests files
## build image ## build image
To build `faas-db` docker image To build `faas-db` docker image
` `
cd scripts && ./build.sh make build
` `
## run image ## run image
To run `faas-db` docker image To run `faas-db` docker image
` `
cd scripts && ./run.sh make run
` `
## additional commands
```
clean clean DB docker volume
build build container
build-nc build container without caching
run run container
run-nd run container in no-deamon mode
up build and run container
logs print docker logs
stop stop container
version print current component version
test run all tests
testFaasDB run checking docker image tests
```
FAAS_DB_IMAGE=faas/faas-db:1.0-SNAPSHOT FAAS_DB_REPO=faas
FAAS_DB_VERSION=1.0-SNAPSHOT
FAAS_DB_NAME=faas-db
FAAS_DB_IMAGE=${FAAS_DB_REPO}/${FAAS_DB_NAME}:${FAAS_DB_VERSION}
FAAS_DB_VOLUME_VAR_LIB_MYSQL=/tmp/faas-db FAAS_DB_VOLUME_VAR_LIB_MYSQL=/tmp/faas-db
FAAS_DB_PORT=8306 FAAS_DB_PORT=8306
# TODO - remove to external resource # TODO - remove to external resource
FAAS_DB_ROOT_PASSWORD=secure MYSQL_ROOT_PASSWORD=secure
version: '3.1'
services:
db:
image: ${FAAS_DB_IMAGE}
build:
context: ../
dockerfile: Dockerfile
restart: always
environment:
MYSQL_ROOT_PASSWORD: ${FAAS_DB_ROOT_PASSWORD}
volumes:
- ${FAAS_DB_VOLUME_VAR_LIB_MYSQL}:/var/lib/mysql
ports:
- "${FAAS_DB_PORT}:3306"
#! /bin/bash
docker-compose --env-file ../conf/faas-db.cnf -f ../conf/faas-db.compose.yml build
#! /bin/bash
docker-compose --env-file ../conf/faas-db.cnf -f ../conf/faas-db.compose.yml up
#! /usr/bin/env bats
@test "faas-db - checking version in variables" {
[ $FAAS_DB_VERSION = "1.0-SNAPSHOT" ]
}
@test "faas-db - checking app name in variables" {
[ $FAAS_DB_NAME = "faas-db" ]
}
@test "faas-db - checking image string in variables" {
[ $FAAS_DB_IMAGE = "faas/faas-db:1.0-SNAPSHOT" ]
}
@test "faas-db - checking version in image file" {
run docker exec $FAAS_DB_NAME bash -c 'cat /faas-docker-version'
[ "$output" = "1.0-SNAPSHOT" ]
}
@test "faas-db - checking app name in image file" {
run docker exec $FAAS_DB_NAME bash -c 'cat /faas-docker-name'
[ "$output" = "faas-db" ]
}
@test "faas-db - checking image string in image file" {
run docker exec $FAAS_DB_NAME bash -c 'cat /faas-docker-image'
[ "$output" = "faas/faas-db:1.0-SNAPSHOT" ]
}
@test "faas-db - checking DB version in client command" {
run docker exec $FAAS_DB_NAME bash -c 'mysql --version'
[ "$output" = "mysql Ver 15.1 Distrib 10.5.8-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2" ]
}
@test "faas-db - checking DB version in running DB instance" {
run docker exec $FAAS_DB_NAME bash -c "mysql --disable-column-names -uroot -p${MYSQL_ROOT_PASSWORD} mysql -e 'select version();'"
[ "$output" = "10.5.8-MariaDB-1:10.5.8+maria~focal" ]
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment