diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d8fe4fa70f618843e9ab2df67167b49565c71f25 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/.project diff --git a/Dockerfile b/Dockerfile index 4de8215caa0e70a36063e9db402a832617fb0470..cf62a183763fa2d5ec8a5cb4cdf9d8f9357b402d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1 +1,11 @@ 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 diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..e7a0ddce9ac694f39aa34c0e602717bd1d02b9bd --- /dev/null +++ b/Makefile @@ -0,0 +1,36 @@ +# 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} + +help: # this help + @awk 'BEGIN {FS = ":.*?# "} /^[a-zA-Z_-]+:.*?# / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) diff --git a/README.md b/README.md index db916d12f7b8498ecca0957868cd60a9d705e959..9c6fca519d90179e2ad8401af7dbf281f2a63be3 100644 --- a/README.md +++ b/README.md @@ -2,20 +2,28 @@ ## structure `_conf/`_ - directory with configuration files -`scripts/` - directory with utils and scripts ## build image -To build `faas-db` docker image +To build `faas-db` docker image ` -cd scripts && ./build.sh +make build ` - ## run 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 +` diff --git a/conf/faas-db.cnf b/conf/faas-db.cnf index ab58617555eb4e04f94163056527aae5c6f7708e..e60dca321a091b5b9d3f26196ba87dd7701ace32 100644 --- a/conf/faas-db.cnf +++ b/conf/faas-db.cnf @@ -1,6 +1,11 @@ -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_PORT=8306 # TODO - remove to external resource -FAAS_DB_ROOT_PASSWORD=secure +MYSQL_ROOT_PASSWORD=secure diff --git a/conf/faas-db.compose.yml b/conf/faas-db.compose.yml deleted file mode 100644 index a1823743eacdb4a879063087b95020900962450a..0000000000000000000000000000000000000000 --- a/conf/faas-db.compose.yml +++ /dev/null @@ -1,15 +0,0 @@ -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" diff --git a/scripts/build.sh b/scripts/build.sh deleted file mode 100755 index b1c82a0584e7dfe466d51944ffe0c88be800b085..0000000000000000000000000000000000000000 --- a/scripts/build.sh +++ /dev/null @@ -1,3 +0,0 @@ -#! /bin/bash - -docker-compose --env-file ../conf/faas-db.cnf -f ../conf/faas-db.compose.yml build diff --git a/scripts/run.sh b/scripts/run.sh deleted file mode 100755 index 38268c8b8324327032cd6f2cebcee2411594fdd5..0000000000000000000000000000000000000000 --- a/scripts/run.sh +++ /dev/null @@ -1,3 +0,0 @@ -#! /bin/bash - -docker-compose --env-file ../conf/faas-db.cnf -f ../conf/faas-db.compose.yml up