diff --git a/.forgejo/workflows/release.yml b/.forgejo/workflows/release.yml index a1c6c78..9602add 100644 --- a/.forgejo/workflows/release.yml +++ b/.forgejo/workflows/release.yml @@ -16,8 +16,5 @@ jobs: git clone --branch $GITHUB_REF_NAME https://${TOKEN}@${GIT_SERVER}/${REPO}.git . git fetch git checkout ${{ github.head_ref }} - - name: prepare deploy - run: sh ./deploy/prepare-deploy.sh - - - + - name: list + run: ls diff --git a/.gitignore b/.gitignore index feabc44..62752be 100644 --- a/.gitignore +++ b/.gitignore @@ -20,5 +20,5 @@ ###< phpunit/phpunit ### .idea/ +/deploy/futtern-app/ /deploy/var/ -/deploy/app/ diff --git a/deploy/Dockerfile b/deploy/Dockerfile new file mode 100644 index 0000000..47bc55b --- /dev/null +++ b/deploy/Dockerfile @@ -0,0 +1,2 @@ +FROM git.php.fail/lubiana/container/php:8.3 as phpbuild + diff --git a/deploy/etc/php83/php-fpm.d/www.conf b/deploy/etc/php83/php-fpm.d/www.conf index e5a895d..113b8c2 100644 --- a/deploy/etc/php83/php-fpm.d/www.conf +++ b/deploy/etc/php83/php-fpm.d/www.conf @@ -1,13 +1,10 @@ [www] -user = root -group = root +user = nobody +group = nobody listen = 9001 pm = dynamic pm.max_children = 5 pm.start_servers = 2 pm.min_spare_servers = 1 -pm.max_spare_servers = 3 -env[APP_ENV]=$APP_ENV -env[APP_SECRET]=$APP_SECRET -catch_workers_output = yes +pm.max_spare_servers = 3 \ No newline at end of file diff --git a/deploy/install.sh b/deploy/install.sh new file mode 100755 index 0000000..d4b64b7 --- /dev/null +++ b/deploy/install.sh @@ -0,0 +1,31 @@ +#!/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 diff --git a/deploy/prepare-deploy.sh b/deploy/prepare-deploy.sh old mode 100755 new mode 100644 index 5bb412a..c0ad1ed --- a/deploy/prepare-deploy.sh +++ b/deploy/prepare-deploy.sh @@ -1,6 +1,6 @@ #!/usr/bin/env sh -TARGETDIR='deploy/app' +TARGETDIR='futtern-app' if [ -d $TARGETDIR ]; then rm -rf $TARGETDIR @@ -8,7 +8,7 @@ fi mkdir $TARGETDIR cd $TARGETDIR || return -pathsToCopy="public bin config migrations src templates composer.json composer.lock symfony.lock .env" +pathsToCopy="public bin config migrations src templates composer.json composer.lock symfony.lock .env etc" for path in $pathsToCopy do @@ -17,6 +17,14 @@ done rm ./bin/phpunit 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} diff --git a/deploy/systemd/container-futtern-caddy.service b/deploy/systemd/container-futtern-caddy.service deleted file mode 100644 index 1067128..0000000 --- a/deploy/systemd/container-futtern-caddy.service +++ /dev/null @@ -1,43 +0,0 @@ -# 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 diff --git a/deploy/systemd/container-futtern-php.service b/deploy/systemd/container-futtern-php.service deleted file mode 100644 index e6f139c..0000000 --- a/deploy/systemd/container-futtern-php.service +++ /dev/null @@ -1,46 +0,0 @@ -# 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 diff --git a/deploy/systemd/pod-futtern.service b/deploy/systemd/pod-futtern.service deleted file mode 100644 index 10a8fb0..0000000 --- a/deploy/systemd/pod-futtern.service +++ /dev/null @@ -1,42 +0,0 @@ -# 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 diff --git a/deploy/update.sh b/deploy/update.sh deleted file mode 100644 index 4d7548a..0000000 --- a/deploy/update.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/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 diff --git a/public/static/img/slice-of-pizza.png b/public/static/img/slice-of-pizza.png deleted file mode 100644 index 300e7e7..0000000 Binary files a/public/static/img/slice-of-pizza.png and /dev/null differ diff --git a/templates/base.html.twig b/templates/base.html.twig index 1918768..93a64b7 100644 --- a/templates/base.html.twig +++ b/templates/base.html.twig @@ -3,7 +3,7 @@