archive
This commit is contained in:
48
cypht2/Dockerfile
Executable file
48
cypht2/Dockerfile
Executable file
@@ -0,0 +1,48 @@
|
||||
FROM php:7.1.26-alpine3.9
|
||||
|
||||
RUN apk add --no-cache \
|
||||
bash \
|
||||
ca-certificates \
|
||||
curl \
|
||||
fcron \
|
||||
gcc \
|
||||
libpng \
|
||||
libpng-dev \
|
||||
openssl \
|
||||
php-bcmath \
|
||||
php-curl \
|
||||
php-fpm \
|
||||
php-gd \
|
||||
php-intl \
|
||||
php-mbstring \
|
||||
php-xml \
|
||||
php-zip \
|
||||
php7-gd \
|
||||
php7-mbstring \
|
||||
php7-pdo \
|
||||
php7-pdo_sqlite \
|
||||
php7-pgsql \
|
||||
php7-pdo_pgsql \
|
||||
postgresql \
|
||||
postgresql-contrib \
|
||||
postgresql-dev \
|
||||
rsync \
|
||||
sqlite \
|
||||
sqlite-dev \
|
||||
sudo \
|
||||
tzdata \
|
||||
wget
|
||||
|
||||
RUN docker-php-ext-install \
|
||||
gd \
|
||||
pdo \
|
||||
pdo_pgsql \
|
||||
pdo_sqlite
|
||||
|
||||
RUN apk del \
|
||||
libpng-dev \
|
||||
postgresql-dev \
|
||||
sqlite-dev
|
||||
|
||||
CMD []
|
||||
ENTRYPOINT ["bash", "/mnt/entrypoint.sh"]
|
||||
30
cypht2/build_and_run.sh
Executable file
30
cypht2/build_and_run.sh
Executable file
@@ -0,0 +1,30 @@
|
||||
#! /bin/bash
|
||||
|
||||
set -e
|
||||
set -u
|
||||
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")"
|
||||
name="$(basename "$(pwd)")"
|
||||
dir="$(pwd)"
|
||||
|
||||
pushd $GOPATH/src/local/rproxy3
|
||||
CGO_ENABLED=0 GOOS=linux go build -o "$dir/mnt/proxy" -a -installsuffix cgo
|
||||
popd
|
||||
|
||||
#img="php"
|
||||
#tag="7.1.26-alpine3.9"
|
||||
#docker pull $img:$tag
|
||||
docker build -t $name:latest .
|
||||
|
||||
mkdir -p ./mnt
|
||||
cp ./entrypoint.sh ./mnt/
|
||||
|
||||
docker run --rm -it \
|
||||
--entrypoint sh \
|
||||
--name $name \
|
||||
-p 8346:8081 \
|
||||
-v $(pwd)/mnt:/mnt \
|
||||
$name:latest \
|
||||
/mnt/entrypoint.sh \
|
||||
-p 8081 -burst 100 -crt /mnt/server.crt -key /mnt/server.key -r localhost:http://localhost:8080 -rate 100 -timeout 30 \
|
||||
"$@"
|
||||
88
cypht2/entrypoint.sh
Executable file
88
cypht2/entrypoint.sh
Executable file
@@ -0,0 +1,88 @@
|
||||
#! /bin/sh
|
||||
|
||||
set -e
|
||||
set -u
|
||||
|
||||
function install_composer() {
|
||||
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
|
||||
php -r "if (hash_file('sha384', 'composer-setup.php') === '48e3236262b34d30969dca3c37281b3b4bbe3221bda826ac6a9a62d6444cdb0dcd0615698a5cbe587c3f0fe57a54d8f5') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
|
||||
php composer-setup.php --install-dir=bin --filename=composer
|
||||
php -r "unlink('composer-setup.php');"
|
||||
}
|
||||
|
||||
function install() {
|
||||
install_composer
|
||||
mkdir /tmp/cypht-temp
|
||||
cd /tmp/cypht-temp
|
||||
wget https://github.com/jasonmunro/cypht/archive/master.zip
|
||||
unzip master.zip
|
||||
cd cypht-master && composer install && cd ..
|
||||
cp cypht-master/hm3.sample.ini cypht-master/hm3.ini
|
||||
find cypht-master -type d -print | xargs chmod 755
|
||||
find cypht-master -type f -print | xargs chmod 644
|
||||
mv cypht-master/* $1
|
||||
cd $1
|
||||
rm -rf /tmp/cypht-temp
|
||||
}
|
||||
|
||||
function config_user_gen() {
|
||||
php ./scripts/config_gen.php
|
||||
php ./scripts/create_account.php admin admin
|
||||
}
|
||||
|
||||
function run_auth_sqlite() {
|
||||
echo "CREATE TABLE hm_user_session (hm_id varchar(180), data longblob, date timestamp, primary key (hm_id));" \
|
||||
| sqlite3 /mnt/test.db || true
|
||||
echo "CREATE TABLE hm_user (username varchar(250), hash varchar(250), primary key (username));" \
|
||||
| sqlite3 /mnt/test.db || true
|
||||
echo "CREATE TABLE hm_user_settings(username varchar(250), settings longblob, primary key (username));" \
|
||||
| sqlite3 /mnt/test.db || true
|
||||
}
|
||||
|
||||
function run_auth_pgsql() {
|
||||
echo '127.0.0.1 localhost' >> /etc/hosts
|
||||
mkdir -p /run/postgresql
|
||||
chmod -R 777 /run/postgresql
|
||||
if [ ! -d /mnt/postgresql/data ]; then
|
||||
sudo -u postgres bash -c '
|
||||
mkdir -p /mnt/postgresql/data &&
|
||||
chmod 0700 /mnt/postgresql/data &&
|
||||
initdb /mnt/postgresql/data &&
|
||||
echo "host all all 0.0.0.0/8 md5" >> /mnt/postgresql/data/pg_hba.conf &&
|
||||
echo "listen_addresses='"'"'*'"'"'" >> /mnt/postgresql/data/postgresql.conf &&
|
||||
pg_ctl -D /mnt/postgresql/data start &&
|
||||
psql postgresql://localhost:5432 \
|
||||
--command "CREATE DATABASE test WITH ENCODING UTF8 TEMPLATE=template0;" &&
|
||||
psql postgresql://localhost:5432/test \
|
||||
--command "CREATE USER bel WITH SUPERUSER PASSWORD '"'"'pwd'"'"';" &&
|
||||
psql postgresql://bel:pwd@localhost:5432/test \
|
||||
--command "GRANT ALL PRIVILEGES ON DATABASE test TO bel;" &&
|
||||
psql postgresql://bel:pwd@localhost:5432/test \
|
||||
--command "CREATE TABLE hm_user_session (hm_id varchar(250) primary key not null, data text, date timestamp);" &&
|
||||
psql postgresql://bel:pwd@localhost:5432/test \
|
||||
--command "CREATE TABLE hm_user (username varchar(255) primary key not null, hash varchar(255));" &&
|
||||
psql postgresql://bel:pwd@localhost:5432/test \
|
||||
--command "CREATE TABLE hm_user_settings (username varchar(250) primary key not null, settings text);"
|
||||
'
|
||||
else
|
||||
sudo -u postgres bash -c 'pg_ctl -D /mnt/postgresql/data start'
|
||||
fi
|
||||
}
|
||||
|
||||
DESTINATION="/mnt/cypht"
|
||||
if [ ! -d $DESTINATION ]; then
|
||||
mkdir -p $DESTINATION
|
||||
install $DESTINATION
|
||||
fi
|
||||
cd $DESTINATION
|
||||
run_auth_pgsql
|
||||
#run_auth_sqlite
|
||||
config_user_gen
|
||||
mkdir -p /var/lib/hm3
|
||||
mkdir -p /var/lib/hm3/attachments
|
||||
mkdir -p /var/lib/hm3/users
|
||||
mkdir -p /var/lib/hm3/app_data
|
||||
ln -s /mnt/cypht/site /var/www/html/mail
|
||||
php -S 0.0.0.0:8080 &
|
||||
/mnt/proxy "$@"
|
||||
exit $?
|
||||
Reference in New Issue
Block a user