Compare commits

..

78 Commits

Author SHA1 Message Date
Arnie 3f700b538c Update run scripts for db import 2021-06-08 09:40:50 +02:00
Arnie 0fa50fa2d9 Update run script for maria db import 2021-06-08 09:38:27 +02:00
Arnie 12777d228c Update adminer 2021-03-06 09:19:11 +01:00
Arnie a8ac87cc2c Add fathom 2021-03-06 09:13:15 +01:00
Arnie 0931c0f1bb Add idea files to gitignore 2021-03-06 09:12:45 +01:00
Arnie d62c3bb404 Add realpath function for mac compat 2021-03-06 09:10:49 +01:00
Arnie 2e91e01590 Update code formatter 2021-03-06 09:10:18 +01:00
Arnie b99086b922 Update run script to include import command 2021-02-19 10:13:52 +01:00
Arnie 248aca2640 Fix dev proxy fallback 2021-01-28 08:18:40 +01:00
Arnie eb9046a016 Update dev proxy configuration 2021-01-26 07:48:22 +01:00
Arnie a923fb6351 Update dev proxy with explicit caddy reload after config change 2020-11-22 19:09:24 +01:00
Arnie 366cd94119 Add dockerignore to dev proxy 2020-11-22 15:07:28 +01:00
Arnie f21e70669c Do not cache not found site fallback 2020-11-22 14:02:05 +01:00
Arnie 8325f74371 Add 404 to dev proxy 2020-10-09 17:03:19 +02:00
Arnie 4d9365e411 Fix dev proxy fallbacks 2020-10-06 12:12:00 +02:00
Arnie 65fc1b91a4 Update adminer 2020-10-06 11:30:23 +02:00
Arnie 2e89c4bb39 Update dev proxy 2020-10-06 11:30:15 +02:00
Arnie bb10ae775e Add import script for mysql 2020-07-20 10:51:43 +02:00
Arnie 70cf118ddb Make sure mariadb is exposed locally only 2020-05-13 12:40:25 +02:00
Arnie 8c494acebe Expose maria db random port 2020-05-13 12:33:42 +02:00
Arnie 84a14307cb Update adminer 2019-11-20 13:50:33 +01:00
Arnie 98221c2f7a Allow omiting colors 2019-09-17 09:48:37 +02:00
Arnie 9a75a91df2 Fix code formatter 2019-09-09 15:52:51 +02:00
Arnie dc36be2efb Fix inspecting docker objects when starting container 2019-07-28 07:33:36 +02:00
Arnie 4da98f6580 Update pgadmin, add postgres migrations 2019-07-28 07:33:19 +02:00
Arnie 3ef3473236 Update development scripts 2019-05-30 08:52:33 +02:00
Arnie 1a2b31f16a Rename run scripts 2019-05-30 08:45:46 +02:00
Arnie 94b1de4aaa Update adminer 2019-05-30 08:43:18 +02:00
Arnie 6771e2af62 Update elasticsearch configuration 2019-05-30 08:42:58 +02:00
Arnie 71c9b169df Update elastic search 2019-03-25 07:10:28 +01:00
Arnie a499fed7ba Add node interpretter 2019-03-25 07:09:17 +01:00
Arnie 450cae64b9 Add update pgadmin, add default password 2019-03-25 07:02:29 +01:00
Arnie 453913e1ab Fix backup in maria db, update maria db 2019-03-25 07:02:11 +01:00
Arnie 56daea7eb6 Add new versions of elastic search 2019-03-25 07:01:42 +01:00
Arnie 3b44dff061 Bring back version 5.6 to code formatter, fucking A 2019-02-14 15:01:54 +01:00
Arnie e0f32d44b1 Update code formatter 2019-02-14 15:00:04 +01:00
Arnie e5c20726a8 Update code formatter 2019-01-30 07:21:12 +01:00
Arnie 00c1886dc1 Fix webpack hmr gzip 2019-01-09 13:29:24 +01:00
Arnie d8dc527f88 Code Formatter: Support tsx 2018-12-19 07:25:50 +01:00
Arnie 7758455fc7 Code Formatter: Push all versions to repo 2018-12-19 06:54:49 +01:00
Arnie 032ed99739 Code Formatter: Support vue files 2018-12-19 06:53:41 +01:00
Arnie df1b8fef4e Code Formatter:
- Updated node
- added json support
2018-12-19 06:51:13 +01:00
Arnie cc0b2cd584 Code formatter: up the version 2018-12-19 06:41:27 +01:00
Arnie 3e5427a95b - Support php 7 and 5.6
- Support TypeScript
2018-12-19 06:41:08 +01:00
Arnie eb03df7e66 Update adminer 2018-12-11 09:11:28 +01:00
Arnie 52e3e92452 Update caddy proxy 2018-12-10 13:35:37 +01:00
Arnie 75be9aef27 Make php 7.0 cs fixer 2018-11-19 19:31:44 +01:00
Arnie 9fc9241c47 Update windows startup scripts 2018-08-27 08:06:53 +02:00
Arnie 1b5319b3fa Fix adminer upload sizes 2018-08-24 16:53:00 +02:00
Arnie b72c9de259 Update adminer run configuration to include default server 2018-08-24 14:31:17 +02:00
Arnie 1a9bdcf666 Return values 2018-08-22 08:51:46 +02:00
Arnie 57f420e0e0 Add automount path fix 2018-08-22 08:50:21 +02:00
Arnie 11eec3138e Fix reading the continue value 2018-08-22 08:47:32 +02:00
Arnie 2c14504134 Add docker install script 2018-08-22 08:41:59 +02:00
Arnie d9eff7bece Add WSL startup scripts 2018-08-21 18:10:08 +02:00
Arnie ba8fc9be8d Add docker relay installation script 2018-08-21 17:53:23 +02:00
Arnie 8c385c8562 Update adminer 2018-08-16 12:00:29 +02:00
Arnie 2919e542c2 Update dev-proxy configuration 2018-08-16 11:31:44 +02:00
Arnie 678adadc81 Update adminer 2018-08-16 08:10:18 +02:00
Arnie f80f641021 Add pgadmin config 2018-08-10 10:17:17 +02:00
Arnie 42c96ef915 Update adminer and dev proxy 2018-08-10 10:16:47 +02:00
Arnie 0885939ae1 Add reload command for caddy 2018-05-04 08:05:42 +02:00
Arnie 2639c0d1bd Update caddy proxy 2018-04-20 07:58:58 +02:00
Arnie 1d0bf9e3f8 Support websocket in caddy 2018-04-18 07:20:34 +02:00
Arnie f59387dbae Add caddy proxy 2018-04-18 07:01:49 +02:00
Arnie ef03f3e0f7 Fix elastic search config 2018-04-17 14:47:39 +02:00
Arnie cbf8f1cabc Add persistent volume to elastic 2018-04-11 06:28:29 +02:00
Arnie 4ae006a796 Fix sync and move functions 2018-04-11 06:23:07 +02:00
Arnie d7c86421f6 Install xpack for elastic 5.3.2 2018-04-11 06:22:02 +02:00
Arnie 7b2ac13417 Update the run script for mariadb 2018-03-23 12:00:03 +01:00
Arnie a7050f1767 Update the run script for mariadb 2018-03-23 11:58:41 +01:00
Arnie 43765388f8 Update adminer build 2018-03-15 11:00:13 +01:00
Arnie 55082bf091 Add sync command to aws cli script 2018-03-13 06:51:52 +01:00
Arnie aa23d37449 Add makefile for aws-cli 2018-03-13 06:48:10 +01:00
Arnie b4f509d90d Default aws cli directory for commands 2018-03-02 10:02:08 +01:00
Arnie ec252ee502 Update dev configuration 2018-02-27 12:06:51 +01:00
Arnie 8338490267 Add move to aws cli 2018-01-24 10:18:26 +01:00
Arnie b8ffe6ab02 Update aws cli migrate warning text 2018-01-23 07:20:45 +01:00
57 changed files with 1625 additions and 402 deletions
+1
View File
@@ -1 +1,2 @@
**/env.shinc
.idea
+14 -2
View File
@@ -2,7 +2,19 @@ ARG IMAGE_NAME
ARG IMAGE_VERSION
FROM ${IMAGE_NAME}:${IMAGE_VERSION}
# Clue adminer override
#RUN sed -i 's/max_execution_time.*/max_execution_time = 600/g' /etc/php5/cli/php.ini && sed -i 's/max_input_time.*/max_input_time = 600/g' /etc/php5/fpm/php.ini
USER root
RUN rm /usr/local/etc/php/conf.d/0-upload_large_dumps.ini
RUN apk add --no-cache \
$PHPIZE_DEPS \
&& pecl install mongodb \
&& pecl clear-cache \
&& docker-php-ext-enable mongodb
COPY ["conf.d/", "/usr/local/etc/php/conf.d"]
ENV ADMINER_PLUGINS="dump-date dump-json dump-php dump-zip edit-calendar edit-textarea"
ENV ADMINER_DESIGN="hever"
USER adminer
+28
View File
@@ -0,0 +1,28 @@
DOCKER_REGISTRY := dr.ys-dev.cz
DOCKER_PUBLIC_REGISTRY := yoursystemcz
DOCKER_MY_REGISTRY := dr.cechis.cz
APP_NAME := adminer
IMAGE_NAME := adminer
VERSION := 4.8.0
all: build release
.PHONY: all
version/$(VERSION): IMAGE_VERSION=$(VERSION)
version/%:
docker build -t $(DOCKER_REGISTRY)/$(APP_NAME):$* --build-arg "IMAGE_NAME=$(IMAGE_NAME)" --build-arg "IMAGE_VERSION=$*" .
release/%:
docker tag $(DOCKER_REGISTRY)/$(APP_NAME):$* $(DOCKER_PUBLIC_REGISTRY)/$(APP_NAME):$*
docker tag $(DOCKER_REGISTRY)/$(APP_NAME):$* $(DOCKER_MY_REGISTRY)/$(APP_NAME):$*
docker push $(DOCKER_REGISTRY)/$(APP_NAME):$*
docker push $(DOCKER_MY_REGISTRY)/$(APP_NAME):$*
docker push $(DOCKER_PUBLIC_REGISTRY)/$(APP_NAME):$*
build: version/$(VERSION)
release: release/$(VERSION)
-1
View File
@@ -1,4 +1,3 @@
post_max_size = 2000M
upload_max_filesize = 2000M
memory_limit = 2000M
max_file_uploads = 20
+6 -4
View File
@@ -2,8 +2,8 @@
SCRIPT_PATH=$( cd "$(dirname "$0")" ; pwd -P )
IMAGE_NAME="adminer"
IMAGE_VERSION="latest"
IMAGE_NAME="yoursystemcz/adminer"
IMAGE_VERSION="4.8.0"
SERVICE_NAME=adminer
@@ -17,6 +17,7 @@ source ${SCRIPT_PATH}/../common.shinc
DOMAIN_NAME="adminer.loc"
ADMINER_DESIGN="hever"
ADMINER_PLUGINS="dump-date dump-json dump-php dump-zip edit-calendar edit-foreign edit-textarea"
ADMINER_DEFAULT_SERVER="maria-db"
source ${SCRIPT_PATH}/env.shinc 2> /dev/null
@@ -28,15 +29,16 @@ init() {
NETWORKS=(${DB_NETWORK} ${PROXY_NETWORK})
__createNetworks
__build || return $?
docker create \
--name ${SERVICE_NAME} \
-e VIRTUAL_HOST=${DOMAIN_NAME} \
-e VIRTUAL_PORT=8080 \
-e ADMINER_DESIGN="${ADMINER_DESIGN}" \
-e ADMINER_PLUGINS="${ADMINER_PLUGINS}" \
-e ADMINER_DEFAULT_SERVER="${ADMINER_DEFAULT_SERVER}" \
--restart=unless-stopped \
${SERVICE_NAME}:latest
${IMAGE_NAME}:${IMAGE_VERSION}
[[ $? -ne 0 ]] && return 1
+6
View File
@@ -0,0 +1,6 @@
*
!.gitignore
!Dockerfile
!README.md
!run.sh
!Makefile
+27
View File
@@ -0,0 +1,27 @@
DOCKER_REGISTRY = dr.ys-dev.cz
DOCKER_PUBLIC_REGISTRY = yoursystemcz
APP_NAME = aws-cli
all: build release clean
version/3.5: IMAGE_VERSION=3.5
version/latest: IMAGE_VERSION=3.6
version/%:
docker build -t $(DOCKER_REGISTRY)/$(APP_NAME):$* --build-arg "IMAGE_NAME=alpine" --build-arg "IMAGE_VERSION=$(IMAGE_VERSION)" .
release/%:
docker tag $(DOCKER_REGISTRY)/$(APP_NAME):$* $(DOCKER_PUBLIC_REGISTRY)/$(APP_NAME):$*
docker push $(DOCKER_REGISTRY)/$(APP_NAME):$*
docker push $(DOCKER_PUBLIC_REGISTRY)/$(APP_NAME):$*
clean/%:
docker rmi $(DOCKER_REGISTRY)/$(APP_NAME):$*
docker rmi $(DOCKER_PUBLIC_REGISTRY)/$(APP_NAME):$*
build: version/3.5 version/latest
release: release/3.5 release/latest
clean: clean/3.5 clean/latest
-242
View File
@@ -1,242 +0,0 @@
#!/usr/bin/env bash
SCRIPT_PATH=$( cd "$(dirname "$0")" ; pwd -P )
IMAGE_NAME="alpine"
IMAGE_VERSION="3.4"
SERVICE_NAME=aws-cli
source ${SCRIPT_PATH}/../common.shinc
#
# Project specific variables
#
AWS_DEFAULT_REGION=eu-central-1
CUSTOM_ARGS=""
CURRENT_DATE="$(date +%Y-%m-%d)"
platform=$(uname)
if [[ ${platform} = "FreeBSD" ]] || [[ ${platform} = "Darwin" ]]; then
EXPIRES=$(date -v+365d '+%a, %d %b %Y 00:00:00 GMT')
else
EXPIRES=$(date '+%a, %d %b %Y 00:00:00 GMT' -d "${CURRENT_DATE} + 365 day")
fi
CACHE_MAX_AGE="31536000"
ACL="public-read"
source ${SCRIPT_PATH}/env.shinc 2> /dev/null
REQUIRED_VARIABLES=(AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY)
for _var in ${REQUIRED_VARIABLES[@]}; do
if [ -z ${!_var+x} ]; then
echo "Please provide credential in env.shinc file, missing definition of variable: ${_var}"
exit 2
fi
done
init() {
__build
[[ $? -ne 0 ]] && return 1
}
cmd() {
local localDir
__msg "Specify a mount point to /mnt/host inside the docker container"
read localDir
if [[ ${localDir} = "" ]]; then
localDir="$(pwd -P)"
__warn "You have not provided a directory, using current path: ${localDir}"
__msg "Continue? [(y)/n]"
read CONTINUE
if [[ ${CONTINUE} != "" ]] && [[ ${CONTINUE} != "y" ]] && [[ ${CONTINUE} != "Y" ]]; then
return 0
fi
fi
__warn "Mounting ${localDir} to /mnt/host inside the docker container"
docker run --rm \
-u $(id -u):$(id -g) \
--env AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} \
--env AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} \
--env AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION} \
-v "${localDir}":/mnt/host \
${CUSTOM_ARGS} \
${SERVICE_NAME} \
aws "$@"
}
upload() {
local source="$1"
shift
local target="$1"
shift
local args="$@"
[[ ${source} = "" ]] && __err "You must provide a source directory (filesystem) as the first parameter" && return 137
[[ ${target} = "" ]] && __err "You must provide a target directory (s3) as the second parameter" && return 137
[[ ! -e ${source} ]] && __err "The source does not exist: ${source}" && return 6
__warn "Uploading ${source} to s3://${target}"
__msg "Cache expires on ${EXPIRES}"
if [[ -f ${source} ]]; then
# File
local dirName=$(dirname ${source})
local filename=$(basename ${source})
docker run --rm \
-u $(id -u):$(id -g) \
--env AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} \
--env AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} \
--env AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION} \
-v "${dirName}":/mnt/host \
${SERVICE_NAME} \
aws s3 cp "/mnt/host/${filename}" "s3://${target}" ${args} --acl "${ACL}" --expires "${EXPIRES}" --cache-control "max-age=${CACHE_MAX_AGE}" --metadata-directive REPLACE
else
# Directory
docker run --rm \
-u $(id -u):$(id -g) \
--env AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} \
--env AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} \
--env AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION} \
-v "${source}":/mnt/host \
${SERVICE_NAME} \
aws s3 cp /mnt/host "s3://${target}" ${args} --recursive --acl "${ACL}" --expires "${EXPIRES}" --cache-control "max-age=${CACHE_MAX_AGE}" --metadata-directive REPLACE
fi
}
download() {
local source="$1"
shift
local target="$1"
shift
local args="$@"
[[ ${source} = "" ]] && __err "You must provide a source (filesystem) as the first parameter" && return 137
[[ ${target} = "" ]] && __err "You must provide a target (s3) as the second parameter" && return 137
__warn "Downloading s3://${source} to ${target}"
if [[ ! -e ${target} ]]; then
__warn "The target ${target} does not exist. Is this a file (f) or a directory (d)? ..."
read type
if [[ ${type} = "f" ]]; then
mkdir -p $(dirname ${target})
touch ${target}
elif [[ ${type} = "d" ]]; then
mkdir -p ${target}
else
__err "The input is invalid, please use either 'f' or 'd'"
fi
fi
if [[ -f ${target} ]]; then
# File
local dirName=$(dirname ${target})
local filename=$(basename ${target})
docker run --rm \
-u $(id -u):$(id -g) \
--env AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} \
--env AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} \
--env AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION} \
-v "${dirName}":/mnt/host \
${SERVICE_NAME} \
aws s3 cp "s3://${source}" "/mnt/host/${filename}" ${args}
else
# Directory
docker run --rm \
-u $(id -u):$(id -g) \
--env AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} \
--env AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} \
--env AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION} \
-v "${target}":/mnt/host \
${SERVICE_NAME} \
aws s3 cp "s3://${source}" /mnt/host ${args} --recursive
fi
}
migrate() {
local source_dir="$1"
shift
local target_dir="$1"
shift
local args="$@"
[[ ${source_dir} = "" ]] && __err "You must provide a source directory (s3) as the first parameter" && return 137
[[ ${target_dir} = "" ]] && __err "You must provide a target directory (s3) as the second parameter" && return 137
__warn "Migrating s3://${source} to s3://${target}"
echo "Cache expires on ${EXPIRES}"
docker run --rm \
-u $(id -u):$(id -g) \
--env AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} \
--env AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} \
--env AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION} \
${SERVICE_NAME} \
aws s3 cp "s3://${source_dir}" "s3://${target_dir}" ${args} --recursive --acl "${ACL}" --expires "${EXPIRES}" --cache-control "max-age=${CACHE_MAX_AGE}" --metadata-directive REPLACE
}
setPermissions() {
local target_dir="$1"
if [[ ${target_dir} = "" ]]; then
__warn "Please provide an s3 path: "
read target_dir
fi
docker run --rm \
-u $(id -u):$(id -g) \
--env AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} \
--env AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} \
--env AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION} \
${SERVICE_NAME} \
aws s3 cp "s3://${target_dir}" "s3://${target_dir}" --recursive --acl "${ACL}" --expires "${EXPIRES}" --cache-control "max-age=${CACHE_MAX_AGE}" --metadata-directive REPLACE
}
exec() {
local source_dir="$1"
if [[ ${source_dir} = "" ]]; then
source_dir=$(pwd -P)
__warn "You have not provided a directory, using current path: ${source_dir}"
__msg "Continue? [(y)/n]"
read CONTINUE
if [[ ${CONTINUE} != "" ]] && [[ ${CONTINUE} != "y" ]] && [[ ${CONTINUE} != "Y" ]]; then
return 0
fi
fi
docker run --rm -it \
-u $(id -u):$(id -g) \
--env AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} \
--env AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} \
--env AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION} \
-v "${source_dir}":/mnt/host \
${SERVICE_NAME} \
sh
}
"$@"
exit $?
+10 -7
View File
@@ -1,28 +1,31 @@
FROM node:8-slim
FROM node:12-slim
ARG PHP_VERSION
ENV PHP_CS_FIXER_IGNORE_ENV=true
# https support
RUN apt-get update && \
apt-get install -y apt-transport-https ca-certificates
apt-get install -y apt-transport-https ca-certificates curl gnupg2
# add yarn and php
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
curl -sS https://packages.sury.org/php/apt.gpg | apt-key add - && \
echo "deb https://packages.sury.org/php/ stretch main" | tee /etc/apt/sources.list.d/${PHP_VERSION}.list && \
apt-get update && \
apt-get install -y yarn php5-cli && \
apt-get install -y yarn ${PHP_VERSION}-cli && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /etc/apt/sources.list.d/* /tmp/* /var/tmp/*
# add php fixer
RUN curl -L https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.10.0/php-cs-fixer.phar -o /usr/local/bin/php-cs-fixer && \
RUN curl -L https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.16.3/php-cs-fixer.phar -o /usr/local/bin/php-cs-fixer && \
chmod a+x /usr/local/bin/php-cs-fixer
WORKDIR /app
# add csscomb and prettier
RUN yarn add prettier csscomb --global && \
ln -s /app/node_modules/.bin/prettier /usr/local/bin/prettier && \
ln -s /app/node_modules/.bin/csscomb /usr/local/bin/csscomb
RUN npm install prettier csscomb --global
COPY ["src/entry.sh", "/app/entry.sh"]
+39
View File
@@ -0,0 +1,39 @@
FROM node:10-slim
# https support
RUN apt-get update && \
apt-get install -y apt-transport-https ca-certificates
# add yarn and php
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
apt-get update && \
apt-get install -y yarn php5-cli && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /etc/apt/sources.list.d/* /tmp/* /var/tmp/*
# add php fixer
RUN curl -L https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.14.0/php-cs-fixer.phar -o /usr/local/bin/php-cs-fixer && \
chmod a+x /usr/local/bin/php-cs-fixer
WORKDIR /app
# add csscomb and prettier
RUN npm install prettier csscomb --global
COPY ["src/entry.sh", "/app/entry.sh"]
COPY ["src/inc", "/app/inc"]
WORKDIR /code
CMD ["/app/entry.sh"]
ENTRYPOINT ["/app/entry.sh"]
ARG VERSION
ARG COMMIT_SHA
ENV VERSION=$VERSION
ENV COMMIT_SHA=$COMMIT_SHA
+10 -2
View File
@@ -17,13 +17,21 @@ GIT_TAG = $(shell git describe --tags --exact-match 2>/dev/null)
VERSION := $(or $(GIT_TAG),latest)
all : VERSION := 1.0.1
all : VERSION := 1.1.2
all : build release
.PHONY : all
build :
docker build --build-arg VERSION=$(VERSION) --build-arg COMMIT_SHA=$(COMMIT) -t $(DOCKER_REGISTRY)/$(APP_NAME):$(VERSION) .
docker build --build-arg VERSION=$(VERSION) --build-arg PHP_VERSION="php7.3" --build-arg COMMIT_SHA=$(COMMIT) -t $(DOCKER_REGISTRY)/$(APP_NAME):$(VERSION)-php7.3 .
docker build --build-arg VERSION=$(VERSION) --build-arg PHP_VERSION="php7.4" --build-arg COMMIT_SHA=$(COMMIT) -t $(DOCKER_REGISTRY)/$(APP_NAME):$(VERSION)-php7.4 .
docker build --build-arg VERSION=$(VERSION) --build-arg COMMIT_SHA=$(COMMIT) -t $(DOCKER_REGISTRY)/$(APP_NAME):$(VERSION)-php5.6 .
docker tag $(DOCKER_REGISTRY)/$(APP_NAME):$(VERSION)-php7.4 $(DOCKER_REGISTRY)/$(APP_NAME):$(VERSION)
docker tag $(DOCKER_REGISTRY)/$(APP_NAME):$(VERSION)-php7.4 $(DOCKER_REGISTRY)/$(APP_NAME):latest
release : build
docker push $(DOCKER_REGISTRY)/$(APP_NAME):$(VERSION)-php7.3
docker push $(DOCKER_REGISTRY)/$(APP_NAME):$(VERSION)-php7.4
docker push $(DOCKER_REGISTRY)/$(APP_NAME):$(VERSION)-php5.6
docker push $(DOCKER_REGISTRY)/$(APP_NAME):$(VERSION)
docker push $(DOCKER_REGISTRY)/$(APP_NAME):latest
+9 -6
View File
@@ -32,6 +32,8 @@ main() {
_version="${VERSION}"
fi
__initVariables "$@"
__header "Code-Formatter [${_version}]"
@@ -41,25 +43,26 @@ main() {
case "${_cmd}" in
process)
__initVariables "$@"
source ${INCLUDES_PATH}/process.shinc
process
return $?
;;
prettier)
__initVariables "$@"
source ${INCLUDES_PATH}/formatters/prettier.shinc
__prettier
if [[ ${#CSS_FILES[@]} -ne 0 ]]; then
__prettier ${CSS_FILES[@]}
fi
if [[ ${#JS_FILES[@]} -ne 0 ]]; then
__prettier ${JS_FILES[@]}
fi
return $?
;;
csscomb)
__initVariables "$@"
source ${INCLUDES_PATH}/formatters/csscomb.shinc
__csscomb
__csscomb ${CSS_FILES[@]}
return $?
;;
php-cs-fixer)
__initVariables "$@"
source ${INCLUDES_PATH}/formatters/php-cs-fixer.shinc
__phpFixer
return $?
@@ -3,11 +3,12 @@
__csscomb() {
__msg "Csscomb:"
local files=("$@")
if [[ ${DRY_RUN} -eq 0 ]]; then
csscomb -v "${CSS_FILES[@]}"
csscomb -v "${files[@]}"
else
csscomb --lint -v "${CSS_FILES[@]}"
csscomb --lint -v "${files[@]}"
fi
return $?
@@ -3,13 +3,18 @@
__phpFixer() {
local failed=0
local args=""
__msg "PHP-cs-fixer"
if [[ ${VERBOSE} -eq 1 ]]; then
args="${args} -vvv"
fi
# Cannot chain php files without specifying a config CS file :(
if [[ ${DRY_RUN} -eq 0 ]]; then
for file in "${PHP_FILES[@]}"; do
php-cs-fixer fix "${file}"
php-cs-fixer ${args} fix "${file}"
[[ $? -ne 0 ]] && failed=1
done
else
@@ -17,7 +22,7 @@ __phpFixer() {
local invalid_syntax=()
for file in "${PHP_FILES[@]}"; do
php-cs-fixer fix --dry-run "${file}"
php-cs-fixer ${args} fix --dry-run "${file}"
case $? in
0)
#all good
@@ -3,12 +3,13 @@
__prettier() {
__msg "Prettier:"
local files=("$@")
if [[ ${DRY_RUN} -eq 0 ]]; then
prettier --write "${JS_FILES[@]}"
prettier --write "${files[@]}"
else
__msg "Listing (: unprettiered :) files:" 1
prettier --list-different "${JS_FILES[@]}"
prettier --list-different "${files[@]}"
fi
return $?
+5
View File
@@ -6,30 +6,35 @@
# Colors
__color_green() {
[[ ${OMIT_COLORS} -eq 1 ]] && printf -- "%b" "$*" && return
printf '\033[1;31;32m'
printf -- "%b" "$*"
printf '\033[0m'
}
__color_red() {
[[ ${OMIT_COLORS} -eq 1 ]] && printf -- "%b" "$*" && return
printf '\033[1;31m'
printf -- "%b" "$*"
printf '\033[0m'
}
__color_red_bg() {
[[ ${OMIT_COLORS} -eq 1 ]] && printf -- "%b" "$*" && return
printf '\033[1;41m'
printf -- "%b" "$*"
printf '\033[0m'
}
__color_white() {
[[ ${OMIT_COLORS} -eq 1 ]] && printf -- "%b" "$*" && return
printf '\033[1;37;40m'
printf -- "%b" "$*"
printf '\033[0m'
}
__color_yellow() {
[[ ${OMIT_COLORS} -eq 1 ]] && printf -- "%b" "$*" && return
printf '\033[1;31;33m'
printf -- "%b" "$*"
printf '\033[0m'
+4 -2
View File
@@ -11,13 +11,15 @@ process() {
# Run css comb
if [[ ${#CSS_FILES[@]} -ne 0 ]]; then
__csscomb
__csscomb "${CSS_FILES[@]}"
[[ $? -ne 0 ]] && failed=1
__prettier "${CSS_FILES[@]}"
[[ $? -ne 0 ]] && failed=1
fi
# Run JS prettier
if [[ ${#JS_FILES[@]} -ne 0 ]]; then
__prettier
__prettier "${JS_FILES[@]}"
[[ $? -ne 0 ]] && failed=1
fi
+9 -2
View File
@@ -11,7 +11,8 @@ PHP_FILES=()
DRY_RUN=0
OMIT_COLORS=0
VERBOSE=0
__initVariables() {
@@ -21,6 +22,12 @@ __initVariables() {
--dry-run)
DRY_RUN=1
;;
--no-color)
OMIT_COLORS=1
;;
--verbose)
VERBOSE=1
;;
*.css|*.scss|*.sass|*.less)
__path_exists "${1}"
if [[ $? -ne 0 ]]; then
@@ -29,7 +36,7 @@ __initVariables() {
CSS_FILES+=("${1}")
fi
;;
*.js|*.jsx)
*.js|*.jsx|*.ts|*.tsx|*.json|*.vue)
__path_exists "${1}"
if [[ $? -ne 0 ]]; then
__err "Specified path does not exist: ${1}"
+29
View File
@@ -34,6 +34,19 @@ stop() {
start() {
__msg "Starting container... " 0 no
docker inspect --type container "${SERVICE_NAME}" > /dev/null 2>&1
if [[ $? -ne 0 ]]; then
init
CURRENT_STATUS=$(docker inspect --format "{{.State.Running}}" "${SERVICE_NAME}")
if [[ "${CURRENT_STATUS}" == "true" ]]; then
return 0
fi
fi
STATUS=$(docker start ${SERVICE_NAME} 2>&1)
if [[ $? -ne 0 ]]; then
__err "${STATUS}"
@@ -104,3 +117,19 @@ help() {
return 0
}
realpath $PWD > /dev/null 2>&1
if [[ $? -ne 0 ]]; then
realpath() {
OURPWD=$PWD
cd "$(dirname "$1")"
LINK=$(readlink "$(basename "$1")")
while [ "$LINK" ]; do
cd "$(dirname "$LINK")"
LINK=$(readlink "$(basename "$1")")
done
REALPATH="$PWD/$(basename "$1")"
cd "$OURPWD"
echo "$REALPATH"
}
fi
+18
View File
@@ -0,0 +1,18 @@
DOCKER_REGISTRY = dr.ys-dev.cz
DOCKER_PUBLIC_REGISTRY = yoursystemcz
APP_NAME = dev-proxy
APP_VERSION = 2.0
all: build tag release
build:
docker build -t $(DOCKER_REGISTRY)/$(APP_NAME):$(APP_VERSION) ./src
tag:
docker tag $(DOCKER_REGISTRY)/$(APP_NAME):$(APP_VERSION) $(DOCKER_PUBLIC_REGISTRY)/$(APP_NAME):$(APP_VERSION)
release: tag
docker push $(DOCKER_REGISTRY)/$(APP_NAME):$(APP_VERSION)
docker push $(DOCKER_PUBLIC_REGISTRY)/$(APP_NAME):$(APP_VERSION)
Executable
+73
View File
@@ -0,0 +1,73 @@
#!/usr/bin/env bash
SCRIPT_PATH=$( cd "$(dirname "$0")" ; pwd -P )
IMAGE_NAME="yoursystemcz/dev-proxy"
IMAGE_VERSION="2.0"
SERVICE_NAME=dev-proxy
source ${SCRIPT_PATH}/../common.shinc
#
# Project specific variables
#
source ${SCRIPT_PATH}/env.shinc 2> /dev/null
init() {
makePrivate
}
makePrivate() {
docker pull ${IMAGE_NAME}:${IMAGE_VERSION} || return $?
NETWORKS=(${PROXY_NETWORK})
__createNetworks
docker create \
--name ${SERVICE_NAME} \
-v /var/run/docker.sock:/tmp/docker.sock:ro \
-v dev-proxy:/root/.caddy \
-v ${SCRIPT_PATH}/src/errorPages:/errorPages \
--restart=unless-stopped \
-p 127.0.0.1:80:80 \
-p 127.0.0.1:443:443 \
--net ${PROXY_NETWORK} \
${IMAGE_NAME}:${IMAGE_VERSION}
[[ $? -ne 0 ]] && return 1
__ask_to_start
}
makePublic() {
docker pull ${IMAGE_NAME}:${IMAGE_VERSION} || return $?
NETWORKS=(${PROXY_NETWORK})
__createNetworks
docker create \
--name ${SERVICE_NAME} \
-v /var/run/docker.sock:/tmp/docker.sock:ro \
-v dev-proxy:/root/.caddy \
--restart=unless-stopped \
-p 80:80 \
-p 443:443 \
--net ${PROXY_NETWORK} \
${IMAGE_NAME}:${IMAGE_VERSION}
[[ $? -ne 0 ]] && return 1
__ask_to_start
}
reload() {
docker exec ${SERVICE_NAME} caddy reload --config /etc/caddy/Caddyfile
}
"$@"
exit $?
+2
View File
@@ -0,0 +1,2 @@
/.dockerignore
/Dockerfile
+51
View File
@@ -0,0 +1,51 @@
FROM alpine:3.12
ARG CADDY_VERSION="2.2.0"
ARG FOREGO_VERSION="0.16.1"
ARG DOCKER_GEN_VERSION="0.7.4"
ENV CADDYPATH="/etc/caddy"
ENV DOCKER_HOST unix:///tmp/docker.sock
# Install wget and install/updates certificates
RUN apk add --no-cache bash openssh-client git && \
apk add --no-cache --virtual .build-dependencies curl wget tar
# Install Forego
RUN wget --quiet "https://github.com/jwilder/forego/releases/download/v${FOREGO_VERSION}/forego" \
&& mv ./forego /usr/bin/forego \
&& chmod u+x /usr/bin/forego
# Install docker-gen
RUN wget --quiet "https://github.com/jwilder/docker-gen/releases/download/$DOCKER_GEN_VERSION/docker-gen-alpine-linux-amd64-$DOCKER_GEN_VERSION.tar.gz" \
&& tar -C /usr/bin -xvzf "docker-gen-alpine-linux-amd64-$DOCKER_GEN_VERSION.tar.gz" \
&& rm "/docker-gen-alpine-linux-amd64-$DOCKER_GEN_VERSION.tar.gz"
# Install Caddy
RUN curl --silent --show-error --fail --location \
--header "Accept: application/tar+gzip, application/x-gzip, application/octet-stream" -o - \
"https://github.com/mholt/caddy/releases/download/v${CADDY_VERSION}/caddy_${CADDY_VERSION}_linux_amd64.tar.gz" \
| tar --no-same-owner -C /usr/bin -xz \
&& chmod 0755 /usr/bin/caddy \
&& /usr/bin/caddy version \
&& apk del .build-dependencies
EXPOSE 80 443
VOLUME /etc/caddy
# Starting app:
COPY [".", "/code"]
WORKDIR /code
ENTRYPOINT ["sh", "/code/docker-entrypoint.sh"]
CMD ["/usr/bin/forego", "start", "-r"]
+2
View File
@@ -0,0 +1,2 @@
dockergen: docker-gen -notify-output -config /code/docker-gen/config/docker-gen.cfg -notify caddy reload
caddy: caddy run --config /etc/caddy/Caddyfile --watch
+10
View File
@@ -0,0 +1,10 @@
#!/bin/sh
set -o errexit
set -o nounset
# Create initial configuration:
docker-gen /code/docker-gen/templates/Caddyfile.tmpl /etc/caddy/Caddyfile
# Execute passed command:
exec "$@"
@@ -0,0 +1,7 @@
[[config]]
template = "/code/docker-gen/templates/Caddyfile.tmpl"
dest = "/etc/caddy/Caddyfile"
onlyexposed = false
watch = true
wait = "500ms:2s"
notifycmd = "caddy reload --config /etc/caddy/Caddyfile"
@@ -0,0 +1,65 @@
{{ $CurrentContainer := where $ "ID" .Docker.CurrentContainerID | first }}
{{ $hosts := groupByMulti $ "Env.VIRTUAL_HOST" "," }}
{
auto_https disable_redirects
local_certs
}
:80 {
log {
output stdout
}
root * /code/errorPages/siteNotFound
file_server
header Cache-Control "no-cache, max-age=0"
try_files {path} /index.html
}
{{ if $hosts }}
{{ range $host, $containers := $hosts }}
{{ $c := first $containers }}
{{ $tlsOff := trim (index $c.Env "VIRTUAL_DISABLE_TLS") }}
{{ $port := coalesce $c.Env.VIRTUAL_PORT "80" }}
http://{{ $host }}, https://{{ $host }} {
tls internal
reverse_proxy * {
header_up X-Real-IP {http.request.remote}
header_up X-Forwarded-Port {http.request.port}
header_up X-Forwarded-Proto {http.request.scheme}
flush_interval -1
{{ range $i, $container := $containers }}
{{ $addrLen := len $container.Addresses }}
{{ range $knownNetwork := $CurrentContainer.Networks }}
{{ range $containerNetwork := $container.Networks }}
{{ if (and (and (ne $containerNetwork.Name "ingress") (ne $containerNetwork.Name "bridge")) (or (eq $knownNetwork.Name $containerNetwork.Name) (eq $knownNetwork.Name "host"))) }}
## Can be connected with "{{ $containerNetwork.Name }}" network
to {{ $containerNetwork.IP }}:{{ $port }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
}
@hmr {
not {
path /__webpack_hmr
}
}
encode @hmr gzip
log {
output stdout
}
}
{{ end }}
{{ end }}
Binary file not shown.

After

Width:  |  Height:  |  Size: 242 KiB

File diff suppressed because one or more lines are too long
+13
View File
@@ -0,0 +1,13 @@
ARG IMAGE_NAME
ARG IMAGE_VERSION
FROM ${IMAGE_NAME}:${IMAGE_VERSION}
RUN bin/elasticsearch-plugin install x-pack
ADD elasticsearch.yml /usr/share/elasticsearch/config/
USER root
RUN chown elasticsearch:elasticsearch config/elasticsearch.yml
USER elasticsearch
+19
View File
@@ -0,0 +1,19 @@
http:
host: 0.0.0.0
transport:
host: 127.0.0.1
xpack:
security:
enabled: false
authc:
anonymous:
roles:
- role1
- role2
cluster:
routing:
allocation:
disk:
watermark:
low: 0.90
high: 0.95
+67
View File
@@ -0,0 +1,67 @@
#!/usr/bin/env bash
SCRIPT_PATH=$( cd "$(dirname "$0")" ; pwd -P )
IMAGE_NAME="elasticsearch"
IMAGE_VERSION="5.6.16"
SERVICE_NAME=ys-elastic-search-5
source ${SCRIPT_PATH}/../common.shinc
#
# Project specific variables
#
DOMAIN_NAME="elastic5.loc"
RELEASE_NAME="yoursystemcz/elasticsearch"
RELEASE_VERSION="5.6.16"
PERSISTENT_VOLUME="ys-elastic-5"
source ${SCRIPT_PATH}/env.shinc 2> /dev/null
init() {
__init
# Create networks
NETWORKS=(${SEARCH_ENGINE_NETWORK} ${PROXY_NETWORK})
__createNetworks
docker create \
--name ${SERVICE_NAME} \
-e VIRTUAL_HOST=${DOMAIN_NAME} \
-e VIRTUAL_PORT=9200 \
-v ${PERSISTENT_VOLUME}:/usr/share/elasticsearch/data \
--net ${SEARCH_ENGINE_NETWORK} \
${RELEASE_NAME}:${RELEASE_VERSION}
[[ $? -ne 0 ]] && return 1
docker network connect ${PROXY_NETWORK} ${SERVICE_NAME}
__ask_to_start
}
build() {
docker build \
--build-arg IMAGE_NAME=${IMAGE_NAME} \
--build-arg IMAGE_VERSION=${IMAGE_VERSION} \
-t ${RELEASE_NAME}:${RELEASE_VERSION} \
${SCRIPT_PATH}
}
release() {
build
docker push ${RELEASE_NAME}:${RELEASE_VERSION}
return $?
}
"$@"
exit $?
+11
View File
@@ -0,0 +1,11 @@
ARG IMAGE_NAME
ARG IMAGE_VERSION
FROM ${IMAGE_NAME}:${IMAGE_VERSION}
ADD elasticsearch.yml /usr/share/elasticsearch/config/
USER root
RUN chown elasticsearch:elasticsearch config/elasticsearch.yml
USER elasticsearch
+19
View File
@@ -0,0 +1,19 @@
http:
host: 0.0.0.0
transport:
host: 127.0.0.1
xpack:
security:
enabled: false
authc:
anonymous:
roles:
- role1
- role2
cluster:
routing:
allocation:
disk:
watermark:
low: 0.90
high: 0.95
+67
View File
@@ -0,0 +1,67 @@
#!/usr/bin/env bash
SCRIPT_PATH=$( cd "$(dirname "$0")" ; pwd -P )
IMAGE_NAME="elasticsearch"
IMAGE_VERSION="6.5.4"
SERVICE_NAME=ys-elastic-search-6
source ${SCRIPT_PATH}/../common.shinc
#
# Project specific variables
#
DOMAIN_NAME="elastic6.loc"
RELEASE_NAME="yoursystemcz/elasticsearch"
RELEASE_VERSION="6.5.4"
PERSISTENT_VOLUME="ys-elastic-6"
source ${SCRIPT_PATH}/env.shinc 2> /dev/null
init() {
__init
# Create networks
NETWORKS=(${SEARCH_ENGINE_NETWORK} ${PROXY_NETWORK})
__createNetworks
docker create \
--name ${SERVICE_NAME} \
-e VIRTUAL_HOST=${DOMAIN_NAME} \
-e VIRTUAL_PORT=9200 \
-v ${PERSISTENT_VOLUME}:/usr/share/elasticsearch/data \
--net ${SEARCH_ENGINE_NETWORK} \
${RELEASE_NAME}:${RELEASE_VERSION}
[[ $? -ne 0 ]] && return 1
docker network connect ${PROXY_NETWORK} ${SERVICE_NAME}
__ask_to_start
}
build() {
docker build \
--build-arg IMAGE_NAME=${IMAGE_NAME} \
--build-arg IMAGE_VERSION=${IMAGE_VERSION} \
-t ${RELEASE_NAME}:${RELEASE_VERSION} \
${SCRIPT_PATH}
}
release() {
build
docker push ${RELEASE_NAME}:${RELEASE_VERSION}
return $?
}
"$@"
exit $?
+7
View File
@@ -10,3 +10,10 @@ xpack:
roles:
- role1
- role2
cluster:
routing:
allocation:
disk:
watermark:
low: 0.90
high: 0.95
+13 -3
View File
@@ -3,7 +3,8 @@
SCRIPT_PATH=$( cd "$(dirname "$0")" ; pwd -P )
IMAGE_NAME="elasticsearch"
IMAGE_VERSION="5.3.2"
# Old version, AWS supported
IMAGE_VERSION="2.3.5"
SERVICE_NAME=ys-elastic-search
@@ -17,7 +18,10 @@ source ${SCRIPT_PATH}/../common.shinc
DOMAIN_NAME="elastic.loc"
RELEASE_NAME="yoursystemcz/elasticsearch"
RELEASE_VERSION="5.3.2"
# Old version, AWS supported
RELEASE_VERSION="2.3.5"
PERSISTENT_VOLUME="ys-elastic"
source ${SCRIPT_PATH}/env.shinc 2> /dev/null
@@ -32,6 +36,8 @@ init() {
docker create \
--name ${SERVICE_NAME} \
-e VIRTUAL_HOST=${DOMAIN_NAME} \
-e VIRTUAL_PORT=9200 \
-v ${PERSISTENT_VOLUME}:/usr/share/elasticsearch/data \
--net ${SEARCH_ENGINE_NETWORK} \
${RELEASE_NAME}:${RELEASE_VERSION}
@@ -42,12 +48,16 @@ init() {
__ask_to_start
}
release() {
build() {
docker build \
--build-arg IMAGE_NAME=${IMAGE_NAME} \
--build-arg IMAGE_VERSION=${IMAGE_VERSION} \
-t ${RELEASE_NAME}:${RELEASE_VERSION} \
${SCRIPT_PATH}
}
release() {
build
docker push ${RELEASE_NAME}:${RELEASE_VERSION}
Executable
+55
View File
@@ -0,0 +1,55 @@
#!/usr/bin/env bash
SCRIPT_PATH=$( cd "$(dirname "$0")" ; pwd -P )
IMAGE_NAME="usefathom/fathom"
IMAGE_VERSION="latest"
SERVICE_NAME=fathom
source ${SCRIPT_PATH}/../common.shinc
#
# Project specific variables
#
DOMAIN_NAME="fathom.loc"
source ${SCRIPT_PATH}/env.shinc 2> /dev/null
init() {
__init
NETWORKS=(${PROXY_NETWORK} ${DB_NETWORK})
__createNetworks
docker create \
--name ${SERVICE_NAME} \
-e VIRTUAL_HOST=${DOMAIN_NAME} \
-e VIRTUAL_PORT=8080 \
-e FATHOM_DATABASE_DRIVER="postgres" \
-e FATHOM_DATABASE_NAME="fathom" \
-e FATHOM_DATABASE_USER="root" \
-e FATHOM_DATABASE_PASSWORD="megaheslo" \
-e FATHOM_DATABASE_HOST="pgsql-db" \
-e FATHOM_DATABASE_SSLMODE="disable" \
-e FATHOM_SECRET="abcdefghijqrstuvw34567890" \
${IMAGE_NAME}:${IMAGE_VERSION}
[[ $? -ne 0 ]] && return 1
docker network connect ${PROXY_NETWORK} ${SERVICE_NAME}
[[ $? -ne 0 ]] && return 1
docker network connect ${DB_NETWORK} ${SERVICE_NAME}
[[ $? -ne 0 ]] && return 1
__ask_to_start
}
"$@"
exit $?
View File
Executable
+122
View File
@@ -0,0 +1,122 @@
#!/usr/bin/env bash
SCRIPT_PATH=$( cd "$(dirname "$0")" ; pwd -P )
IMAGE_NAME="mariadb"
IMAGE_VERSION="10.3"
SERVICE_NAME=maria-db
source ${SCRIPT_PATH}/../common.shinc
#
# Project specific variables
#
DB_VOLUME=mariadb_shared
BACKUP_DIR=${SCRIPT_PATH}/backup
source ${SCRIPT_PATH}/env.shinc 2> /dev/null
init() {
__init
# Create networks
NETWORKS=(${DB_NETWORK})
__createNetworks
# Create the database container
docker create \
--name ${SERVICE_NAME} \
--restart=unless-stopped \
-v ${DB_VOLUME}:/var/lib/mysql \
-p 127.0.0.1::3306 \
-e MYSQL_ROOT_PASSWORD=${DB_PASSWORD} \
--net ${DB_NETWORK} \
${IMAGE_NAME}:${IMAGE_VERSION}
[[ $? -ne 0 ]] && return 1
__ask_to_start
}
# Runs a command inside the container, mounting the current context to /current inside
cmd() {
docker run --rm -it -v $PWD:/current --net ${DB_NETWORK} ${IMAGE_NAME}:${IMAGE_VERSION} $@
}
import() {
local dbname="$1"
shift
local filename="$1"
shift
if [[ "${dbname}" == "" ]] || [[ "${filename}" == "" ]]; then
__err "You must provide database name and filename of the file you want to import"
__msg "E.g. ./run import my-database-name \"\$PWD/my-file.sql\""
return 137
fi
if [[ ! -f "${filename}" ]]; then
__err "The filename was not located at ${filename}"
return 137
fi
echo -e "${C_WARN}This will import the file located at \"${C_WHITE}${filename}${C_WARN}\" to a database named \"${C_WHITE}${dbname}${C_WARN}\"${C_NONE}"
echo
__warn "Do you want to continue? [y/(n)] "
read CONTINUE
if [[ "${CONTINUE}" != "y" ]]; then
__msg "Quiting..."
return 0
fi
__msg "Importing, please wait..."
local path=$(realpath "${filename}")
local name=$(basename "${path}")
docker run --rm -it -v "${path}":"/import/${name}" --net ${DB_NETWORK} ${IMAGE_NAME}:${IMAGE_VERSION} mysql -h ${SERVICE_NAME} -u root -p${DB_PASSWORD} "${dbname}" -e "source /import/${name}"
}
bash() {
cmd bash
}
# Used for exporting the whole database filesystem
backup() {
stop
local user=$(id -u)
mkdir -p ${BACKUP_DIR} && \
docker run --rm --volumes-from ${SERVICE_NAME} -v ${BACKUP_DIR}:/backup busybox tar cvf /backup/backup.tar /var/lib/mysql && sudo chown -R ${user}:${user} ./backup
if [[ $? -ne 0 ]]; then
__err "Could not create the backup"
exit 2
fi
start
return $?
}
# Used for importing the whole database filesystem
restore() {
stop
docker run --rm --volumes-from ${SERVICE_NAME} -v ${BACKUP_DIR}:/backup busybox sh -c "rm -rf /var/lib/mysql/* && tar xvf /backup/backup.tar --directory /"
start
return $?
}
"$@"
exit $?
-72
View File
@@ -1,72 +0,0 @@
#!/usr/bin/env bash
SCRIPT_PATH=$( cd "$(dirname "$0")" ; pwd -P )
IMAGE_NAME="mariadb"
IMAGE_VERSION="10.1"
SERVICE_NAME=maria-db
source ${SCRIPT_PATH}/../common.shinc
#
# Project specific variables
#
DB_VOLUME=mariadb_shared
BACKUP_DIR=${SCRIPT_PATH}/backup
source ${SCRIPT_PATH}/env.shinc 2> /dev/null
init() {
__init
# Create networks
NETWORKS=(${DB_NETWORK})
__createNetworks
# Create the database container
docker create \
--name ${SERVICE_NAME} \
--restart=unless-stopped \
-v ${DB_VOLUME}:/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD=${DB_PASSWORD} \
--net ${DB_NETWORK} \
${IMAGE_NAME}:${IMAGE_VERSION}
[[ $? -ne 0 ]] && return 1
__ask_to_start
}
# Used for exporting the whole database filesystem
export() {
stop
local user=$(id -u)
mkdir -p ${BACKUP_DIR} && \
docker run --rm --volumes-from ${SERVICE_NAME} -v ${BACKUP_DIR}:/backup busybox tar cvf /backup/backup.tar /var/lib/mysql && chown -R ${user}:${user} ./backup
if [[ $? -ne 0 ]]; then
__err "Could not create the backup"
exit 2
fi
start
return $?
}
# Used for importing the whole database filesystem
import() {
stop
docker run --rm --volumes-from ${SERVICE_NAME} -v ${BACKUP_DIR}:/backup busybox sh -c "rm -rf /var/lib/mysql/* && tar xvf /backup/backup.tar --directory /"
start
return $?
}
"$@"
exit $?
View File
+18
View File
@@ -0,0 +1,18 @@
DOCKER_REGISTRY = dr.ys-dev.cz
DOCKER_PUBLIC_REGISTRY = yoursystemcz
APP_NAME = node-interpretter
all: build release
build:
docker build -t $(DOCKER_REGISTRY)/$(APP_NAME):latest --build-arg "IMAGE_NAME=node" --build-arg "IMAGE_VERSION=10.15.0-slim" ./src
tag:
docker tag $(DOCKER_REGISTRY)/$(APP_NAME):latest $(DOCKER_PUBLIC_REGISTRY)/$(APP_NAME):latest
release: tag
docker push $(DOCKER_REGISTRY)/$(APP_NAME):latest
docker push $(DOCKER_PUBLIC_REGISTRY)/$(APP_NAME):latest
+41
View File
@@ -0,0 +1,41 @@
#!/usr/bin/env bash
SCRIPT_PATH=$( cd "$(dirname "$0")" ; pwd -P )
SERVICE_NAME="node-interpretter"
source ${SCRIPT_PATH}/shared.env.shinc 2> /dev/null
source ${SCRIPT_PATH}/env.shinc 2> /dev/null
docker inspect --type container ${SERVICE_NAME} > /dev/null 2>&1
if [[ $? -ne 0 ]]; then
echo "The node container does not exist"
exit 137
fi
NODE_SERVICE_STATE=$(docker inspect --type container ${SERVICE_NAME} --format "{{.State.Running}}")
if [[ $? -ne 0 ]]; then
echo "Could not get state of the node container"
exit 137
fi
if [[ "${NODE_SERVICE_STATE}" != "true" ]]; then
docker start ${SERVICE_NAME} > /dev/null 2>&1
if [[ $? -ne 0 ]]; then
echo "Could not start the node container"
exit 137
fi
fi
case "${1}" in
npm|npx|yarn|yarnpkg|*npm-cli.js*|*npx-cli.js*)
docker exec -i ${SERVICE_NAME} "$@"
;;
*)
docker exec -i ${SERVICE_NAME} node "$@"
;;
esac
+3
View File
@@ -0,0 +1,3 @@
#!/usr/bin/env bash
node npm "$@"
+3
View File
@@ -0,0 +1,3 @@
#!/usr/bin/env bash
node npx "$@"
+3
View File
@@ -0,0 +1,3 @@
#!/usr/bin/env bash
node yarn "$@"
+3
View File
@@ -0,0 +1,3 @@
#!/usr/bin/env bash
node yarnpkg "$@"
+3
View File
@@ -0,0 +1,3 @@
PROJECTS_PATH="${HOME}/projects"
MOUNT_PATHS=("${HOME}:${HOME}" "${PROJECTS_PATH}:/projects" "/mnt:/mnt")
#RESTART=1
+129
View File
@@ -0,0 +1,129 @@
#!/usr/bin/env bash
SCRIPT_PATH=$( cd "$(dirname "$0")" ; pwd -P )
IMAGE_NAME="yoursystemcz/node-interpretter"
IMAGE_VERSION="latest"
SERVICE_NAME="node-interpretter"
source ${SCRIPT_PATH}/../common.shinc
#
# Project specific variables
#
MOUNT_PATHS=()
RESTART=0
source ${SCRIPT_PATH}/shared.env.shinc 2> /dev/null
source ${SCRIPT_PATH}/env.shinc 2> /dev/null
__createLink() {
local continue
local hostPath="${1}"
local binaryLink="${2}"
if [[ -f "${hostPath}" || -L "${hostPath}" ]]; then
__warn "There is already a ${hostPath}, are you sure you want to replace it? [y/(n)]:"
read continue
if [[ "${continue}" == "y" || "${continue}" == "Y" ]]; then
__msg "Linking node binary at ${hostPath}"
sudo rm -f "${hostPath}"
sudo ln -s "${SCRIPT_PATH}/bin/${binaryLink}" "${hostPath}"
[[ $? -ne 0 ]] && __err "Could not link ${binaryLink} binary at ${hostPath}" && return 137
fi
else
__msg "Linking node binary at ${hostPath}"
sudo ln -s "${SCRIPT_PATH}/bin/${binaryLink}" "${hostPath}"
fi
}
__deleteLink() {
local hostPath="${1}"
local binaryLink="${2}"
if [[ -L "${hostPath}" ]]; then
local linkName=$(readlink -f "${hostPath}")
if [[ $? -eq 0 && "${linkName}" == "${SCRIPT_PATH}/bin/${binaryLink}" ]]; then
__warn "Removing link at ${hostPath}"
sudo rm -f ${hostPath}
fi
fi
}
__createLinks() {
__createLink "${NODE_HOST_PATH}" node
__createLink "${NODE_HOST_PATH}js" node
__createLink "${NPM_HOST_PATH}" npm
__createLink "${NPX_HOST_PATH}" npx
__createLink "${YARN_HOST_PATH}" yarn
__createLink "${YARNPKG_HOST_PATH}" yarnpkg
}
__deleteLinks() {
__deleteLink "${NODE_HOST_PATH}" node
__deleteLink "${NODE_HOST_PATH}js" node
__deleteLink "${NPM_HOST_PATH}" npm
__deleteLink "${NPX_HOST_PATH}" npx
__deleteLink "${YARN_HOST_PATH}" yarn
__deleteLink "${YARNPKG_HOST_PATH}" yarnpkg
}
init() {
__createLinks
local mountPaths=""
[[ ${#MOUNT_PATHS[@]} -eq 0 ]] && __err "No MOUNT_PATHS were specified. Please provide these in an .env.shinc file at ${SCRIPT_PATH}/.env.shinc" && return 137
for mountPath in ${MOUNT_PATHS[@]}; do
mountPaths="${mountPaths} -v ${mountPath}"
done
args="${mountPaths} -v ${SCRIPT_PATH}/configs/${SERVICE_NAME/plex_/}:/config"
if [[ ${RESTART} -eq 1 ]]; then
args="${args} --restart=always"
fi
docker create \
--name ${SERVICE_NAME} \
--user $(id -u) \
-v ${SSH_KEY}:/home/node/.ssh/${SSH_KEY_NAME} \
-v ${KNOWN_HOSTS}:/home/node/.ssh/known_hosts \
-v npm-cache:/home/node/.npm \
-e TZ=Europe/Prague \
${args} \
--net host \
--entrypoint /cmd \
${IMAGE_NAME}:${IMAGE_VERSION}
[[ $? -ne 0 ]] && __err "Could not create the docker container" && return 137
docker start ${SERVICE_NAME} && \
docker exec --user 0 ${SERVICE_NAME} mkdir -p /usr/local/lib/node_modules && \
docker exec --user 0 ${SERVICE_NAME} chown $(id -u) /usr/local/lib/node_modules && \
docker exec --user 0 ${SERVICE_NAME} chown $(id -u) /usr/local/bin
}
remove() {
stop
__msg "Removing container... " 0 no
STATUS=$(docker rm ${SERVICE_NAME} 2>&1)
if [[ $? -ne 0 ]]; then
__err "${STATUS}"
return 1
else
__success "[ok]"
fi
__deleteLinks
return 0
}
"$@"
exit $?
+12
View File
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
SSH_KEY="$HOME/.ssh/id_rsa"
SSH_KEY_NAME="id_rsa"
KNOWN_HOSTS="${HOME}/.ssh/known_hosts"
PROJECTS_PATH="${HOME}/projects"
NODE_HOST_PATH="/usr/local/bin/node"
NPM_HOST_PATH="/usr/local/bin/npm"
NPX_HOST_PATH="/usr/local/bin/npx"
YARN_HOST_PATH="/usr/local/bin/yarn"
YARNPKG_HOST_PATH="/usr/local/bin/yarnpkg"
+8
View File
@@ -0,0 +1,8 @@
ARG IMAGE_NAME
ARG IMAGE_VERSION
FROM ${IMAGE_NAME}:${IMAGE_VERSION}
COPY ["./cmd", "/cmd"]
ENTRYPOINT ["node"]
+11
View File
@@ -0,0 +1,11 @@
#!/usr/bin/env bash
echo "Waiting for commands..."
while :
do
sleep 10 &
wait
done
exit 0
Executable
+52
View File
@@ -0,0 +1,52 @@
#!/usr/bin/env bash
SCRIPT_PATH=$( cd "$(dirname "$0")" ; pwd -P )
IMAGE_NAME="dpage/pgadmin4"
IMAGE_VERSION="4.10"
SERVICE_NAME=pgadmin
source ${SCRIPT_PATH}/../common.shinc
#
# Project specific variables
#
DOMAIN_NAME="pgadmin.loc"
PGADMIN_DEFAULT_EMAIL="admin"
PGADMIN_DEFAULT_PASSWORD="admin"
source ${SCRIPT_PATH}/env.shinc 2> /dev/null
init() {
__init
# Create networks
NETWORKS=(${DB_NETWORK} ${PROXY_NETWORK})
__createNetworks
docker create \
--name ${SERVICE_NAME} \
-e VIRTUAL_HOST=${DOMAIN_NAME} \
-e VIRTUAL_PORT=80 \
-e PGADMIN_DEFAULT_EMAIL=${PGADMIN_DEFAULT_EMAIL} \
-e PGADMIN_DEFAULT_PASSWORD=${PGADMIN_DEFAULT_PASSWORD} \
-v pgadmin:/var/lib/pgadmin \
--restart=unless-stopped \
${IMAGE_NAME}:${IMAGE_VERSION}
[[ $? -ne 0 ]] && return 1
docker network connect ${DB_NETWORK} ${SERVICE_NAME}
[[ $? -ne 0 ]] && return 1
docker network connect ${PROXY_NETWORK} ${SERVICE_NAME}
[[ $? -ne 0 ]] && return 1
__ask_to_start
}
"$@"
Executable
+155
View File
@@ -0,0 +1,155 @@
#!/usr/bin/env bash
SCRIPT_PATH=$( cd "$(dirname "$0")" ; pwd -P )
IMAGE_NAME="postgres"
IMAGE_VERSION="10.9"
POSTGIS_MAJOR="2.5"
POSTGIS_VERSION="2.5.2+dfsg-1~exp1.pgdg90+1"
SERVICE_NAME=pgsql-db
source ${SCRIPT_PATH}/../common.shinc
#
# Project specific variables
#
DB_VOLUME=pgsql_persistent_10
PORT=5432
source ${SCRIPT_PATH}/env.shinc 2> /dev/null
__build() {
docker build \
--build-arg IMAGE_NAME=${IMAGE_NAME} \
--build-arg VERSION=${IMAGE_VERSION} \
--build-arg POSTGIS_MAJOR=${IMAGE_VERSION} \
--build-arg POSTGIS_VERSION=${IMAGE_VERSION} \
-t ${SERVICE_NAME}:latest \
${SCRIPT_PATH}/build
return $?
}
init() {
__init
NETWORKS=(${DB_NETWORK})
__createNetworks
__msg "Removing old postgres bin volume..."
docker volume rm -f ${PGSQL_DB_BIN} &&
docker create \
--name ${SERVICE_NAME} \
--restart=unless-stopped \
-v ${DB_VOLUME}:/var/lib/postgresql/data \
-v ${PGSQL_DB_BIN}:/usr/lib/postgresql/${IMAGE_VERSION}/bin \
-e POSTGRES_USER=${DB_USER} \
-e POSTGRES_PASSWORD=${DB_PASSWORD} \
--net ${DB_NETWORK} \
-p ${PORT}:5432 \
${IMAGE_NAME}:${IMAGE_VERSION}
[[ $? -ne 0 ]] && return 1
__ask_to_start
}
import() {
local dbname="$1"
shift
local filename="$1"
shift
if [[ "${dbname}" == "" ]] || [[ "${filename}" == "" ]]; then
__err "You must provide database name and filename of the file you want to import"
__msg "E.g. ./run import my-database-name \"\$PWD/my-file.sql\""
return 137
fi
if [[ ! -f "${filename}" ]]; then
__err "The filename was not located at ${filename}"
return 137
fi
echo -e "${C_WARN}This will import the file located at \"${C_WHITE}${filename}${C_WARN}\" to a database named \"${C_WHITE}${dbname}${C_WARN}\"${C_NONE}"
echo
__warn "Do you want to continue? [y/(n)] "
read CONTINUE
if [[ "${CONTINUE}" != "y" ]]; then
__msg "Quiting..."
return 0
fi
__msg "Importing, please wait..."
local path=$(realpath "${filename}")
local name=$(basename "${path}")
docker run --rm -it -v "${path}":"/import/${name}" --net ${DB_NETWORK} ${IMAGE_NAME}:${IMAGE_VERSION} pg_restore --no-owner -Fc --host=${SERVICE_NAME} --password --dbname=${dbname} "/import/${name}"
}
migrate9to10() {
local migrationVolume="pgsql-9-10-dump-migration"
local migrationPath="/pgsql-data-dump"
stop
docker volume create ${migrationVolume}
docker run --rm -d \
--name postgres_migration_from_9 \
-v ${DB_VOLUME}:/var/lib/postgresql/data \
-v ${PGSQL_DB_BIN}:/usr/lib/postgresql/${IMAGE_VERSION}/bin \
-v ${migrationVolume}:${migrationPath} \
-e POSTGRES_USER=${DB_USER} \
-e POSTGRES_PASSWORD=${DB_PASSWORD} \
mdillon/postgis:9.5
echo "Waiting for postgres to initialize"
sleep 10
docker exec -it \
postgres_migration_from_9 \
bash -c "pg_dumpall > ${migrationPath}/full.dump"
if [[ $? -ne 0 ]]; then
docker stop postgres_migration_from_9
__err "Bad thing, don't continue, quitsies, bye"
exit 137
fi
docker stop postgres_migration_from_9
docker volume rm -f ${DB_VOLUME}
docker volume create ${DB_VOLUME}
docker run --rm -d \
--name postgres_migration_to_10 \
-v ${DB_VOLUME}:/var/lib/postgresql/data \
-v ${PGSQL_DB_BIN}:/usr/lib/postgresql/${IMAGE_VERSION}/bin \
-v ${migrationVolume}:${migrationPath} \
-e POSTGRES_USER=${DB_USER} \
-e POSTGRES_PASSWORD=${DB_PASSWORD} \
mdillon/postgis:10
echo "Waiting for postgres to initialize"
sleep 30
docker exec -it \
postgres_migration_to_10 \
psql -f ${migrationPath}/full.dump
docker stop postgres_migration_to_10
__init
}
"$@"
exit $?
-49
View File
@@ -1,49 +0,0 @@
#!/usr/bin/env bash
SCRIPT_PATH=$( cd "$(dirname "$0")" ; pwd -P )
IMAGE_NAME="mdillon/postgis"
IMAGE_VERSION="9.5"
SERVICE_NAME=pgsql-db
source ${SCRIPT_PATH}/../common.shinc
#
# Project specific variables
#
DB_VOLUME=pgsql_persistent
PORT=5432
source ${SCRIPT_PATH}/env.shinc 2> /dev/null
init() {
__init
NETWORKS=(${DB_NETWORK})
__createNetworks
__msg "Removing old postgres bin volume..."
docker volume rm -f ${PGSQL_DB_BIN} &&
docker create \
--name ${SERVICE_NAME} \
--restart=unless-stopped \
-v ${DB_VOLUME}:/var/lib/postgresql/data \
-v ${PGSQL_DB_BIN}:/usr/lib/postgresql/${IMAGE_VERSION}/bin \
-e POSTGRES_USER=${DB_USER} \
-e POSTGRES_PASSWORD=${DB_PASSWORD} \
--net ${DB_NETWORK} \
-p ${PORT}:5432 \
${IMAGE_NAME}:${IMAGE_VERSION}
[[ $? -ne 0 ]] && return 1
__ask_to_start
}
"$@"
exit $?
+311
View File
@@ -0,0 +1,311 @@
#!/usr/bin/env bash
installDocker() {
local continue
local distribution
local codename
echo "Installing prerequisites for Docker"
sudo apt update && sudo apt install -y apt-transport-https ca-certificates curl software-properties-common
echo "Fetching GPG key"
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
echo "Verify the fingerprint is correct:"
sudo apt-key fingerprint 0EBFCD88
echo "Does the fingerprint match [9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88] ? [y]/n"
read continue
[[ "${continue}" != "" ]] && [[ "${continue}" != "y" ]] && [[ "${continue}" != "Y" ]] && return 137
distribution=$(lsb_release -is | tr '[:upper:]' '[:lower:]')
codename=$(lsb_release -cs)
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/${distribution} ${codename} stable"
sudo apt update && sudo apt install -y docker-ce
[[ $? -ne 0 ]] && return 137
echo "Do you want to run docker commands without sudo? This will make your system less secure, effectively granting your user root privileges through the use of docker"
echo "y/[n]"
read continue
[[ "${continue}" != "" ]] && [[ "${continue}" != "y" ]] && [[ "${continue}" != "Y" ]] && return 0
sudo usermod -aG docker ${USER}
return 0
}
installGo() {
echo "Installing golang"
echo "Fetching latest tags from github..."
local tags=$(curl -s https://github.com/golang/go/tags | awk '/golang\/go\/releases\/tag/{print $7}' FS='["/]')
local latest=""
if [[ ${tags} = "" ]]; then
echo "Could not fetch the tags"
return 2
fi
echo "Fetched the latest tags, deciding which one to use..."
for tag in ${tags}[@]; do
tag=${tag//go}
if [[ ${tag} = *"rc"* ]]; then
continue
elif [[ ${tag} = *"beta"* ]]; then
continue
elif [[ ${tag} = *"alpha"* ]]; then
continue
fi
echo "Found the latest tag: ${tag}"
latest=${tag}
break
done
if [[ "${latest}" = "" ]]; then
__err "Could not fetch the latest release"
return 2
fi
echo "Downloading golang ${latest}"
sudo curl -L --output "go.tar.gz" "https://storage.googleapis.com/golang/go${latest}.linux-amd64.tar.gz"
echo "Installing golang in /usr/local/go"
sudo tar -C /usr/local -xzf "go.tar.gz"
[[ ! -e /usr/local/go/bin ]] && echo "Did not install go properly" && return 137
grep -q /usr/local/go/bin ~/.bashrc
if [[ $? -ne 0 ]]; then
echo "Adding PATH export to .bashrc to include golang binary location"
echo "export PATH=\$PATH:/usr/local/go/bin" | tee -a ~/.bashrc
fi
echo "Removing the downloaded file"
sudo rm -f "go.tar.gz"
return 0
}
installRelay() {
echo "Installing npiperelay"
echo "Fetching the relay from github"
/usr/local/go/bin/go get -d github.com/jstarks/npiperelay
[[ $? -ne 0 ]] && echo "Could not fetch the relay" && return 137
local diskPath=/mnt/c/Users
[[ ! -d "${diskPath}" ]] && diskPath=/c/Users
[[ ! -d "${diskPath}" ]] && diskPath=/mnt/d/Users
[[ ! -d "${diskPath}" ]] && diskPath=/d/Users
if [[ ! -d "${diskPath}" ]]; then
echo "Cannot locate the directory with user accounts [attempted: /mnt/c/Users, /mnt/d/Users, /c/Users, /d/Users"
until [[ -d "${diskPath}" ]] ; do
echo "Please provide a path to the directory:"
read diskPath
done
fi
local userPath=${diskPath}/${USER}
until [[ -d "${userPath}" ]] ; do
local newUser
echo "Path ${userPath} does not exist!"
echo "It seems you are running the shell under different user, please provide a windows username to install the relay under"
read newUser
userPath=${diskPath}/${newUser}
done
echo "Building the relay binary for windows"
export GOOS=windows
/usr/local/go/bin/go build -o "${userPath}/go/bin/npiperelay.exe" github.com/jstarks/npiperelay
[[ $? -ne 0 ]] && echo "Could not build the binary" && return 137
echo "Linking the relay binary"
[[ -e ${userPath}/go/bin/npiperelay.exe ]] && sudo rm ${userPath}/go/bin/npiperelay.exe
sudo ln -s ${userPath}/go/bin/npiperelay.exe /usr/local/bin/npiperelay.exe
[[ $? -ne 0 ]] && echo "Could not link the binary" && return 137
echo "Installing socat"
sudo apt update
sudo apt install -y socat
[[ $? -ne 0 ]] && echo "Could not install the requirements" && return 137
return 0
}
addStartupScript() {
echo "Creating the docker relay startup script"
local relayLocation=~/.docker-relay
touch "${relayLocation}"
chmod +x "${relayLocation}"
cat << "EOF" | tee -a "${relayLocation}" > /dev/null
#!/usr/bin/env bash
isRelayRunning() {
[[ $(ps aux | grep -v grep | grep "socat UNIX-LISTEN:/var/run/docker.sock,fork,group=docker,umask=007 EXEC" | wc -l) -eq 0 ]] && return 0
return 1
}
isRelayRunning
RUNNING=$?
if [[ ${RUNNING} -eq 0 ]]; then
echo "Starting docker relay"
sudo ls > /dev/null
exec sudo socat UNIX-LISTEN:/var/run/docker.sock,fork,group=docker,umask=007 EXEC:"npiperelay.exe -ep -s //./pipe/docker_engine",nofork &
fi
RETRIES=20
until [[ ${RUNNING} -eq 1 ]] || [[ ${RETRIES} -eq 0 ]]; do
isRelayRunning
RUNNING=$?
sleep 1
RETRIES=$((RETRIES-1))
done
if [[ ${RUNNING} -ne 1 ]] && [[ ${RETRIES} -eq 0 ]]; then
echo "Could not initialize the docker relay!"
echo "Exiting..."
exit 137
fi
exit 0
EOF
echo "Aliasing docker to run the relay script first in ~/.bash_aliases"
cat << EOF | tee -a ~/.bash_aliases > /dev/null
alias docker="${relayLocation} && docker"
EOF
echo "Done, try running 'docker ps'"
return 0
}
installDockerCompose() {
echo "Installing docker-compose"
echo "Fetching latest tags from github..."
local tags=$(curl -s https://github.com/docker/compose/tags | awk '/docker\/compose\/releases\/tag/{print $7}' FS='["/]')
local latest=""
if [[ ${tags} = "" ]]; then
echo "Could not fetch the tags"
return 2
fi
echo "Fetched the latest tags, deciding which one to use..."
for tag in ${tags}[@]; do
tag=${tag//go}
if [[ ${tag} = *"rc"* ]]; then
continue
elif [[ ${tag} = *"beta"* ]]; then
continue
elif [[ ${tag} = *"alpha"* ]]; then
continue
fi
echo "Found the latest tag: ${tag}"
latest=${tag}
break
done
if [[ "${latest}" = "" ]]; then
__err "Could not fetch the latest release"
return 2
fi
local compose_path=$(which docker-compose)
which docker-compose > /dev/null 2>&1
if [[ $? -ne 0 ]]; then
compose_path=/usr/local/bin/docker-compose
__warn "You do not seem to have docker compose installed, installing to ${compose_path}"
fi
__msg "Installing docker-compose ${latest}"
sudo curl -L https://github.com/docker/compose/releases/download/${latest}/docker-compose-`uname -s`-`uname -m` --output "${compose_path}" &&
sudo chmod +x "${compose_path}"
[[ $? -ne 0 ]] && echo "Docker compose might be running, please close all processes before installing this version" && return 2
return 0
}
mapAutomountPaths() {
local continue
echo "Are you running windows version 18.03 or later? y/[n]"
read continue
[[ "${continue}" != "" ]] && [[ "${continue}" != "y" ]] && [[ "${continue}" != "Y" ]] && return 0
cat << EOF | sudo tee /etc/wsl.conf > /dev/null
[automount]
root = /
options = "metadata"
EOF
local linkPath=/usr/local/bin/npiperelay.exe
if [[ -e "${linkPath}" ]]; then
local relayPath=$(readlink $linkPath)
relayPath=${relayPath/\/mnt/}
until [[ -f "${relayPath}" ]]; do
echo "Cannot find path to the npiperelay. Please provide a path to binary"
read relayPath
done
echo "Linking relaypath to ${linkPath}"
ln -s ${relayPath} ${linkPath}
fi
[[ $? -ne 0 ]] && return 137
echo "Please restart your computer, after the restart the volumes will be mounted in /c/, /d/, etc. instead of /mnt/c/, /mnt/d/..."
return 0
}
initialize() {
installDocker
[[ $? -ne 0 ]] && echo "Could not install Docker" && return 137
installGo
[[ $? -ne 0 ]] && echo "Could not install Go" && return 137
installRelay
[[ $? -ne 0 ]] && echo "Could not install relay" && return 137
addStartupScript
[[ $? -ne 0 ]] && echo "Could not add the startup script" && return 137
installDockerCompose
[[ $? -ne 0 ]] && echo "Could not install docker compose" && return 137
mapAutomountPaths
[[ $? -ne 0 ]] && echo "Could not map the volume paths properly" && return 137
return 0
}
[[ ${1} = "" ]] && initialize || "$@"
exit $?