Compare commits

..

101 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
Arnie 182343e995 Increase php memory limit 2018-01-17 16:40:45 +01:00
Arnie 3adc15874c Add bigger post size to adminer 2018-01-17 16:39:16 +01:00
Arnie e14b20b061 Update code formatter cs fixer 2018-01-15 08:48:09 +01:00
Arnie dec286b858 Add code formatter 2018-01-09 17:45:46 +01:00
Arnie 4c8162b17b Fix awscli upload 2018-01-09 17:43:50 +01:00
Arnie 9c0461efe6 Fix aws cli paths 2018-01-09 16:00:40 +01:00
Arnie 1dde9c2962 Fix aws cli mount point when mounting a file 2018-01-09 15:42:52 +01:00
Arnie ea08597755 Fix aws cli exec 2018-01-09 15:36:40 +01:00
Arnie b10452ecf5 Fix aws cli exec 2018-01-09 15:34:18 +01:00
Arnie e6320dde0a Platform independent expiry time 2018-01-09 13:22:13 +01:00
Arnie cee7d50580 Update aws cli 2018-01-09 12:32:19 +01:00
Arnie 355369978e Update elastic 2018-01-09 11:51:39 +01:00
Arnie 82e2decda3 Update elastic 2018-01-05 11:29:04 +01:00
Arnie 4d7d6009d1 Update elastic 2018-01-05 10:57:13 +01:00
Arnie 9970ba1a06 Update adminer 2018-01-04 09:58:32 +01:00
Arnie ac46887e75 Replace project name variable for service name 2018-01-04 06:58:48 +01:00
Arnie 770aafa5ca Allow overriding individual service configuration 2018-01-04 06:58:01 +01:00
Arnie af6d1a3272 Add elastic search 2018-01-04 06:56:20 +01:00
Arnie 17fd20d1ca Remove debugging 2018-01-04 06:50:35 +01:00
Arnie b89beaed58 Add reminder not to edit the settings file 2018-01-04 06:37:38 +01:00
Arnie 323fb01588 Add option to override settings 2018-01-04 06:36:49 +01:00
Arnie ad512e2af5 Update license and readme 2018-01-04 06:36:42 +01:00
Arnie 524b9f1c0e Initial commit 2018-01-04 06:34:06 +01:00
65 changed files with 2670 additions and 3 deletions
+2
View File
@@ -0,0 +1,2 @@
**/env.shinc
.idea
+2 -2
View File
@@ -1,9 +1,9 @@
MIT License MIT License
Copyright (c) <year> <copyright holders> Copyright (c) 2017 Čech - iSlužby s.r.o.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+6 -1
View File
@@ -1,3 +1,8 @@
# Docker-development # Docker-development
Development tools in docker Development tools in docker
use `./run.sh init` in each of the project directories that you want to use
to override the default settings use a file `env.shinc`
+20
View File
@@ -0,0 +1,20 @@
ARG IMAGE_NAME
ARG IMAGE_VERSION
FROM ${IMAGE_NAME}:${IMAGE_VERSION}
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)
+2
View File
@@ -0,0 +1,2 @@
max_execution_time = 600
max_input_time = 600
+3
View File
@@ -0,0 +1,3 @@
post_max_size = 2000M
upload_max_filesize = 2000M
memory_limit = 2000M
Executable
+54
View File
@@ -0,0 +1,54 @@
#!/usr/bin/env bash
SCRIPT_PATH=$( cd "$(dirname "$0")" ; pwd -P )
IMAGE_NAME="yoursystemcz/adminer"
IMAGE_VERSION="4.8.0"
SERVICE_NAME=adminer
source ${SCRIPT_PATH}/../common.shinc
#
# Project specific variables
#
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
init() {
__init
# Create networks
NETWORKS=(${DB_NETWORK} ${PROXY_NETWORK})
__createNetworks
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 \
${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
}
"$@"
+6
View File
@@ -0,0 +1,6 @@
*
!.gitignore
!Dockerfile
!README.md
!run.sh
!Makefile
+10
View File
@@ -0,0 +1,10 @@
ARG IMAGE_NAME
ARG IMAGE_VERSION
FROM ${IMAGE_NAME}:${IMAGE_VERSION}
RUN apk --no-cache update && \
apk --no-cache add python py-pip py-setuptools ca-certificates groff less && \
pip --no-cache-dir install awscli && \
rm -rf /var/cache/apk/*
WORKDIR /mnt
+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
+109
View File
@@ -0,0 +1,109 @@
# AWS CLI Docker Container
[![GitHub forks](https://img.shields.io/github/forks/sekka1/aws-cli-docker.svg)](https://github.com/sekka1/aws-cli-docker/network)
[![GitHub stars](https://img.shields.io/github/stars/sekka1/aws-cli-docker.svg)](https://github.com/sekka1/aws-cli-docker/stargazers)
[![GitHub issues](https://img.shields.io/github/issues/sekka1/aws-cli-docker.svg)](https://github.com/sekka1/aws-cli-docker/issues)
[![Twitter](https://img.shields.io/twitter/url/https/github.com/sekka1/aws-cli-docker.svg?style=social)](https://twitter.com/intent/tweet?text=AWS%20CLI%20in%20a%20%40Docker%20container%20%40AWSCLI:&url=https://github.com/sekka1/aws-cli-docker)
[![Docker Pulls](https://img.shields.io/docker/pulls/garland/aws-cli-docker.svg)](https://hub.docker.com/r/garland/aws-cli-docker/)
[![Docker Stars](https://img.shields.io/docker/stars/garland/aws-cli-docker.svg)](https://hub.docker.com/r/garland/aws-cli-docker/)
Docker container with the AWS CLI installed.
Using [Alpine linux](https://hub.docker.com/_/alpine/). The Docker image is 87MB
An automated build of this image is on Docker Hub: https://hub.docker.com/r/garland/aws-cli-docker/
## Getting your AWS Keys:
[http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-set-up.html#cli-signup](http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-set-up.html#cli-signup)
## Passing your keys into this container via environmental variables:
[http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-environment](http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-environment)
## Command line options for things like setting the region
[http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-command-line](http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-command-line)
## You can run any commands available to the AWS CLI
[http://docs.aws.amazon.com/cli/latest/index.html](http://docs.aws.amazon.com/cli/latest/index.html)
## Example Usage:
### Describe an instance:
docker run \
--env AWS_ACCESS_KEY_ID=<<YOUR_ACCESS_KEY>> \
--env AWS_SECRET_ACCESS_KEY=<<YOUR_SECRET_ACCESS>> \
--env AWS_DEFAULT_REGION=us-east-1 \
garland/aws-cli-docker \
aws ec2 describe-instances --instance-ids i-90949d7a
output:
{
"Reservations": [
{
"OwnerId": "960288280607",
"ReservationId": "r-1bb15137",
"Groups": [],
"RequesterId": "226008221399",
"Instances": [
{
"Monitoring": {
"State": "enabled"
},
"PublicDnsName": null,
...
...
}
### Return a list of items in s3 bucket
docker run \
--env AWS_ACCESS_KEY_ID=<<YOUR_ACCESS_KEY>> \
--env AWS_SECRET_ACCESS_KEY=<<YOUR_SECRET_ACCESS>> \
garland/aws-cli-docker \
aws s3 ls
output:
2014-06-03 19:41:30 folder1
2014-06-06 23:02:29 folder2
### Upload content of your current directory (say it contains two files _test.txt_ and _test2.txt_) to s3 bucket
docker run \
--env AWS_ACCESS_KEY_ID=<<YOUR_ACCESS_KEY>> \
--env AWS_SECRET_ACCESS_KEY=<<YOUR_SECRET_ACCESS>> \
-v $PWD:/data
garland/aws-cli-docker \
aws s3 --dryrun sync . s3://mybucket
output:
(dryrun) upload: test.txt to s3://mybucket/test.txt
(dryrun) upload: test2.txt to s3://mybucket/test2.txt
doc: http://docs.aws.amazon.com/cli/latest/reference/s3/index.html
### Retrieve a decrypted Windows password by passing in your private key
We will map the private keys that resides on your local system to inside the container
docker run \
-v <<LOCATION_TO_YOUR_PRIVATE_KEYy>>:/tmp/key.pem \
--env AWS_ACCESS_KEY_ID=<<YOUR_ACCESS_KEY>> \
--env AWS_SECRET_ACCESS_KEY=<<YOUR_SECRET_ACCESS>> \
--env AWS_DEFAULT_REGION=us-east-1 \
garland/aws-cli-docker \
aws ec2 get-password-data --instance-id <<YOUR_INSTANCE_ID>> --priv-launch-key /tmp/key.pem
Output:
{
"InstanceId": "i-90949d7a",
"Timestamp": "2014-12-11T01:18:27.000Z",
"PasswordData": "8pa%o?foo"
}
doc: http://docs.aws.amazon.com/cli/latest/reference/ec2/get-password-data.html
+44
View File
@@ -0,0 +1,44 @@
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 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 ${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.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 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
+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
+37
View File
@@ -0,0 +1,37 @@
#
# Settings
#
# Name of the docker image
APP_NAME := code-formatter
# Select the docker registry to use for the image
DOCKER_REGISTRY := yoursystemcz
# Describe current branch
BRANCH = $(shell git rev-parse --abbrev-ref HEAD)
COMMIT = $(shell git rev-parse HEAD)
GIT_TAG = $(shell git describe --tags --exact-match 2>/dev/null)
VERSION := $(or $(GIT_TAG),latest)
all : VERSION := 1.1.2
all : build release
.PHONY : all
build :
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
+88
View File
@@ -0,0 +1,88 @@
#!/usr/bin/env bash
SCRIPT_PATH=$( cd "$(dirname "$0")" ; pwd -P )
INCLUDES_PATH="${SCRIPT_PATH}/inc"
source ${INCLUDES_PATH}/functions.shinc
source ${INCLUDES_PATH}/variables.shinc
usage() {
# Todo
__success "Options"
__msg "help, --help, -h" 1
__indent 2
echo "Print this help"
echo
}
main() {
trap shutdown SIGTERM SIGINT
local _version="unknown"
if [[ -z ${VERSION+x} ]] || [[ ${VERSION} = "" ]]; then
if [[ -z ${COMMIT_SHA+x} ]] || [[ ${COMMIT_SHA} = "" ]]; then
_version="${COMMIT_SHA}"
fi
elif [[ ${VERSION} = "latest" ]]; then
_version="${VERSION} - ${COMMIT_SHA}"
else
_version="${VERSION}"
fi
__initVariables "$@"
__header "Code-Formatter [${_version}]"
local _cmd=${1}
shift
case "${_cmd}" in
process)
source ${INCLUDES_PATH}/process.shinc
process
return $?
;;
prettier)
source ${INCLUDES_PATH}/formatters/prettier.shinc
if [[ ${#CSS_FILES[@]} -ne 0 ]]; then
__prettier ${CSS_FILES[@]}
fi
if [[ ${#JS_FILES[@]} -ne 0 ]]; then
__prettier ${JS_FILES[@]}
fi
return $?
;;
csscomb)
source ${INCLUDES_PATH}/formatters/csscomb.shinc
__csscomb ${CSS_FILES[@]}
return $?
;;
php-cs-fixer)
source ${INCLUDES_PATH}/formatters/php-cs-fixer.shinc
__phpFixer
return $?
;;
help|--help|-h)
usage
return 0
;;
*)
if [[ ${1} = "" ]]; then
__warn "You need to provide a command"
return 1
else
__err "Invalid command: $1"
fi
return 137
;;
esac
}
main "$@"
exit $?
@@ -0,0 +1,15 @@
#!/usr/bin/env bash
__csscomb() {
__msg "Csscomb:"
local files=("$@")
if [[ ${DRY_RUN} -eq 0 ]]; then
csscomb -v "${files[@]}"
else
csscomb --lint -v "${files[@]}"
fi
return $?
}
@@ -0,0 +1,63 @@
#!/usr/bin/env bash
__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 ${args} fix "${file}"
[[ $? -ne 0 ]] && failed=1
done
else
local needs_fixing=()
local invalid_syntax=()
for file in "${PHP_FILES[@]}"; do
php-cs-fixer ${args} fix --dry-run "${file}"
case $? in
0)
#all good
;;
4)
invalid_syntax+=("${file}")
;;
8)
needs_fixing+=("${file}")
;;
*)
__err "There was an error with php-cs-fixer configuration"
failed=1
;;
esac
done
if [[ ${#needs_fixing[@]} -gt 0 ]]; then
failed=1
__err "Needs fixing:" 1
for file in "${needs_fixing[@]}"; do
__msg "${file}" 2
done
fi
if [[ ${#invalid_syntax[@]} -gt 0 ]]; then
failed=1
__err "Invalid syntax:" 1
for file in "${invalid_syntax[@]}"; do
__msg "${file}" 2
done
fi
fi
return ${failed}
}
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
__prettier() {
__msg "Prettier:"
local files=("$@")
if [[ ${DRY_RUN} -eq 0 ]]; then
prettier --write "${files[@]}"
else
__msg "Listing (: unprettiered :) files:" 1
prettier --list-different "${files[@]}"
fi
return $?
}
+108
View File
@@ -0,0 +1,108 @@
#!/usr/bin/env bash
#
# Logging functions
#
# 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'
}
# Indent by 2 x {n} spaces
__indent() {
if [[ ${1} != "" ]] && [[ ${1} -ne 0 ]]; then
printf %$(expr ${1} \* 4)s
fi
}
# Output functions
__header() {
echo
__success "$*"
echo
}
__footer() {
echo $(printf %20s | tr " " "-")
echo
__indent 1
echo "${1}"
}
__msg() {
__indent $2
__color_white "$1"
echo
}
__success() {
__indent $2
__color_green "$1"
echo
}
__warn() {
__indent $2
__color_yellow "$1"
echo
}
__err() {
__indent $2
__color_red "$1"
echo
}
#
# Helper functions
#
# Termination signal trap
shutdown() {
echo
__warn "Received termination signal, shutting down"
exit 0
}
__path_exists() {
if [[ -z ${1+x} ]] || [[ "${1}" = "" ]]; then
__err "Invalid call to __path_exists: No path supplied"
exit 137
fi
[[ -f ${1} ]] || [[ -d ${1} ]] && return 0
return 1
}
+33
View File
@@ -0,0 +1,33 @@
#!/usr/bin/env bash
source ${INCLUDES_PATH}/formatters/prettier.shinc
source ${INCLUDES_PATH}/formatters/csscomb.shinc
source ${INCLUDES_PATH}/formatters/php-cs-fixer.shinc
process() {
local failed=0
# Run css comb
if [[ ${#CSS_FILES[@]} -ne 0 ]]; then
__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 "${JS_FILES[@]}"
[[ $? -ne 0 ]] && failed=1
fi
# Run PHP cs fixer
if [[ ${#PHP_FILES[@]} -ne 0 ]]; then
__phpFixer
[[ $? -ne 0 ]] && failed=1
fi
return ${failed}
}
+58
View File
@@ -0,0 +1,58 @@
#!/usr/bin/env bash
# List of supplied CSS files for csscomb
CSS_FILES=()
# List of supplied JS files for prettier
JS_FILES=()
# List of supplied php files for php-cs-fixer
PHP_FILES=()
DRY_RUN=0
OMIT_COLORS=0
VERBOSE=0
__initVariables() {
# Loop over parameters and set the variables
while [[ ${#} -gt 0 ]]; do
case "${1}" in
--dry-run)
DRY_RUN=1
;;
--no-color)
OMIT_COLORS=1
;;
--verbose)
VERBOSE=1
;;
*.css|*.scss|*.sass|*.less)
__path_exists "${1}"
if [[ $? -ne 0 ]]; then
__err "Specified path does not exist: ${1}"
else
CSS_FILES+=("${1}")
fi
;;
*.js|*.jsx|*.ts|*.tsx|*.json|*.vue)
__path_exists "${1}"
if [[ $? -ne 0 ]]; then
__err "Specified path does not exist: ${1}"
else
JS_FILES+=("${1}")
fi
;;
*.php|*.phtml)
__path_exists "${1}"
if [[ $? -ne 0 ]]; then
__err "Specified path does not exist: ${1}"
else
PHP_FILES+=("${1}")
fi
;;
esac
shift 1
done
}
+135
View File
@@ -0,0 +1,135 @@
#!/usr/bin/env bash
REQUIRED_VARIABLES=(SERVICE_NAME SCRIPT_PATH IMAGE_NAME IMAGE_VERSION)
for _var in ${REQUIRED_VARIABLES[@]}; do
if [ -z ${!_var+x} ]; then
echo "Missing definition of variable: ${_var}"
exit 2
fi
done
source ${SCRIPT_PATH}/../settings.shinc
source ${SCRIPT_PATH}/../env.shinc 2> /dev/null
source ${SCRIPT_PATH}/../functions.shinc
#
# Commonly used functions
#
stop() {
__msg "Stopping container... " 0 no
STATUS=$(docker stop ${SERVICE_NAME} > /dev/null 2>&1)
if [[ $? -ne 0 ]]; then
__err "${STATUS}"
return 1
else
__success "[ok]"
fi
return 0
}
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}"
return 1
else
__success "[ok]"
fi
return 0
}
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
return 0
}
logs() {
docker logs "$@" ${SERVICE_NAME}
return $?
}
exec() {
# Test if bash is available
docker exec -it ${SERVICE_NAME} /bin/bash -c "echo 'test'" > /dev/null 2>&1
if [[ $? -eq 0 ]]; then
docker exec -it ${SERVICE_NAME} /bin/bash
return $?
fi
# Test if bash is available
docker exec -it ${SERVICE_NAME} /bin/sh -c "echo 'test'" > /dev/null 2>&1
if [[ $? -eq 0 ]]; then
docker exec -it ${SERVICE_NAME} /bin/sh
return $?
fi
__err "Could not find either sh or bash in the container"
return 1
}
help() {
echo "┌──────────────────────────────────────────────────────────────┐"
echo "│ Available commands │"
echo "└──────────────────────────────────────────────────────────────┘"
echo -e -n "$LOG"
echo " > init - Initializes the environment"
echo " > start - Start containers"
echo " > stop - Stops containers"
echo " > remove - Removes traces of the container"
echo " > logs - Shows logs"
echo " > exec - Enters the containers tty"
echo " > help - Display this help"
echo -e -n "${NORMAL}"
echo "└──────────────────────────────────────────────────────────────┘"
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 $?
+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
+69
View File
@@ -0,0 +1,69 @@
#!/usr/bin/env bash
SCRIPT_PATH=$( cd "$(dirname "$0")" ; pwd -P )
IMAGE_NAME="elasticsearch"
# Old version, AWS supported
IMAGE_VERSION="2.3.5"
SERVICE_NAME=ys-elastic-search
source ${SCRIPT_PATH}/../common.shinc
#
# Project specific variables
#
DOMAIN_NAME="elastic.loc"
RELEASE_NAME="yoursystemcz/elasticsearch"
# Old version, AWS supported
RELEASE_VERSION="2.3.5"
PERSISTENT_VOLUME="ys-elastic"
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 $?
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 $?
+108
View File
@@ -0,0 +1,108 @@
#!/usr/bin/env bash
# Indent output by 2 x {n} spaces
__indent() {
if [[ $1 != "" ]] && [[ $1 -ne 0 ]]; then
printf ' %0.s' {1..$1}
fi
}
__newLine() {
if [[ $1 = "" ]]; then
echo
fi
}
__msg() {
echo -ne "${C_WHITE}"
__indent $2
echo -ne "$1${C_NONE}"
__newLine $3
}
__warn() {
echo -ne "${C_WARN}"
__indent $2
echo -ne "$1${C_NONE}"
__newLine $3
}
__success() {
echo -ne "${C_GREEN}"
__indent $2
echo -ne "$1${C_NONE}"
__newLine $3
}
__err() {
echo -ne "${C_ERR}"
__indent $2
echo -ne "$1${C_NONE}"
__newLine $3
}
#
# Internal functions
#
__createNetworks() {
for _var in ${NETWORKS[@]}; do
if [[ ${_var} = "" ]]; then
continue
fi
docker network inspect ${_var} > /dev/null 2>&1
if [[ $? -ne 0 ]]; then
# If it does not, create it
__warn "The network ${_var} does not exist. Creating... " 1 no
STATUS=$(docker network create ${_var} 2>&1)
if [[ $? -ne 0 ]]; then
__err "${STATUS}"
return 117
else
__success "[ok]"
fi
fi
done
return 0
}
init() {
__err "The init function was not overridden"
return 137
}
__init() {
__msg "Initializing ${SERVICE_NAME}"
# Make sure we have the latest build
docker pull ${IMAGE_NAME}:${IMAGE_VERSION}
return $?
}
__build() {
docker build \
--build-arg IMAGE_NAME=${IMAGE_NAME} \
--build-arg IMAGE_VERSION=${IMAGE_VERSION} \
-t ${SERVICE_NAME}:latest \
${SCRIPT_PATH}
return $?
}
__ask_to_start() {
__success "Start the container? [(y)/n]... "
read START
if [[ ${START} != "" ]] && [[ ${START} != "y" ]] && [[ ${START} != "Y" ]]; then
return 0
fi
start
return $?
}
Executable
+50
View File
@@ -0,0 +1,50 @@
#!/usr/bin/env bash
SCRIPT_PATH=$( cd "$(dirname "$0")" ; pwd -P )
IMAGE_NAME="mailhog/mailhog"
IMAGE_VERSION="latest"
SERVICE_NAME=mailhog
source ${SCRIPT_PATH}/../common.shinc
#
# Project specific variables
#
SMTP_PORT=1025
WEB_PORT=8025
DOMAIN_NAME="mailhog.loc"
source ${SCRIPT_PATH}/env.shinc 2> /dev/null
init() {
__init
NETWORKS=(${SMTP_NETWORK} ${PROXY_NETWORK})
__createNetworks
docker create \
--name ${SERVICE_NAME} \
-e VIRTUAL_HOST=${DOMAIN_NAME} \
-e VIRTUAL_PORT=${WEB_PORT} \
-p ${SMTP_PORT}:1025 \
${IMAGE_NAME}:${IMAGE_VERSION}
[[ $? -ne 0 ]] && return 1
docker network connect ${SMTP_NETWORK} ${SERVICE_NAME}
[[ $? -ne 0 ]] && return 1
docker network connect ${PROXY_NETWORK} ${SERVICE_NAME}
[[ $? -ne 0 ]] && return 1
__ask_to_start
}
"$@"
exit $?
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 $?
+5
View File
@@ -0,0 +1,5 @@
ARG IMAGE_NAME
ARG IMAGE_VERSION
FROM ${IMAGE_NAME}:${IMAGE_VERSION}
COPY conf.d/ /etc/nginx/conf.d/
+4
View File
@@ -0,0 +1,4 @@
proxy_connect_timeout 300;
proxy_send_timeout 300;
proxy_read_timeout 300;
send_timeout 300;
+1
View File
@@ -0,0 +1 @@
client_max_body_size 2000m;
Executable
+61
View File
@@ -0,0 +1,61 @@
#!/usr/bin/env bash
SCRIPT_PATH=$( cd "$(dirname "$0")" ; pwd -P )
IMAGE_NAME="jwilder/nginx-proxy"
IMAGE_VERSION="latest"
SERVICE_NAME=nginx-proxy
source ${SCRIPT_PATH}/../common.shinc
#
# Project specific variables
#
source ${SCRIPT_PATH}/env.shinc 2> /dev/null
init() {
__init
NETWORKS=(${PROXY_NETWORK})
__createNetworks
__build || return $?
# Create the nginx-proxy container
docker create \
--name ${SERVICE_NAME} \
-v /var/run/docker.sock:/tmp/docker.sock:ro \
--restart=unless-stopped \
-p 80:80 \
-p 443:443 \
--net ${PROXY_NETWORK} \
${SERVICE_NAME}:latest
[[ $? -ne 0 ]] && return 1
__ask_to_start
}
fix() {
local upperDir=$(docker inspect ${SERVICE_NAME} --format "{{.GraphDriver.Data.UpperDir}}")
[[ $? -ne 0 ]] && __err "Could not determine the nginx proxy filesystem path" && return 2
stop
sudo rm $(docker inspect ${SERVICE_NAME} --format "{{.GraphDriver.Data.UpperDir}}")/etc/nginx/conf.d/default.conf
if [[ $? -eq 0 ]]; then
__success "Succesfully removed the nginx configuration, restart the container"
return 0
else
__err "Could not remove the configuration file"
return 1
fi
}
"$@"
exit $?
+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 $?
+46
View File
@@ -0,0 +1,46 @@
#!/usr/bin/env bash
# DO NOT EDIT THIS FILE DIRECTLY, USE env.shinc FILE TO OVERRIDE THE FOLLOWING VARIABLES
#
# Networks
#
# Reverse proxy
PROXY_NETWORK="web-server"
# Databases
DB_NETWORK="database"
# Mail
SMTP_NETWORK="smtp"
# Elastic search
SEARCH_ENGINE_NETWORK="elastic"
#
# Database settings
#
DB_USER="root"
DB_PASSWORD="megaheslo"
PGSQL_DB_BIN="postgres_bin_dir"
#
# Colors
#
C_NONE="\033[0m" # Reset formating
C_ERR="\033[41;1m" # Red
C_WARN="\033[1;33m" # Yellow
C_HIGHLIGHT="\033[1;95m" # Purple
C_LOG="\033[1;3;36m" # Cyan
C_GREEN="\033[32m"
C_WHITE="\033[1;37m"
+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 $?