work-on-deployment #15
12 changed files with 155 additions and 51 deletions
|
@ -16,5 +16,8 @@ jobs:
|
||||||
git clone --branch $GITHUB_REF_NAME https://${TOKEN}@${GIT_SERVER}/${REPO}.git .
|
git clone --branch $GITHUB_REF_NAME https://${TOKEN}@${GIT_SERVER}/${REPO}.git .
|
||||||
git fetch
|
git fetch
|
||||||
git checkout ${{ github.head_ref }}
|
git checkout ${{ github.head_ref }}
|
||||||
- name: list
|
- name: prepare deploy
|
||||||
run: ls
|
run: sh ./deploy/prepare-deploy.sh
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -20,5 +20,5 @@
|
||||||
###< phpunit/phpunit ###
|
###< phpunit/phpunit ###
|
||||||
|
|
||||||
.idea/
|
.idea/
|
||||||
/deploy/futtern-app/
|
|
||||||
/deploy/var/
|
/deploy/var/
|
||||||
|
/deploy/app/
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
FROM git.php.fail/lubiana/container/php:8.3 as phpbuild
|
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
[www]
|
[www]
|
||||||
|
|
||||||
user = nobody
|
user = root
|
||||||
group = nobody
|
group = root
|
||||||
listen = 9001
|
listen = 9001
|
||||||
pm = dynamic
|
pm = dynamic
|
||||||
pm.max_children = 5
|
pm.max_children = 5
|
||||||
pm.start_servers = 2
|
pm.start_servers = 2
|
||||||
pm.min_spare_servers = 1
|
pm.min_spare_servers = 1
|
||||||
pm.max_spare_servers = 3
|
pm.max_spare_servers = 3
|
||||||
|
env[APP_ENV]=$APP_ENV
|
||||||
|
env[APP_SECRET]=$APP_SECRET
|
||||||
|
catch_workers_output = yes
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
#!/usr/bin/env sh
|
|
||||||
|
|
||||||
if [ ! -d "var" ]; then
|
|
||||||
mkdir var
|
|
||||||
fi
|
|
||||||
podman pod stop futtern
|
|
||||||
podman pod rm futtern
|
|
||||||
|
|
||||||
podman pod create \
|
|
||||||
--label "io.containers.autoupdate=registry" \
|
|
||||||
--name futtern \
|
|
||||||
-p 8087:8087
|
|
||||||
|
|
||||||
podman run -d \
|
|
||||||
--pod futtern \
|
|
||||||
--name futtern-php \
|
|
||||||
--volume $(pwd)/etc/php83/php-fpm.d/www.conf:/etc/php83/php-fpm.d/www.conf \
|
|
||||||
--volume $(pwd)/futtern-app:/var/www/html \
|
|
||||||
--volume $(pwd)/var:/var/www/html/var \
|
|
||||||
--env 'APP_ENV=prod' \
|
|
||||||
git.php.fail/lubiana/container/php:8.3-fpm
|
|
||||||
|
|
||||||
podman run -d \
|
|
||||||
--pod futtern \
|
|
||||||
--name futtern-caddy \
|
|
||||||
--volume $(pwd)/etc/caddy/Caddyfile:/etc/caddy/Caddyfile \
|
|
||||||
--volume $(pwd)/futtern-app:/var/www/html \
|
|
||||||
--volume caddy_data:/data \
|
|
||||||
docker.io/caddy/caddy:alpine
|
|
||||||
|
|
||||||
echo 'yes' | podman exec -it futtern-php /var/www/html/bin/console doctrine:migrations:migrate
|
|
14
deploy/prepare-deploy.sh
Normal file → Executable file
14
deploy/prepare-deploy.sh
Normal file → Executable file
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
TARGETDIR='futtern-app'
|
TARGETDIR='deploy/app'
|
||||||
|
|
||||||
if [ -d $TARGETDIR ]; then
|
if [ -d $TARGETDIR ]; then
|
||||||
rm -rf $TARGETDIR
|
rm -rf $TARGETDIR
|
||||||
|
@ -8,7 +8,7 @@ fi
|
||||||
mkdir $TARGETDIR
|
mkdir $TARGETDIR
|
||||||
cd $TARGETDIR || return
|
cd $TARGETDIR || return
|
||||||
|
|
||||||
pathsToCopy="public bin config migrations src templates composer.json composer.lock symfony.lock .env etc"
|
pathsToCopy="public bin config migrations src templates composer.json composer.lock symfony.lock .env"
|
||||||
|
|
||||||
for path in $pathsToCopy
|
for path in $pathsToCopy
|
||||||
do
|
do
|
||||||
|
@ -17,14 +17,6 @@ done
|
||||||
|
|
||||||
rm ./bin/phpunit
|
rm ./bin/phpunit
|
||||||
APP_ENV=prod composer install --no-dev -a
|
APP_ENV=prod composer install --no-dev -a
|
||||||
mkdir -p ~/.ssh/
|
|
||||||
# Print the SSH key, replacing newline characters with actual new lines
|
|
||||||
echo "$SSH_PRIVATE_KEY" | tr -d '\r' > ~/.ssh/id_rsa
|
|
||||||
# Set appropriate permissions for the SSH key
|
|
||||||
chmod 600 ~/.ssh/id_rsa
|
|
||||||
# Add the remote host's key to the known_hosts file to avoid authenticity confirmation
|
|
||||||
ssh-keyscan -H $HOST >> ~/.ssh/known_hosts
|
|
||||||
# SCP files to the remote host
|
|
||||||
rsync -avz --delete public/ ${USERNAME}@${HOST}:${TARGETDIR}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
43
deploy/systemd/container-futtern-caddy.service
Normal file
43
deploy/systemd/container-futtern-caddy.service
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
# container-futtern-caddy.service
|
||||||
|
# autogenerated by Podman 4.3.1
|
||||||
|
# Sun Jun 23 05:33:51 UTC 2024
|
||||||
|
|
||||||
|
[Unit]
|
||||||
|
Description=Podman container-futtern-caddy.service
|
||||||
|
Documentation=man:podman-generate-systemd(1)
|
||||||
|
Wants=network-online.target
|
||||||
|
After=network-online.target
|
||||||
|
RequiresMountsFor=%t/containers
|
||||||
|
BindsTo=pod-futtern.service
|
||||||
|
After=pod-futtern.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Environment=PODMAN_SYSTEMD_UNIT=%n
|
||||||
|
Restart=on-failure
|
||||||
|
TimeoutStopSec=70
|
||||||
|
ExecStartPre=/bin/rm \
|
||||||
|
-f %t/%n.ctr-id
|
||||||
|
ExecStart=/usr/bin/podman run \
|
||||||
|
--cidfile=%t/%n.ctr-id \
|
||||||
|
--cgroups=no-conmon \
|
||||||
|
--rm \
|
||||||
|
--pod-id-file %t/pod-futtern.pod-id \
|
||||||
|
--sdnotify=conmon \
|
||||||
|
--replace \
|
||||||
|
-d \
|
||||||
|
--name futtern-caddy \
|
||||||
|
--volume %h/futtern/etc/caddy/Caddyfile:/etc/caddy/Caddyfile \
|
||||||
|
--volume %h/futtern/app:/var/www/html \
|
||||||
|
--volume caddy_data:/data docker.io/caddy/caddy:alpine
|
||||||
|
ExecStop=/usr/bin/podman stop \
|
||||||
|
--ignore -t 10 \
|
||||||
|
--cidfile=%t/%n.ctr-id
|
||||||
|
ExecStopPost=/usr/bin/podman rm \
|
||||||
|
-f \
|
||||||
|
--ignore -t 10 \
|
||||||
|
--cidfile=%t/%n.ctr-id
|
||||||
|
Type=notify
|
||||||
|
NotifyAccess=all
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=default.target
|
46
deploy/systemd/container-futtern-php.service
Normal file
46
deploy/systemd/container-futtern-php.service
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
# container-futtern-php.service
|
||||||
|
# autogenerated by Podman 4.3.1
|
||||||
|
# Sun Jun 23 05:33:51 UTC 2024
|
||||||
|
|
||||||
|
[Unit]
|
||||||
|
Description=Podman container-futtern-php.service
|
||||||
|
Documentation=man:podman-generate-systemd(1)
|
||||||
|
Wants=network-online.target
|
||||||
|
After=network-online.target
|
||||||
|
RequiresMountsFor=%t/containers
|
||||||
|
BindsTo=pod-futtern.service
|
||||||
|
After=pod-futtern.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Environment=PODMAN_SYSTEMD_UNIT=%n
|
||||||
|
Restart=on-failure
|
||||||
|
TimeoutStopSec=70
|
||||||
|
ExecStartPre=/bin/rm \
|
||||||
|
-f %t/%n.ctr-id
|
||||||
|
ExecStart=/usr/bin/podman run \
|
||||||
|
--cidfile=%t/%n.ctr-id \
|
||||||
|
--cgroups=no-conmon \
|
||||||
|
--rm \
|
||||||
|
--pod-id-file %t/pod-futtern.pod-id \
|
||||||
|
--sdnotify=conmon \
|
||||||
|
--replace \
|
||||||
|
-d \
|
||||||
|
--name futtern-php \
|
||||||
|
--volume %h/futtern/etc/php83/php-fpm.d/www.conf:/etc/php83/php-fpm.d/www.conf \
|
||||||
|
--volume %h/futtern/app:/var/www/html \
|
||||||
|
--volume %h/futtern/app/var:/var/www/html/var \
|
||||||
|
--env APP_ENV=prod \
|
||||||
|
--env APP_SECRET=UwUtHiSisNotSecurePlZcHanGeMe \
|
||||||
|
git.php.fail/lubiana/container/php:8.3-fpm
|
||||||
|
ExecStop=/usr/bin/podman stop \
|
||||||
|
--ignore -t 10 \
|
||||||
|
--cidfile=%t/%n.ctr-id
|
||||||
|
ExecStopPost=/usr/bin/podman rm \
|
||||||
|
-f \
|
||||||
|
--ignore -t 10 \
|
||||||
|
--cidfile=%t/%n.ctr-id
|
||||||
|
Type=notify
|
||||||
|
NotifyAccess=all
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=default.target
|
42
deploy/systemd/pod-futtern.service
Normal file
42
deploy/systemd/pod-futtern.service
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
# pod-futtern.service
|
||||||
|
# autogenerated by Podman 4.3.1
|
||||||
|
# Sun Jun 23 05:33:51 UTC 2024
|
||||||
|
|
||||||
|
[Unit]
|
||||||
|
Description=Podman pod-futtern.service
|
||||||
|
Documentation=man:podman-generate-systemd(1)
|
||||||
|
Wants=network-online.target
|
||||||
|
After=network-online.target
|
||||||
|
RequiresMountsFor=/run/user/%U/containers
|
||||||
|
Wants=container-futtern-caddy.service container-futtern-php.service
|
||||||
|
Before=container-futtern-caddy.service container-futtern-php.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Environment=PODMAN_SYSTEMD_UNIT=%n
|
||||||
|
Restart=on-failure
|
||||||
|
TimeoutStopSec=70
|
||||||
|
ExecStartPre=/bin/rm \
|
||||||
|
-f %t/pod-futtern.pid %t/pod-futtern.pod-id
|
||||||
|
ExecStartPre=/usr/bin/podman pod create \
|
||||||
|
--infra-conmon-pidfile %t/pod-futtern.pid \
|
||||||
|
--pod-id-file %t/pod-futtern.pod-id \
|
||||||
|
--exit-policy=stop \
|
||||||
|
--label io.containers.autoupdate=registry \
|
||||||
|
--name futtern \
|
||||||
|
-p 8087:8087 \
|
||||||
|
--replace
|
||||||
|
ExecStart=/usr/bin/podman pod start \
|
||||||
|
--pod-id-file %t/pod-futtern.pod-id
|
||||||
|
ExecStop=/usr/bin/podman pod stop \
|
||||||
|
--ignore \
|
||||||
|
--pod-id-file %t/pod-futtern.pod-id \
|
||||||
|
-t 10
|
||||||
|
ExecStopPost=/usr/bin/podman pod rm \
|
||||||
|
--ignore \
|
||||||
|
-f \
|
||||||
|
--pod-id-file %t/pod-futtern.pod-id
|
||||||
|
PIDFile=%t/pod-futtern.pid
|
||||||
|
Type=forking
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=default.target
|
8
deploy/update.sh
Normal file
8
deploy/update.sh
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
systemctl --user stop pod-futtern
|
||||||
|
systemctl --user start pod-futtern
|
||||||
|
sleep 2
|
||||||
|
podman exec -it futtern-php /var/www/html/bin/console cache:clear
|
||||||
|
podman exec -it futtern-php /var/www/html/bin/console cache:warmup
|
||||||
|
echo 'yes' | podman exec -it futtern-php /var/www/html/bin/console doctrine:migrations:migrate
|
BIN
public/static/img/slice-of-pizza.png
Normal file
BIN
public/static/img/slice-of-pizza.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
|
@ -3,7 +3,7 @@
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>{% block title %}Welcome!{% endblock %}</title>
|
<title>{% block title %}Welcome!{% endblock %}</title>
|
||||||
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 128 128%22><text y=%221.2em%22 font-size=%2296%22>⚫️</text><text y=%221.3em%22 x=%220.2em%22 font-size=%2276%22 fill=%22%23fff%22>sf</text></svg>">
|
<link rel="icon" type="image/png" href="/static/img/slice-of-pizza.png" />
|
||||||
<link rel="stylesheet" href="/static/css/simple.min.css">
|
<link rel="stylesheet" href="/static/css/simple.min.css">
|
||||||
<script src="/static/js/htmx.min.js"></script>
|
<script src="/static/js/htmx.min.js"></script>
|
||||||
</head>
|
</head>
|
||||||
|
|
Loading…
Reference in a new issue