Skip to content

Commit 0167984

Browse files
committed
added localhost and remotehost options and support arch linux(pacman)
1 parent e6dc25f commit 0167984

File tree

4 files changed

+118
-32
lines changed

4 files changed

+118
-32
lines changed

README.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Plus, manage docker containers with Portainer.
2222
<p align="left"> arm64/aarch64, x86-64 </p>
2323

2424
#### Supported Linux Package Manage Systems:
25-
<p align="left"> apk, dnf, yum, apt/apt-get, zypper </p>
25+
<p align="left"> apk, dnf, yum, apt/apt-get, zypper, pacman </p>
2626

2727
#### Supported Linux Operation Systems:
2828
<p align="left"> <a href="https://alpinelinux.org/" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/7600810?s=200&v=4" alt="alpine linux" height="40" width="40"/> </a>&nbsp;&nbsp;&nbsp;
@@ -32,7 +32,8 @@ Plus, manage docker containers with Portainer.
3232
<a href="https://ubuntu.com/" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/4604537?s=200&v=4" alt="ubuntu" height="40" width="40"/> </a>&nbsp;&nbsp;&nbsp;
3333
<a href="https://www.raspberrypi.com/" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/1294177?s=200&v=4" alt="ubuntu" height="40" width="40"/> </a>&nbsp;&nbsp;&nbsp;
3434
<a href="https://www.redhat.com/en/technologies/linux-platforms/enterprise-linux" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/33972111?s=200&v=4" alt="redhat on s390x (IBM Z)" height="40" width="40"/> </a>&nbsp;&nbsp;&nbsp;
35-
<a href="https://www.suse.com/products/server/" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/623819?s=200&v=4" alt="opensuse on s390x (IBM Z)" height="40" width="40"/> </a> </p>
35+
<a href="https://www.suse.com/products/server/" target="_blank" rel="noreferrer"> <img src="https://avatars.githubusercontent.com/u/623819?s=200&v=4" alt="opensuse on s390x (IBM Z)" height="40" width="40"/> </a>&nbsp;&nbsp;&nbsp;
36+
<a href="https://archlinux.org/" target="_blank" rel="noreferrer"> <img src="https://gitlab.archlinux.org/uploads/-/system/group/avatar/23/iconfinder_archlinux_386451.png?width=48" alt="arch linux" height="40" width="40"/> </a> </p>
3637

3738
##### Note: Fedora 37, 39 and alpine linux x86-64 compatible, could not try sles IBM Z s390x, rhel IBM Z s390x and raspberrypi.
3839

@@ -92,7 +93,7 @@ chmod +x install.sh
9293

9394
## Requirements
9495

95-
Make sure you have the latest versions of **Docker** and **Docker Compose** installed on your machine.
96+
Make sure you have the latest versions of **Docker** and **Docker Compose** installed on your machine and require up to 2 GB of RAM.
9697

9798
- [How install docker](https://docs.docker.com/engine/install/)
9899
- [How install docker compose](https://docs.docker.com/compose/install/)
@@ -131,7 +132,9 @@ DIRECTORY_PATH=```pwd``` at command line\
131132
DATABASE_IMAGE_NAME=```mariadb``` or ```mysql```\
132133
DATABASE_CONT_NAME=```mariadb```, ```mysql``` or ```custom name```\
133134
DATABASE_PACKAGE_MANAGER=```apt-get update && apt-get install -y gettext-base``` for mariadb, ```microdnf install -y gettext``` for mysql\
134-
DATABASE_ADMIN_COMMANDLINE=```mariadb-admin``` for mariadb, ```mysqladmin``` for mysql
135+
DATABASE_ADMIN_COMMANDLINE=```mariadb-admin``` for mariadb, ```mysqladmin``` for mysql\
136+
SSL_SNIPPET=```echo 'Generated Self-signed SSL Certificate for localhost'``` for localhost\
137+
SSL_SNIPPET=```certbot certonly --webroot --webroot-path /tmp/acme-challenge --rsa-key-size 4096 --non-interactive --agree-tos --no-eff-email --force-renewal --email ${LETSENCRYPT_EMAIL} -d ${DOMAIN_NAME} -d www.${DOMAIN_NAME}``` for remotehost
135138

136139
and
137140

@@ -153,6 +156,8 @@ Firstly: will create external volume
153156
docker volume create --driver local --opt type=none --opt device=${PWD}/certbot --opt o=bind certbot-etc
154157
```
155158

159+
for localhost ssl: Generate Self-signed SSL Certificate with guide [mkcert repository](https://github.com/FiloSottile/mkcert).
160+
156161
```
157162
docker compose up -d
158163
```
@@ -247,6 +252,14 @@ to remove portainer and the other images:
247252
docker rmi $(docker image ls -q)
248253
```
249254

255+
### Logs containers
256+
257+
To fetch the logs of a container.
258+
259+
```
260+
docker container logs container_name_or_id
261+
```
262+
250263
### Project from existing source
251264

252265
Copy all files into a new directory:
@@ -310,7 +323,7 @@ then ```docker container restart rails```
310323

311324
[https://mariadb.com/kb/en/configuring-mariadb-with-option-files/](https://mariadb.com/kb/en/configuring-mariadb-with-option-files/)
312325

313-
[https://dev.mysql.com/doc/refman/8.3/en/](https://dev.mysql.com/doc/refman/8.3/en/)
326+
[https://dev.mysql.com/doc/](https://dev.mysql.com/doc/)
314327

315328
#### Redis
316329

docker-compose.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ services:
44
depends_on:
55
database:
66
condition: service_healthy
7-
build: ./docker/7.0
8-
#image: 'damalis/rails:7.0'
7+
build: ./docker/8.0
8+
#image: 'damalis/rails:8.0'
99
container_name: rails
1010
networks:
1111
- backend
@@ -31,7 +31,7 @@ services:
3131
TZ: '${LOCAL_TIMEZONE}'
3232
labels:
3333
- 'docker-volume-backup.stop-during-backup=true'
34-
command: bash -c "if [ -f \"/app/Gemfile.lock\" ]; then bundle install; else rails new . && echo -en \"gem 'redis', '~> 5.0', '>= 5.0.5'\\ngem 'mysql2', '~> 0.5.4'\\n\" >> /app/Gemfile; fi && rails s -p 9000 -b '0.0.0.0'"
34+
command: bash -c "if [ -f \"/app/Gemfile.lock\" ]; then bundle install; else rails new . && echo -en \"gem 'redis', '~> 5.4'\\ngem 'mysql2', '~> 0.5.6'\\n\" >> /app/Gemfile; fi && rails s -p 9000 -b '0.0.0.0'"
3535

3636
webserver:
3737
depends_on:
@@ -89,8 +89,7 @@ services:
8989
retries: 20
9090
environment:
9191
TZ: '${LOCAL_TIMEZONE}'
92-
entrypoint: /bin/sh -c "certbot certonly --webroot --webroot-path /tmp/acme-challenge --rsa-key-size 4096 --non-interactive --agree-tos --no-eff-email --force-renewal --email ${LETSENCRYPT_EMAIL} -d ${DOMAIN_NAME} -d www.${DOMAIN_NAME};
93-
trap exit TERM; while :; do certbot renew --dry-run; sleep 12h & wait $${!}; done;"
92+
entrypoint: /bin/sh -c "${SSL_SNIPPET}; trap exit TERM; while :; do certbot renew --dry-run; sleep 12h & wait $${!}; done;"
9493

9594
phpmyadmin:
9695
depends_on:
@@ -137,7 +136,7 @@ services:
137136
bash -c "echo ${PMA_HTPASSWD_USERNAME}:phpmyadmin:$$( printf \"%s:%s:%s\" \"${PMA_HTPASSWD_USERNAME}\" \"phpmyadmin\" \"${PMA_HTPASSWD_PASSWORD}\" | md5sum | awk '{print $$1}' ) > ${PMA_CONF_FOLDER}/.htpasswd
138137
&& printf 'AuthType Digest\\nAuthName \"phpmyadmin\"\\nAuthDigestProvider file\\nAuthUserFile ${PMA_CONF_FOLDER}/.htpasswd\\nRequire valid-user\\n' > ${WEBSERVER_DOC_ROOT}/.htaccess && a2enmod auth_digest;
139138
mkdir -p ${WEBSERVER_DOC_ROOT}/../upload && chown www-data:www-data ${WEBSERVER_DOC_ROOT}/../upload && chmod a+w ${WEBSERVER_DOC_ROOT}/../upload; mkdir -p ${WEBSERVER_DOC_ROOT}/../save && chown www-data:www-data ${WEBSERVER_DOC_ROOT}/../save && chmod a+w ${WEBSERVER_DOC_ROOT}/../save;
140-
grep -qxF 'ServerName 127.0.0.1' ${APACHE_CONFDIR_PREFIX}/apache2.conf || echo -e '\\nServerName 127.0.0.1' >> ${APACHE_CONFDIR_PREFIX}/apache2.conf; grep -qe 'date.timezone = ${LOCAL_TIMEZONE}' ${PHP_INI_DIR_PREFIX}/php/conf.d/security.ini || echo 'date.timezone = ${LOCAL_TIMEZONE}' >> ${PHP_INI_DIR_PREFIX}/php/conf.d/security.ini;
139+
grep -qxF 'ServerName 127.0.0.1' ${APACHE_CONFDIR_PREFIX}/apache2.conf || echo -e '\\nServerName 127.0.0.1' >> ${APACHE_CONFDIR_PREFIX}/apache2.conf; grep -qxF 'date.timezone = ${LOCAL_TIMEZONE}' ${PHP_INI_DIR_PREFIX}/php/conf.d/security.ini || echo 'date.timezone = ${LOCAL_TIMEZONE}' >> ${PHP_INI_DIR_PREFIX}/php/conf.d/security.ini;
141140
a2enmod ssl && a2ensite default-ssl && a2dissite 000-default && /docker-entrypoint.sh 'apache2-foreground'"
142141
143142
database:
@@ -173,7 +172,7 @@ services:
173172
- "docker-volume-backup.stop-during-backup=true"
174173
- "docker-volume-backup.archive-pre=/bin/sh -c 'mysqldump -uroot -p${MYSQL_ROOT_PASSWORD} --all-databases > /tmp/backup/db_backup_data.sql'"
175174
- "docker-volume-backup.exec-label=database"
176-
command: bash -c "${DATABASE_PACKAGE_MANAGER} && export PMA_CONTROLUSER=${PMA_CONTROLUSER} export PMA_CONTROLPASS=${PMA_CONTROLPASS} && envsubst '$$PMA_CONTROLUSER,$$PMA_CONTROLPASS' < /docker-entrypoint-initdb.d/create_tables.sql.template > /docker-entrypoint-initdb.d/create_tables.sql && docker-entrypoint.sh --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci"
175+
command: bash -c "${DATABASE_PACKAGE_MANAGER} && chmod 0444 ${MYSQL_CONF_PREFIX}/z-mysql.cnf && export PMA_CONTROLUSER=${PMA_CONTROLUSER} export PMA_CONTROLPASS=${PMA_CONTROLPASS} && envsubst '$$PMA_CONTROLUSER,$$PMA_CONTROLPASS' < /docker-entrypoint-initdb.d/create_tables.sql.template > /docker-entrypoint-initdb.d/create_tables.sql && docker-entrypoint.sh --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci"
177176

178177
redis:
179178
image: redis:latest

env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ DIRECTORY_PATH=directory_path
66

77
LETSENCRYPT_EMAIL=email@domain.com
88
LETSENCRYPT_CONF_PREFIX=/etc/letsencrypt
9+
SSL_SNIPPET=ssl_snippet
910

1011
PHP_INI_DIR_PREFIX=/usr/local/etc
1112

install.sh

Lines changed: 93 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ sleep 2
1212

1313
# the "lpms" is an abbreviation of Linux Package Management System
1414
lpms=""
15-
for i in apk dnf yum apt zypper
15+
for i in apk dnf yum apt zypper pacman
1616
do
1717
if [ -x "$(command -v $i)" ]; then
1818
if [ "$i" == "apk" ]
@@ -33,6 +33,10 @@ do
3333
lpms=$i
3434
break
3535
elif [[ $(grep -Pow 'ID_LIKE=\K[^;]*' /etc/os-release) == *"suse"* ]]
36+
then
37+
lpms=$i
38+
break
39+
elif [ "$i" == "pacman" ]
3640
then
3741
lpms=$i
3842
break
@@ -47,15 +51,6 @@ if [ -z $lpms ]; then
4751
exit 0
4852
fi
4953

50-
##########
51-
# set varnish version
52-
##########
53-
varnish_version="stable"
54-
if ([[ $(grep -Pow 'VERSION_ID=\K[^;]*' /etc/os-release | tr -d '"') == 9* ]] && [ $(grep -Pow 'ID=\K[^;]*' /etc/os-release | tr -d '"') == "centos" ]) || [ $(grep -Pow 'ID=\K[^;]*' /etc/os-release | tr -d '"') == "fedora" ]
55-
then
56-
varnish_version="latest"
57-
fi
58-
5954
##########
6055
# Uninstall old versions
6156
##########
@@ -87,6 +82,9 @@ then
8782
then
8883
sudo zypper remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine runc
8984
fi
85+
elif [ "$lpms" == "pacman" ]
86+
then
87+
sudo pacman -Rssn podman-docker podman-compose
9088
else
9189
echo ""
9290
echo "could not be detected package management system"
@@ -175,6 +173,10 @@ then
175173

176174
#Installed=`sudo apt-cache policy docker-ce | sed -n '2p' | cut -c 14-`
177175
#Candidate=`sudo apt-cache policy docker-ce | sed -n '3p' | cut -c 14-`
176+
elif [ "$lpms" == "pacman" ]
177+
then
178+
sudo pacman -Syu --noconfirm
179+
sudo pacman -Ss docker docker-buildx
178180
else
179181
echo ""
180182
echo "could not be detected package management system"
@@ -231,13 +233,13 @@ echo "======================================================================="
231233
echo ""
232234
echo ""
233235
echo "======================================================================="
234-
echo "| Installing Docker Compose v2.27.2..."
236+
echo "| Installing Docker Compose v2.32.4..."
235237
echo "======================================================================="
236238
echo ""
237239
sleep 2
238240

239241
sudo mkdir -p /usr/local/lib/docker/cli-plugins
240-
sudo curl -SL "https://github.com/docker/compose/releases/download/v2.27.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/lib/docker/cli-plugins/docker-compose
242+
sudo curl -SL "https://github.com/docker/compose/releases/download/v2.32.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/lib/docker/cli-plugins/docker-compose
241243
sudo chmod +x /usr/local/lib/docker/cli-plugins/docker-compose
242244

243245
echo ""
@@ -266,27 +268,97 @@ clear
266268
# Setup project variables
267269
##########
268270
echo ""
269-
echo ""
270271
echo "======================================================================="
271272
echo "| Please enter project related variables..."
272273
echo "======================================================================="
273274
echo ""
274275
sleep 2
275276

277+
# set the host
278+
which_h=""
279+
items=("localhost" "remotehost")
280+
PS3="which computer command line are you on? Select the host: "
281+
select h in "${items[@]}"
282+
do
283+
case $REPLY in
284+
1)
285+
which_h=$h
286+
break;;
287+
2)
288+
which_h=$h
289+
break;;
290+
*)
291+
echo "Invalid choice $REPLY";;
292+
esac
293+
done
294+
echo "Ok."
295+
276296
# set your domain name
277-
domain_name=""
278-
read -p 'Enter Domain Name(e.g. : example.com): ' domain_name
297+
if [ "$which_h" == "localhost" ]
298+
then
299+
read -p 'Enter Domain Name(default : localhost or e.g. : example.com): ' domain_name
300+
: ${domain_name:=localhost}
301+
[ "$domain_name" != "localhost" ] && sudo -- sh -c -e "grep -qxF '127.0.0.1 $domain_name' /etc/hosts || echo '127.0.0.1 $domain_name' >> /etc/hosts"
302+
else
303+
domain_name=""
304+
read -p 'Enter Domain Name(e.g. : example.com): ' domain_name
305+
#[ "$domain_name" != "localhost" ] && sudo -- sh -c -e "sed -i '/$domain_name/d' /etc/hosts"
306+
fi
279307
[ -z $domain_name ] && domain_name="NULL"
280308
host -N 0 $domain_name 2>&1 > /dev/null
281309
while [ $? -ne 0 ]
282310
do
283311
echo "Try again"
284-
read -p 'Enter Domain Name(e.g. : example.com): ' domain_name
312+
sudo -- sh -c -e "sed -i '/$domain_name/d' /etc/hosts"
313+
if [ "$which_h" == "localhost" ]
314+
then
315+
read -p 'Enter Domain Name(default : localhost or e.g. : example.com): ' domain_name
316+
: ${domain_name:=localhost}
317+
[ "$domain_name" != "localhost" ] && sudo -- sh -c -e "grep -qxF '127.0.0.1 $domain_name' /etc/hosts || echo '127.0.0.1 $domain_name' >> /etc/hosts"
318+
else
319+
read -p 'Enter Domain Name(e.g. : example.com): ' domain_name
320+
#[ "$domain_name" != "localhost" ] && sudo -- sh -c -e "sed -i '/$domain_name/d' /etc/hosts"
321+
fi
285322
[ -z $domain_name ] && domain_name="NULL"
286323
host -N 0 $domain_name 2>&1 > /dev/null
287324
done
288325
echo "Ok."
289326

327+
ssl_snippet=""
328+
if [ "$which_h" == "localhost" ]
329+
then
330+
ssl_snippet="echo 'Generated Self-signed SSL Certificate for localhost'"
331+
if [ "$lpms" == "apk" ]
332+
then
333+
sudo apk add --no-cache nss-tools go git
334+
elif [ "$lpms" == "dnf" ]
335+
then
336+
sudo dnf install nss-tools go git
337+
elif [ "$lpms" == "yum" ]
338+
then
339+
sudo yum install nss-tools go git
340+
elif [ "$lpms" == "zypper" ]
341+
then
342+
sudo zypper install mozilla-nss-tools go git
343+
elif [ "$lpms" == "apt" ]
344+
then
345+
sudo apt install libnss3-tools go git
346+
elif [ "$lpms" == "pacman" ]
347+
then
348+
sudo pacman -S nss go git
349+
else
350+
echo ""
351+
echo "could not be detected package management system"
352+
echo ""
353+
exit 0
354+
fi
355+
sudo rm -Rf mkcert && git clone https://github.com/FiloSottile/mkcert && cd mkcert && go build -ldflags "-X main.Version=$(git describe --tags)"
356+
sudo mkcert -uninstall && mkcert -install && mkcert -key-file privkey.pem -cert-file chain.pem $domain_name *.$domain_name && sudo cat privkey.pem chain.pem > fullchain.pem && sudo mkdir -p ../certbot/live/$domain_name && sudo mv *.pem ../certbot/live/$domain_name && cd ..
357+
echo "Ok."
358+
else
359+
ssl_snippet="certbot certonly --webroot --webroot-path \/tmp\/acme-challenge --rsa-key-size 4096 --non-interactive --agree-tos --no-eff-email --force-renewal --email \$\{LETSENCRYPT_EMAIL\} -d \$\{DOMAIN_NAME\} -d www.\$\{DOMAIN_NAME\}"
360+
fi
361+
290362
# set parameters in env.example file
291363
email=""
292364
regex="^[a-zA-Z0-9\._-]+\@[a-zA-Z0-9._-]+\.[a-zA-Z]+\$"
@@ -398,22 +470,23 @@ echo "Ok."
398470

399471
read -p "Apply changes (y/n)? " choice
400472
case "$choice" in
401-
y|Y ) echo "Yes! Proceeding now...";;
473+
y|Y ) clear; echo ""; echo "Yes! Proceeding now...";;
402474
n|N ) echo "No! Aborting now..."; exit 0;;
403475
* ) echo "Invalid input! Aborting now..."; exit 0;;
404476
esac
405477

406-
cp ./phpmyadmin/apache2/sites-available/default-ssl.sample.conf ./phpmyadmin/apache2/sites-available/default-ssl.conf
407-
cp ./database/phpmyadmin/sql/create_tables.sql.template.example ./database/phpmyadmin/sql/create_tables.sql.template
478+
\cp ./phpmyadmin/apache2/sites-available/default-ssl.sample.conf ./phpmyadmin/apache2/sites-available/default-ssl.conf
479+
\cp ./database/phpmyadmin/sql/create_tables.sql.template.example ./database/phpmyadmin/sql/create_tables.sql.template
408480

409-
cp env.example .env
481+
\cp env.example .env
410482

411483
sed -i "s/db_authentication_password/${db_authentication_password}/" ./database/phpmyadmin/sql/create_tables.sql.template
412484
sed -i "s|db_package_manager|${db_package_manager}|" .env
413485
sed -i 's/db_admin_commandline/'$db_admin_commandline'/' .env
414486
sed -i 's/example.com/'$domain_name'/' .env
415487
sed -i 's/example.com/'$domain_name'/g' ./phpmyadmin/apache2/sites-available/default-ssl.conf
416488
sed -i 's/email@domain.com/'$email'/' .env
489+
sed -i "s/ssl_snippet/$ssl_snippet/" .env
417490
sed -i 's/which_db/'$which_db'/g' .env
418491
sed -i 's/db_username/'$db_username'/g' .env
419492
sed -i 's/db_password/'$db_password'/g' .env

0 commit comments

Comments
 (0)