Compare commits
23 Commits
88ba0839b5
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 3f700b538c | |||
| 0fa50fa2d9 | |||
| 12777d228c | |||
| a8ac87cc2c | |||
| 0931c0f1bb | |||
| d62c3bb404 | |||
| 2e91e01590 | |||
| b99086b922 | |||
| 248aca2640 | |||
| eb9046a016 | |||
| a923fb6351 | |||
| 366cd94119 | |||
| f21e70669c | |||
| 8325f74371 | |||
| 4d9365e411 | |||
| 65fc1b91a4 | |||
| 2e89c4bb39 | |||
| bb10ae775e | |||
| 70cf118ddb | |||
| 8c494acebe | |||
| 84a14307cb | |||
| 98221c2f7a | |||
| 9a75a91df2 |
@@ -1 +1,2 @@
|
||||
**/env.shinc
|
||||
.idea
|
||||
|
||||
@@ -6,6 +6,15 @@ 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
|
||||
|
||||
+2
-2
@@ -5,7 +5,7 @@ APP_NAME := adminer
|
||||
|
||||
IMAGE_NAME := adminer
|
||||
|
||||
VERSION := 4.7.1
|
||||
VERSION := 4.8.0
|
||||
|
||||
all: build release
|
||||
.PHONY: all
|
||||
@@ -19,8 +19,8 @@ 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_PUBLIC_REGISTRY)/$(APP_NAME):$*
|
||||
docker push $(DOCKER_MY_REGISTRY)/$(APP_NAME):$*
|
||||
docker push $(DOCKER_PUBLIC_REGISTRY)/$(APP_NAME):$*
|
||||
|
||||
|
||||
build: version/$(VERSION)
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
SCRIPT_PATH=$( cd "$(dirname "$0")" ; pwd -P )
|
||||
|
||||
IMAGE_NAME="yoursystemcz/adminer"
|
||||
IMAGE_VERSION="4.7.1"
|
||||
IMAGE_VERSION="4.8.0"
|
||||
|
||||
SERVICE_NAME=adminer
|
||||
|
||||
|
||||
@@ -1,22 +1,25 @@
|
||||
FROM node:10-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/php7.3.list && \
|
||||
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 php7.3-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.14.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
|
||||
|
||||
@@ -17,19 +17,21 @@ GIT_TAG = $(shell git describe --tags --exact-match 2>/dev/null)
|
||||
|
||||
VERSION := $(or $(GIT_TAG),latest)
|
||||
|
||||
all : VERSION := 1.1.0
|
||||
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)-php7.3 .
|
||||
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.3 $(DOCKER_REGISTRY)/$(APP_NAME):$(VERSION)
|
||||
docker tag $(DOCKER_REGISTRY)/$(APP_NAME):$(VERSION)-php7.3 $(DOCKER_REGISTRY)/$(APP_NAME):latest
|
||||
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
|
||||
|
||||
@@ -32,6 +32,8 @@ main() {
|
||||
_version="${VERSION}"
|
||||
fi
|
||||
|
||||
__initVariables "$@"
|
||||
|
||||
__header "Code-Formatter [${_version}]"
|
||||
|
||||
|
||||
@@ -41,13 +43,11 @@ main() {
|
||||
|
||||
case "${_cmd}" in
|
||||
process)
|
||||
__initVariables "$@"
|
||||
source ${INCLUDES_PATH}/process.shinc
|
||||
process
|
||||
return $?
|
||||
;;
|
||||
prettier)
|
||||
__initVariables "$@"
|
||||
source ${INCLUDES_PATH}/formatters/prettier.shinc
|
||||
if [[ ${#CSS_FILES[@]} -ne 0 ]]; then
|
||||
__prettier ${CSS_FILES[@]}
|
||||
@@ -58,13 +58,11 @@ main() {
|
||||
return $?
|
||||
;;
|
||||
csscomb)
|
||||
__initVariables "$@"
|
||||
source ${INCLUDES_PATH}/formatters/csscomb.shinc
|
||||
__csscomb ${CSS_FILES[@]}
|
||||
return $?
|
||||
;;
|
||||
php-cs-fixer)
|
||||
__initVariables "$@"
|
||||
source ${INCLUDES_PATH}/formatters/php-cs-fixer.shinc
|
||||
__phpFixer
|
||||
return $?
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -11,6 +11,7 @@ PHP_FILES=()
|
||||
|
||||
|
||||
DRY_RUN=0
|
||||
OMIT_COLORS=0
|
||||
VERBOSE=0
|
||||
|
||||
|
||||
@@ -21,6 +22,9 @@ __initVariables() {
|
||||
--dry-run)
|
||||
DRY_RUN=1
|
||||
;;
|
||||
--no-color)
|
||||
OMIT_COLORS=1
|
||||
;;
|
||||
--verbose)
|
||||
VERBOSE=1
|
||||
;;
|
||||
|
||||
@@ -117,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
|
||||
|
||||
+6
-6
@@ -1,18 +1,18 @@
|
||||
DOCKER_REGISTRY = dr.ys-dev.cz
|
||||
DOCKER_PUBLIC_REGISTRY = yoursystemcz
|
||||
APP_NAME = dev-proxy
|
||||
APP_VERSION = 2.0
|
||||
|
||||
|
||||
|
||||
all: build release
|
||||
all: build tag release
|
||||
|
||||
|
||||
build:
|
||||
docker build -t $(DOCKER_REGISTRY)/$(APP_NAME):latest --build-arg "IMAGE_NAME=nimmis/alpine" --build-arg "IMAGE_VERSION=3.8" ./src
|
||||
docker build -t $(DOCKER_REGISTRY)/$(APP_NAME):$(APP_VERSION) ./src
|
||||
|
||||
tag:
|
||||
docker tag $(DOCKER_REGISTRY)/$(APP_NAME):latest $(DOCKER_PUBLIC_REGISTRY)/$(APP_NAME):latest
|
||||
docker tag $(DOCKER_REGISTRY)/$(APP_NAME):$(APP_VERSION) $(DOCKER_PUBLIC_REGISTRY)/$(APP_NAME):$(APP_VERSION)
|
||||
|
||||
release: tag
|
||||
docker push $(DOCKER_REGISTRY)/$(APP_NAME):latest
|
||||
docker push $(DOCKER_PUBLIC_REGISTRY)/$(APP_NAME):latest
|
||||
docker push $(DOCKER_REGISTRY)/$(APP_NAME):$(APP_VERSION)
|
||||
docker push $(DOCKER_PUBLIC_REGISTRY)/$(APP_NAME):$(APP_VERSION)
|
||||
|
||||
+3
-2
@@ -3,7 +3,7 @@
|
||||
SCRIPT_PATH=$( cd "$(dirname "$0")" ; pwd -P )
|
||||
|
||||
IMAGE_NAME="yoursystemcz/dev-proxy"
|
||||
IMAGE_VERSION="latest"
|
||||
IMAGE_VERSION="2.0"
|
||||
|
||||
SERVICE_NAME=dev-proxy
|
||||
|
||||
@@ -31,6 +31,7 @@ makePrivate() {
|
||||
--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 \
|
||||
@@ -64,7 +65,7 @@ makePublic() {
|
||||
}
|
||||
|
||||
reload() {
|
||||
docker exec ${SERVICE_NAME} pkill -USR1 caddy
|
||||
docker exec ${SERVICE_NAME} caddy reload --config /etc/caddy/Caddyfile
|
||||
}
|
||||
|
||||
"$@"
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
/.dockerignore
|
||||
/Dockerfile
|
||||
@@ -1,6 +1,6 @@
|
||||
FROM alpine:3.8
|
||||
FROM alpine:3.12
|
||||
|
||||
ARG CADDY_VERSION="0.11.1"
|
||||
ARG CADDY_VERSION="2.2.0"
|
||||
ARG FOREGO_VERSION="0.16.1"
|
||||
ARG DOCKER_GEN_VERSION="0.7.4"
|
||||
|
||||
@@ -32,19 +32,19 @@ RUN wget --quiet "https://github.com/jwilder/docker-gen/releases/download/$DOCKE
|
||||
|
||||
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_v${CADDY_VERSION}_linux_amd64.tar.gz" \
|
||||
"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 \
|
||||
&& /usr/bin/caddy version \
|
||||
&& apk del .build-dependencies
|
||||
|
||||
EXPOSE 80 443 2015
|
||||
EXPOSE 80 443
|
||||
VOLUME /etc/caddy
|
||||
|
||||
|
||||
# Starting app:
|
||||
|
||||
ADD . /code
|
||||
COPY [".", "/code"]
|
||||
WORKDIR /code
|
||||
|
||||
ENTRYPOINT ["sh", "/code/docker-entrypoint.sh"]
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
dockergen: docker-gen -notify-output -config /code/docker-gen/config/docker-gen.cfg
|
||||
caddy: caddy --conf /etc/caddy/Caddyfile --log stdout
|
||||
dockergen: docker-gen -notify-output -config /code/docker-gen/config/docker-gen.cfg -notify caddy reload
|
||||
caddy: caddy run --config /etc/caddy/Caddyfile --watch
|
||||
|
||||
@@ -4,4 +4,4 @@ dest = "/etc/caddy/Caddyfile"
|
||||
onlyexposed = false
|
||||
watch = true
|
||||
wait = "500ms:2s"
|
||||
notifycmd = "pkill -USR1 caddy"
|
||||
notifycmd = "caddy reload --config /etc/caddy/Caddyfile"
|
||||
|
||||
@@ -1,14 +1,23 @@
|
||||
{{ $CurrentContainer := where $ "ID" .Docker.CurrentContainerID | first }}
|
||||
|
||||
{{ $hosts := groupByMulti $ "Env.VIRTUAL_HOST" "," }}
|
||||
{
|
||||
auto_https disable_redirects
|
||||
local_certs
|
||||
}
|
||||
|
||||
{{ if not $hosts }}
|
||||
:80 {
|
||||
log {
|
||||
output stdout
|
||||
}
|
||||
|
||||
127.0.0.1:2015
|
||||
log stdout
|
||||
errors stderr
|
||||
root * /code/errorPages/siteNotFound
|
||||
file_server
|
||||
header Cache-Control "no-cache, max-age=0"
|
||||
try_files {path} /index.html
|
||||
}
|
||||
|
||||
{{ else }}
|
||||
{{ if $hosts }}
|
||||
|
||||
{{ range $host, $containers := $hosts }}
|
||||
{{ $c := first $containers }}
|
||||
@@ -16,34 +25,40 @@ errors stderr
|
||||
{{ $port := coalesce $c.Env.VIRTUAL_PORT "80" }}
|
||||
|
||||
http://{{ $host }}, https://{{ $host }} {
|
||||
tls self_signed
|
||||
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
|
||||
|
||||
proxy / {
|
||||
policy round_robin
|
||||
transparent
|
||||
websocket
|
||||
header_upstream Host {host}
|
||||
header_upstream X-Real-IP {remote}
|
||||
header_upstream X-Forwarded-For {remote}
|
||||
header_upstream X-Forwarded-Proto {scheme}
|
||||
{{ 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
|
||||
upstream {{ $containerNetwork.IP }}:{{ $port }}
|
||||
to {{ $containerNetwork.IP }}:{{ $port }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
}
|
||||
|
||||
gzip {
|
||||
not /__webpack_hmr
|
||||
|
||||
@hmr {
|
||||
not {
|
||||
path /__webpack_hmr
|
||||
}
|
||||
}
|
||||
|
||||
encode @hmr gzip
|
||||
|
||||
log {
|
||||
output stdout
|
||||
}
|
||||
log stdout
|
||||
errors stderr
|
||||
}
|
||||
{{ end }}
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 242 KiB |
File diff suppressed because one or more lines are too long
Executable
+55
@@ -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 $?
|
||||
@@ -32,6 +32,7 @@ init() {
|
||||
--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}
|
||||
@@ -46,6 +47,46 @@ 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
|
||||
}
|
||||
|
||||
+52
-9
@@ -59,9 +59,47 @@ init() {
|
||||
__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"
|
||||
local migrationPath="/pgsql-data-dump"
|
||||
stop
|
||||
docker volume create ${migrationVolume}
|
||||
|
||||
@@ -69,16 +107,20 @@ migrate9to10() {
|
||||
--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} \
|
||||
-v ${migrationVolume}:${migrationPath} \
|
||||
-e POSTGRES_USER=${DB_USER} \
|
||||
-e POSTGRES_PASSWORD=${DB_PASSWORD} \
|
||||
mdillon/postgis:9
|
||||
mdillon/postgis:9.5
|
||||
|
||||
echo "Waiting for postgres to initialize"
|
||||
sleep 10
|
||||
|
||||
docker exec -it \
|
||||
postgres_migration_from_9 \
|
||||
bash -c "pg_dumpall > /migration/full.dump"
|
||||
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
|
||||
@@ -92,15 +134,16 @@ migrate9to10() {
|
||||
--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} \
|
||||
-v ${migrationVolume}:${migrationPath} \
|
||||
-e POSTGRES_USER=${DB_USER} \
|
||||
-e POSTGRES_PASSWORD=${DB_PASSWORD} \
|
||||
mdillon/postgis:10 \
|
||||
psql -d postgres -f ${migrationpath}/full.dump
|
||||
mdillon/postgis:10
|
||||
|
||||
sudo docker exec -it \
|
||||
echo "Waiting for postgres to initialize"
|
||||
sleep 30
|
||||
docker exec -it \
|
||||
postgres_migration_to_10 \
|
||||
psql -f /migration/full.dump
|
||||
psql -f ${migrationPath}/full.dump
|
||||
|
||||
docker stop postgres_migration_to_10
|
||||
|
||||
|
||||
Reference in New Issue
Block a user