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

[#17] rebase faas-db and use Makefile.

parent 206cc15c
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}
help: # this help
@awk 'BEGIN {FS = ":.*?# "} /^[a-zA-Z_-]+:.*?# / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
...@@ -2,20 +2,28 @@ ...@@ -2,20 +2,28 @@
## structure ## structure
`_conf/`_ - directory with configuration files `_conf/`_ - directory with configuration files
`scripts/` - directory with utils and scripts
## 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
`
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment