Skip to content

Commit

Permalink
Optimized docker built primary.dind images Docker-Compose install wit…
Browse files Browse the repository at this point in the history
…h pynacl : pyca/pynacl#303
  • Loading branch information
b23prodtm committed Sep 11, 2019
1 parent ff7ba82 commit 211866c
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 38 deletions.
8 changes: 4 additions & 4 deletions .circleci/config-compat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: 2
jobs:
build:
docker:
- image: betothreeprod/dind-php7:0.1.6
- image: betothreeprod/dind-php7:0.1.8
- image: betothreeprod/mariadb:amd64-latest
environment:
PUID: 1000
Expand Down Expand Up @@ -71,7 +71,7 @@ jobs:
- ./app/Vendor/
compose:
docker:
- image: betothreeprod/dind-php7:0.1.6
- image: betothreeprod/dind-php7:0.1.8
shell: /bin/sh -leo pipefail
environment:
- BASH_ENV: /etc/profile
Expand Down Expand Up @@ -125,7 +125,7 @@ workflows:
# build:
# docker:
# # using custom image, see .circleci/images/primary/Dockerfile
# - image: betothreeprod/dind-php7:0.1.6
# - image: betothreeprod/dind-php7:0.1.8
# - image: betothreeprod/mariadb:amd64-latest
# environment:
# PUID: 1000
Expand Down Expand Up @@ -209,7 +209,7 @@ workflows:
# compose:
# docker:
# # use a primary image that already has Docker (recommended)
# - image: betothreeprod/dind-php7:0.1.6
# - image: betothreeprod/dind-php7:0.1.8
# #An image that\u2019s based on Alpine Linux (like docker), uses the ash shell.
# shell: /bin/sh -leo pipefail
# environment:
Expand Down
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
build:
docker:
# using custom image, see .circleci/images/primary/Dockerfile
- image: betothreeprod/dind-php7:0.1.6
- image: betothreeprod/dind-php7:0.1.9
- image: betothreeprod/mariadb:amd64-latest
environment:
PUID: 1000
Expand Down Expand Up @@ -91,7 +91,7 @@ jobs:
compose:
docker:
# use a primary image that already has Docker (recommended)
- image: betothreeprod/dind-php7:0.1.6
- image: betothreeprod/dind-php7:0.1.9
#An image that’s based on Alpine Linux (like docker), uses the ash shell.
shell: /bin/sh -leo pipefail
environment:
Expand Down
5 changes: 4 additions & 1 deletion .circleci/images/primary.dind/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ RUN apk update \
php7-mysqlnd \
php7-phar \
php7-mysqli \
php7-pdo_mysql \
php7-dom \
php7-tokenizer \
php7-simplexml \
php7-fpm \
php7-zlib \
py-pip \
Expand All @@ -45,6 +48,6 @@ RUN apk update \
# Make sure the nginx and php-fpm7 (FASTCGI server) starts when system reboots
# RUN rc-update add php-fpm7 default
# RUN rc-service php-fpm7 start
RUN pip install docker-compose
RUN LIBSODIUM_MAKE_ARGS=-j4 pip install docker-compose
RUN docker-compose --version
WORKDIR /var/www/html/
2 changes: 1 addition & 1 deletion Scripts/lib/locate.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
_locate() {
[ $# -lt 1 ] && echo "Usage: $0 <filename>" && exit 0
[ $# -lt 1 ] && echo "Usage: $0 <filename>" && exit 1
find /usr -name $1 | grep -m 1 $1
}
# export -f _locate
4 changes: 2 additions & 2 deletions Scripts/lib/shell_prompt.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
set -e
shell_prompt() {
[ $# -lt 2 ] && echo "Usage: $0 <file> <name> [-y|n]" && exit 0
[ $# -lt 2 ] && echo "Usage: $0 <file> <name> [-y|n]" && exit 1
script=$1
title=$2
while true; do
Expand Down Expand Up @@ -31,7 +31,7 @@ shell_prompt() {
}
#; export -f shell_prompt
show_password_status() {
[ "$#" -lt 3 ] && echo "Usage: $0 '<VAR_USER>' '<VAR_PASSWORD>' <action-description>"
[ "$#" -lt 3 ] && echo "Usage: $0 '<VAR_USER>' '<VAR_PASSWORD>' <action-description>" && exit 1
logger -st $0 "User ${green}${1}${nc} (using password:${orange} $([ -z $2 ] && echo "NO" || echo "YES")${nc}) $3...\n"
}
#; export -f show_password_status
43 changes: 15 additions & 28 deletions migrate-database.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,9 @@ else
logger -st $0 "Locally Testing values, bootargs...: ${pargs}"
source ./Scripts/fooargs.sh $*
fi
sql_connect() {
prefix=""
[ "$#" -gt 0 ] && prefix=$1 && shift
${prefix} "mysql $*"
}
sql_connect_host() {
sql_connect $* -h ${MYSQL_SERVICE_HOST} -P ${MYSQL_SERVICE_PORT}
}
sql_connect_test_host() {
sql_connect $* -h ${TEST_MYSQL_SERVICE_HOST} -P ${TEST_MYSQL_SERVICE_PORT}
}

sql_connect="mysql"
sql_connect_host="-h ${MYSQL_SERVICE_HOST} -P ${MYSQL_SERVICE_PORT}"
sql_connect_test_host="-h ${TEST_MYSQL_SERVICE_HOST} -P ${TEST_MYSQL_SERVICE_PORT}"
dbfile=database.cms.php
fix_socket="-N"
config_app_checked=""
Expand All @@ -33,17 +24,16 @@ identities=app/Config/database.sql
new_pass=""
new_test_pass=""
saved=("$*")
mysql_connect_args=("eval" "")
test_mysql_connect_args=("eval" "")
mysql_connect_args=""
test_mysql_connect_args=""
mysql_host=${MYSQL_SERVICE_HOST}
test_mysql_host=${TEST_MYSQL_SERVICE_HOST}
while [[ "$#" > 0 ]]; do case $1 in
--connect-expired-password )
mysql_connect_args=(${mysql_connect_args[@]} "--connect-expired-password")
test_mysql_connect_args=(${mysql_connect_args[@]} "--connect-expired-password");;
mysql_connect_args="${mysql_connect_args} --connect-expired-password"
test_mysql_connect_args="${mysql_connect_args} --connect-expired-password";;
--docker )
mysql_connect_args=("docker exec maria" ${mysql_connect_args[@]})
test_mysql_connect_args=("docker exec maria" ${test_mysql_connect_args[@]})
sql_connect="docker exec maria mysql"
mysql_host="%"
test_mysql_host="%"
test_checked=1
Expand Down Expand Up @@ -102,7 +92,7 @@ and environment VARIABLES:"
parse_arg_export "$1" "-dbase*|-DBASE*" "MYSQL_DATABASE" "${DATABASE_USER} database";;
-tbase*|-TBASE*)
parse_arg_export "$1" "-tbase*|-TBASE*" "TEST_DATABASE_NAME" "${MYSQL_USER} database";;
*) echo "Unknown parameter passed: $0 $1"; exit 1;;
*) echo "Unknown parameter passed: $0 $1" && exit 1;;
esac
shift; done
#; import identities
Expand All @@ -123,23 +113,20 @@ create database if not exists '${MYSQL_DATABASE}';\r
grant all on ${MYSQL_DATABASE}.* to '${DATABASE_USER}'@'${mysql_host}';\r
" > $identities
logger -st $0 "Fork script to keep hidden table user secrets"
$(echo "source ${identities}" | sql_connect_host "${mysql_connect_args[@]}" -u ${MYSQL_USER} --password=${MYSQL_PASSWORD})
export MYSQL_ROOT_PASSWORD=$set_DATABASE_PASSWORD
bash -c "echo \"source ${identities}\" | ${sql_connect} ${sql_connect_host} ${mysql_connect_args} -u ${DATABASE_USER} --password=${MYSQL_ROOT_PASSWORD} && echo 'Imported default identities with Success!' && export MYSQL_ROOT_PASSWORD=${set_DATABASE_PASSWORD}"
logger -st $0 "\r${red}WARNING: You will modify SQL ${MYSQL_USER} password !${nc}"
parse_sql_password "$new_test_pass" "set_TEST_DATABASE_PASSWORD" "new ${MYSQL_USER}"
parse_sql_password "$new_test_pass" "set_MYSQL_PASSWORD" "new ${MYSQL_USER}"
#; $identities file contents
echo "use mysql;\r
create user if not exists '${MYSQL_USER}'@'${test_mysql_host}';\r
alter user '${MYSQL_USER}'@'localhost' identified by '${set_TEST_DATABASE_PASSWORD}';\r
alter user '${MYSQL_USER}'@'${test_mysql_host}' identified by '${set_TEST_DATABASE_PASSWORD}';\r
alter user '${MYSQL_USER}'@'localhost' identified by '${set_MYSQL_PASSWORD}';\r
alter user '${MYSQL_USER}'@'${test_mysql_host}' identified by '${set_MYSQL_PASSWORD}';\r
select * from user where user = '${MYSQL_USER}';\r
grant all on ${TEST_DATABASE_NAME}.* to '${MYSQL_USER}'@'${test_mysql_host}';\r
grant all on ${TEST_DATABASE_NAME}2.* to '${MYSQL_USER}'@'${test_mysql_host}';\r
grant all on ${TEST_DATABASE_NAME}3.* to '${MYSQL_USER}'@'${test_mysql_host}';\r
" > $identities
logger -st $0 "Fork script to keep hidden table user secrets"
$(echo "source ${identities}" | sql_connect_host "${mysql_connect_args[@]}" -u ${MYSQL_USER} --password=${MYSQL_PASSWORD})
export MYSQL_PASSWORD=$set_TEST_DATABASE_PASSWORD
bash -c "echo \"source ${identities}\" | ${sql_connect} ${sql_connect_host} ${mysql_connect_args} -u ${DATABASE_USER} --password=${MYSQL_ROOT_PASSWORD} && echo 'Imported test identities with Success!' && export MYSQL_PASSWORD=${set_MYSQL_PASSWORD}"
rm $identities
fi
if [[ $test_checked -eq 1 ]]; then
Expand All @@ -166,7 +153,7 @@ if [[ $test_checked -eq 1 ]]; then
[ ! -z $MYSQL_USER ] && [ ! -z $MYSQL_PASSWORD ] && [[ (! -z $TEST_MYSQL_SERVICE_HOST) ]] || echo "Missing VARIABLES. Please review your settings !"
logger -st $0 "Database Unit Tests... DB=${DB}"
if [[ ${DB} == 'Mysql' ]]; then
sql_connect_test_host "${test_mysql_connect_args[@]}" -u ${MYSQL_USER} --password=${MYSQL_PASSWORD} -v \
$sql_connect ${sql_connect_test_host} ${test_mysql_connect_args} -u ${DATABASE_USER} --password=${MYSQL_ROOT_PASSWORD} -v \
-e "CREATE DATABASE IF NOT EXISTS ${TEST_DATABASE_NAME};" \
-e "CREATE DATABASE IF NOT EXISTS ${TEST_DATABASE_NAME}2;" \
-e "CREATE DATABASE IF NOT EXISTS ${TEST_DATABASE_NAME}3;"
Expand Down

0 comments on commit 211866c

Please sign in to comment.