Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 22 additions & 9 deletions _common/docker.inc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,21 @@ function build_docker_container() {
local IMAGE_NAME=$1
local CONTAINER_NAME=$2
local BUILDER_CONFIGURATION="release"
if [[ $# -eq 3 ]]; then
local TARGET=.
if [[ $# -ge 3 ]]; then
BUILDER_CONFIGURATION=$3
fi
if [[ $# -ge 4 ]]; then
TARGET="-f $4 ."
fi

_verify_vendor_is_not_folder

builder_echo "Building using $BUILDER_CONFIGURATION configuration"


# Download docker image. --mount option requires BuildKit
DOCKER_BUILDKIT=1 docker build -t $IMAGE_NAME --build-arg BUILDER_CONFIGURATION="${BUILDER_CONFIGURATION}" .
DOCKER_BUILDKIT=1 docker build -t $IMAGE_NAME --build-arg BUILDER_CONFIGURATION="${BUILDER_CONFIGURATION}" $TARGET
}

function start_docker_container() {
Expand All @@ -77,10 +84,14 @@ function start_docker_container() {

_verify_vendor_is_not_folder

builder_echo "Starting using $BUILDER_CONFIGURATION configuration"

if [[ $BUILDER_CONFIGURATION =~ debug ]]; then
touch _control/debug
rm -f _control/release
else
rm -f _control/debug
touch _control/release
fi

local CONTAINER_ID=$(get_docker_container_id $CONTAINER_NAME)
Expand All @@ -96,11 +107,13 @@ function start_docker_container() {
builder_echo green "Docker container created successfully"
fi

if [[ $OSTYPE =~ msys|cygwin ]]; then
# Windows needs leading slashes for path
SITE_HTML="//$(pwd):/var/www/html/"
else
SITE_HTML="$(pwd):/var/www/html/"
if [ -z "${DOCKER_BINDING+x}" ]; then
if [[ $OSTYPE =~ msys|cygwin ]]; then
# Windows needs leading slashes for path
DOCKER_BINDING="//$(pwd):/var/www/html/"
else
DOCKER_BINDING="$(pwd):/var/www/html/"
fi
fi

ADD_HOST=
Expand All @@ -109,15 +122,15 @@ function start_docker_container() {
ADD_HOST="--add-host host.docker.internal:host-gateway"
fi

docker run --rm -d -p $PORT:80 -v "${SITE_HTML}" \
docker run --rm -d -p $PORT:80 -v "${DOCKER_BINDING}" \
-e S_KEYMAN_COM=localhost:$PORT_S_KEYMAN_COM \
-e API_KEYMAN_COM=localhost:$PORT_API_KEYMAN_COM \
--name $CONTAINER_DESC \
${ADD_HOST} \
$CONTAINER_NAME

# Skip if link already exists
if [ ! -L vendor ]; then
if [ ! -L vendor ] && [ -f composer.json ]; then
# Create link to vendor/ folder
CONTAINER_ID=$(get_docker_container_id $CONTAINER_NAME)
if [ -z "$CONTAINER_ID" ]; then
Expand Down
2 changes: 2 additions & 0 deletions _common/keyman-local-ports.inc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ if [[ -z ${PORT_KEYMAN_COM+x} ]]; then
readonly PORT_KEYMANWEB_COM=8057
readonly PORT_API_KEYMAN_COM=8058
readonly PORT_API_KEYMAN_COM_DB=8059
readonly PORT_STATUS_KEYMAN_COM=8060
readonly PORT_STATUS_KEYMAN_COM_PUBLIC=8061
fi